Skip to content

Commit

Permalink
Complete AbsolutePath.relative(to:)
Browse files Browse the repository at this point in the history
  • Loading branch information
stevapple committed Mar 8, 2022
1 parent 6b1b327 commit 82d7f53
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions Sources/TSCBasic/Path.swift
Original file line number Diff line number Diff line change
Expand Up @@ -396,9 +396,12 @@ extension AbsolutePath {
var relFilePath = FilePath()
var filepath = filepath
#if os(Windows)
/// TODO: DOS relative path may change the root.
if root != base.root {
throw PathValidationError.differentRoot(pathString, base.pathString)
if self.root != base.root {
guard self.root?.count == 3,
self.root!.hasSuffix(":\\") else {
throw PathValidationError.differentRoot(pathString, base.pathString)
}
relFilePath.root = .init(String(self.root!.dropLast()))
}
#endif
filepath.root = base.filepath.root
Expand Down

0 comments on commit 82d7f53

Please sign in to comment.