---
title: FilePath.ComponentView
framework: system
role: symbol
role_heading: Structure
path: system/filepath/componentview
---

# FilePath.ComponentView

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

## Declaration

```swift
struct ComponentView
```

## Overview

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

- [BidirectionalCollection](swift/bidirectionalcollection.md)
- [Collection](swift/collection.md)
- [Copyable](swift/copyable.md)
- [Decodable](swift/decodable.md)
- [Encodable](swift/encodable.md)
- [Equatable](swift/equatable.md)
- [Escapable](swift/escapable.md)
- [Hashable](swift/hashable.md)
- [RangeReplaceableCollection](swift/rangereplaceablecollection.md)
- [Sendable](swift/sendable.md)
- [SendableMetatype](swift/sendablemetatype.md)
- [Sequence](swift/sequence.md)
