diff --git a/Sources/System/FilePath/FilePathWindows.swift b/Sources/System/FilePath/FilePathWindows.swift index d8927959..fa079b1b 100644 --- a/Sources/System/FilePath/FilePathWindows.swift +++ b/Sources/System/FilePath/FilePathWindows.swift @@ -85,10 +85,10 @@ struct _Lexer { slice._eat(.backslash) != nil } - // Try to consume a drive letter and subsequent `:`. + // Try to consume a drive designator and subsequent `:`. mutating func eatDrive() -> SystemChar? { let copy = slice - if let d = slice._eat(if: { $0.isLetter }), slice._eat(.colon) != nil { + if let d = slice._eat(if: { !isSeparator($0) && $0 != .colon }), slice._eat(.colon) != nil { return d } // Restore slice diff --git a/Tests/SystemTests/FilePathTests/FilePathSyntaxTest.swift b/Tests/SystemTests/FilePathTests/FilePathSyntaxTest.swift index 0fdfbc27..ebb04f58 100644 --- a/Tests/SystemTests/FilePathTests/FilePathSyntaxTest.swift +++ b/Tests/SystemTests/FilePathTests/FilePathSyntaxTest.swift @@ -595,7 +595,7 @@ final class FilePathSyntaxTest: XCTestCase { ), ] - let windowsPaths: Array = [ + var windowsPaths: Array = [ .windows(#""#, absolute: false, components: []), .windows( @@ -628,6 +628,15 @@ final class FilePathSyntaxTest: XCTestCase { components: ["foo", "bar.exe"] ), + .windows( + #"+:\foo"#, + absolute: true, + root: #"+:\"#, relative: #"foo"#, + dirname: #"+:\"#, basename: "foo", + stem: "foo", + components: ["foo"] + ), + .windows( #"C:foo\bar"#, absolute: false, @@ -769,6 +778,19 @@ final class FilePathSyntaxTest: XCTestCase { // TODO: partially-formed Windows roots, we should fully form them... ] +#if os(Windows) + windowsPaths.append( + .windows( + #"€:\foo"#, + absolute: true, + root: #"€:\"#, relative: #"foo"#, + dirname: #"€:\"#, basename: "foo", + stem: "foo", + components: ["foo"] + ) + ) +#endif + for test in unixPaths { test.runAllTests() }