Add Path.source()

This commit is contained in:
Max Howell
2020-08-19 11:41:26 -04:00
parent 8b90260517
commit 6461a550c6
5 changed files with 72 additions and 23 deletions

View File

@@ -14,6 +14,18 @@ extension Path {
return .init(string: "/")
}
#if swift(>=5.3)
public static func source(for filePath: String = #filePath) -> (file: DynamicPath, directory: DynamicPath) {
let file = DynamicPath(string: filePath)
return (file: file, directory: .init(file.parent))
}
#else
public static func source(for filePath: String = #file) -> (file: DynamicPath, directory: DynamicPath) {
let file = DynamicPath(string: filePath)
return (file: file, directory: .init(file.parent))
}
#endif
/// Returns a `Path` representing the users home directory
public static var home: DynamicPath {
let string: String