Implementations of CommonDirs for Linux

This commit is contained in:
Max Howell
2019-01-20 13:03:38 -05:00
parent a98ba37e59
commit 152ad8a8ae
2 changed files with 76 additions and 35 deletions

View File

@@ -16,31 +16,6 @@ public struct Path: Equatable, Hashable, Comparable {
/// The underlying filesystem path
public let string: String
/// Returns a `Path` containing ``FileManager.default.currentDirectoryPath`.
public static var cwd: Path {
return Path(string: FileManager.default.currentDirectoryPath)
}
/// Returns a `Path` representing the root path.
public static var root: Path {
return Path(string: "/")
}
/// Returns a `Path` representing the users home directory
public static var home: Path {
let string: String
#if os(macOS)
if #available(OSX 10.12, *) {
string = FileManager.default.homeDirectoryForCurrentUser.path
} else {
string = NSHomeDirectory()
}
#else
string = NSHomeDirectory()
#endif
return Path(string: string)
}
/**
Returns the filename extension of this path.
- Remark: Implemented via `NSString.pathExtension`.