diff --git a/Sources/TSCBasic/Path.swift b/Sources/TSCBasic/Path.swift index 3ceb2252..208f9819 100644 --- a/Sources/TSCBasic/Path.swift +++ b/Sources/TSCBasic/Path.swift @@ -461,7 +461,21 @@ private struct WindowsPath: Path, Sendable { let fsr: UnsafePointer = self.string.fileSystemRepresentation defer { fsr.deallocate() } - let path: String = String(cString: fsr) + var path: String = String(cString: fsr) + // PathCchRemoveFileSpec removes trailing '\' for a + // path like 'c:\root\path\', which doesn't give us the parent + // directory name. Thus, drop the trailing '\' before calling + // PathCchRemoveFileSpec. + var substring = path[path.startIndex..