Skip to content

Commit a77a2e2

Browse files
committed
Complete AbsolutePath.relative(to:)
1 parent 499d7bc commit a77a2e2

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

Sources/TSCBasic/Path.swift

+6-3
Original file line numberDiff line numberDiff line change
@@ -396,9 +396,12 @@ extension AbsolutePath {
396396
var relFilePath = FilePath()
397397
var filepath = filepath
398398
#if os(Windows)
399-
/// TODO: DOS relative path may change the root.
400-
if root != base.root {
401-
throw PathValidationError.differentRoot(pathString, base.pathString)
399+
if self.root != base.root {
400+
guard self.root.count == 3,
401+
self.root!.hasSuffix(":\\") else {
402+
throw PathValidationError.differentRoot(pathString, base.pathString)
403+
}
404+
relFilePath.root = .init(String(self.dropLast()))
402405
}
403406
#endif
404407
filepath.root = base.filepath.root

0 commit comments

Comments
 (0)