Use FileManager.homeDirectory where possible

This commit is contained in:
Max Howell
2019-01-19 14:35:42 -05:00
parent cd30e89808
commit 29149da72b

View File

@@ -12,7 +12,17 @@ public struct Path: Equatable, Hashable, Comparable {
}
public static var home: Path {
return Path(string: NSHomeDirectory())
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)
}
@inlinable