Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Sources/System/FilePath/FilePathWindows.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 23 additions & 1 deletion Tests/SystemTests/FilePathTests/FilePathSyntaxTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ final class FilePathSyntaxTest: XCTestCase {
),
]

let windowsPaths: Array<SyntaxTestCase> = [
var windowsPaths: Array<SyntaxTestCase> = [
.windows(#""#, absolute: false, components: []),

.windows(
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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()
}
Expand Down