<!--
{
  "availability" : [
    "iOS: 15.0.0 -",
    "iPadOS: 15.0.0 -",
    "macCatalyst: 15.0.0 -",
    "macOS: 12.0.0 -",
    "tvOS: 15.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 8.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "System",
  "identifier" : "/documentation/System/FilePath/ComponentView",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "System"
    ],
    "preciseIdentifier" : "s:6System8FilePathV13ComponentViewV"
  },
  "title" : "FilePath.ComponentView"
}
-->

# FilePath.ComponentView

A bidirectional, range replaceable collection of the non-root components
that make up a file path.

```
struct ComponentView
```

## Overview

ComponentView provides access to standard `BidirectionalCollection`
algorithms for accessing components from the front or back, as well as
standard `RangeReplaceableCollection` algorithms for modifying the
file path using component or range of components granularity.

Example:

```
var path: FilePath = "/./home/./username/scripts/./tree"
let scriptIdx = path.components.lastIndex(of: "scripts")!
path.components.insert("bin", at: scriptIdx)
// path is "/./home/./username/bin/scripts/./tree"

path.components.removeAll { $0.kind == .currentDirectory }
// path is "/home/username/bin/scripts/tree"
```

## Relationships

### Conforms To

[`Encodable`](/documentation/Swift/Encodable)

[`Collection`](/documentation/Swift/Collection)

[`Hashable`](/documentation/Swift/Hashable)

[`Copyable`](/documentation/Swift/Copyable)

[`BidirectionalCollection`](/documentation/Swift/BidirectionalCollection)

[`Escapable`](/documentation/Swift/Escapable)

[`Decodable`](/documentation/Swift/Decodable)

[`Sequence`](/documentation/Swift/Sequence)

[`Sendable`](/documentation/Swift/Sendable)

[`RangeReplaceableCollection`](/documentation/Swift/RangeReplaceableCollection)

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

[`Equatable`](/documentation/Swift/Equatable)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)