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
Now that swiftlang/swift-foundation#976 and swiftlang/swift-foundation#980 are fixed we can clean this code up a bit by removing the empty path check on Linux and by using the native `PathCchIsRoot` on Windows.
Existing code is retained for toolchains <6.1
Copy file name to clipboardexpand all lines: Sources/SwiftFormat/Utilities/URL+isRoot.swift
+25-3
Original file line number
Diff line number
Diff line change
@@ -12,21 +12,43 @@
12
12
13
13
import Foundation
14
14
15
+
#if os(Windows)
16
+
import WinSDK
17
+
#endif
18
+
15
19
extensionURL{
20
+
/// Returns a `Bool` to indicate if the given `URL` leads to the root of a filesystem.
21
+
/// A non-filesystem type `URL` will always return false.
16
22
@_spi(Testing)publicvarisRoot:Bool{
23
+
guard isFileURL else{returnfalse}
24
+
25
+
#if os(macOS)
26
+
returnself.path ==NSOpenStepRootDirectory()
27
+
#endif
28
+
29
+
#if compiler(>=6.1)
17
30
#if os(Windows)
18
-
// 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.
0 commit comments