You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Sources/SwiftExtensions/URLExtensions.swift
+14-8Lines changed: 14 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -12,6 +12,10 @@
12
12
13
13
packageimport Foundation
14
14
15
+
#if os(Windows)
16
+
import WinSDK
17
+
#endif
18
+
15
19
enumFilePathError:Error,CustomStringConvertible{
16
20
case noFileSystemRepresentation(URL)
17
21
case noFileURL(URL)
@@ -82,15 +86,17 @@ extension URL {
82
86
}
83
87
}
84
88
89
+
/// Assuming this URL is a file URL, checks if it looks like a root path. This is a string check, ie. the return
90
+
/// value for a path of `"/foo/.."` would be `false`. An error will be thrown is this is a non-file URL.
85
91
packagevarisRoot:Bool{
86
-
#if os(Windows)
87
-
// FIXME: We should call into Windows' native check to check if this path is a root once https://github.com/swiftlang/swift-foundation/issues/976 is fixed.
88
-
returnself.pathComponents.count <=1
89
-
#else
90
-
// On Linux, we may end up with an string for the path due to https://github.com/swiftlang/swift-foundation/issues/980
91
-
// TODO: Remove the check for "" once https://github.com/swiftlang/swift-foundation/issues/980 is fixed.
0 commit comments