From 29149da72b9bd33c5b97d022948d522d53109681 Mon Sep 17 00:00:00 2001 From: Max Howell Date: Sat, 19 Jan 2019 14:35:42 -0500 Subject: [PATCH] Use FileManager.homeDirectory where possible --- Sources/Path.swift | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Sources/Path.swift b/Sources/Path.swift index 962da84..858e3c0 100644 --- a/Sources/Path.swift +++ b/Sources/Path.swift @@ -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