Skip to content

Commit e6a7fbe

Browse files
committed
TSCBasic: more special case handling for Windows paths
There is no one canonical root on Windows. Windows contains a forest of paths, rooted at a drive (`[A-Z]:\\`), a NT Path `\\??\`, or a UNC path, `\\UNC\` or `\\`. Avoid the check against a canonical root on Windows. This is required for `swift package init` to function.
1 parent 6eb4fd1 commit e6a7fbe

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

Sources/TSCBasic/Path.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,11 @@ public struct AbsolutePath: Hashable {
133133

134134
/// True if the path is the root directory.
135135
public var isRoot: Bool {
136+
#if os(Windows)
137+
return _impl.string.withCString(encodedAs: UTF16.self, PathIsRootW)
138+
#else
136139
return _impl == PathImpl.root
140+
#endif
137141
}
138142

139143
/// Returns the absolute path with the relative path applied.

0 commit comments

Comments
 (0)