Add Path.components

This commit is contained in:
Max Howell
2019-02-15 13:38:36 -05:00
parent a644208c62
commit 476cdc1461
3 changed files with 15 additions and 0 deletions

View File

@@ -200,6 +200,15 @@ public struct Path: Equatable, Hashable, Comparable {
}
}
/**
Splits the string representation on the directory separator.
- Important: The first element is always "/" to be consistent with `NSString.pathComponents`.
*/
@inlinable
public var components: [String] {
return ["/"] + string.split(separator: "/").map(String.init)
}
//MARK: Pathing
/**