Skip to content

Commit e07817c

Browse files
authored
FoundationEssentials: recover from backslide on Windows (#593)
This new helper was added but did not support windows as `stat` is a Unix operation and the Windows equivalent is more nuanced when you are trying to minimise IO overheads. Add a Windows specific path to repair the build on Windows.
1 parent 543a9e4 commit e07817c

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

Sources/FoundationEssentials/URL/URL.swift

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1991,7 +1991,15 @@ extension URL {
19911991

19921992
#if !NO_FILESYSTEM
19931993
private static func isDirectory(_ path: String) -> Bool {
1994-
return FileManager.default._fileStat(path)?.isDirectory ?? false
1994+
#if !FOUNDATION_FRAMEWORK
1995+
var isDirectory: Bool = false
1996+
_ = FileManager.default.fileExists(atPath: path, isDirectory: &isDirectory)
1997+
return isDirectory
1998+
#else
1999+
var isDirectory: ObjCBool = false
2000+
_ = FileManager.default.fileExists(atPath: path, isDirectory: &isDirectory)
2001+
return isDirectory.boolValue
2002+
#endif
19952003
}
19962004
#endif // !NO_FILESYSTEM
19972005

0 commit comments

Comments
 (0)