Dynamic Members
This commit is contained in:
@@ -23,6 +23,8 @@ import Foundation
|
||||
- Note: There may not be an actual filesystem entry at the path. The underlying
|
||||
representation for `Path` is `String`.
|
||||
*/
|
||||
|
||||
@dynamicMemberLookup
|
||||
public struct Path: Equatable, Hashable, Comparable {
|
||||
|
||||
init(string: String) {
|
||||
@@ -45,6 +47,12 @@ public struct Path: Equatable, Hashable, Comparable {
|
||||
return URL(fileURLWithPath: string)
|
||||
}
|
||||
|
||||
/// Facilitates constructing paths for static strings
|
||||
public subscript(dynamicMember pathComponent: String) -> Path {
|
||||
let str = (string as NSString).appendingPathComponent(pathComponent)
|
||||
return Path(string: str)
|
||||
}
|
||||
|
||||
/**
|
||||
Returns the parent directory for this path.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user