Skip to content

Commit 0b95e12

Browse files
committed
FileManager: repair homeDirectoryForCurrentUser on Windows
The `homeDirectory(forUser:)` is currently not functioning properly for users other than the current user. Switch to directly using the CoreFoundation API which simplifies the logic and makes the functionality work on Windows. This uses the forced unwrap for the return value, which was previously the case and resulted in a trap on Windows.
1 parent ff83ef2 commit 0b95e12

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Sources/Foundation/FileManager.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1140,7 +1140,7 @@ open class FileManager : NSObject {
11401140
}
11411141

11421142
open var homeDirectoryForCurrentUser: URL {
1143-
return homeDirectory(forUser: NSUserName())!
1143+
CFCopyHomeDirectoryURLForUser(nil)!.takeRetainedValue()._swiftObject
11441144
}
11451145

11461146
open var temporaryDirectory: URL {

0 commit comments

Comments
 (0)