-
Notifications
You must be signed in to change notification settings - Fork 190
[Windows] Standardize slashes before path processing #731
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -282,10 +282,16 @@ final class FileManagerTests : XCTestCase { | |
try $0.createDirectory(atPath: "create_dir_test2/nested2", withIntermediateDirectories: true) | ||
XCTAssertEqual(try $0.contentsOfDirectory(atPath: "create_dir_test2").sorted(), ["nested", "nested2"]) | ||
XCTAssertNoThrow(try $0.createDirectory(atPath: "create_dir_test2/nested2", withIntermediateDirectories: true)) | ||
|
||
#if os(Windows) | ||
try $0.createDirectory(atPath: "create_dir_test3\\nested", withIntermediateDirectories: true) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is an example of a previous API that used to fail without this change. Previously, this API called |
||
XCTAssertEqual(try $0.contentsOfDirectory(atPath: "create_dir_test3"), ["nested"]) | ||
#endif | ||
|
||
XCTAssertThrowsError(try $0.createDirectory(atPath: "create_dir_test", withIntermediateDirectories: false)) { | ||
XCTAssertEqual(($0 as? CocoaError)?.code, .fileWriteFileExists) | ||
} | ||
XCTAssertThrowsError(try $0.createDirectory(atPath: "create_dir_test3/nested", withIntermediateDirectories: false)) { | ||
XCTAssertThrowsError(try $0.createDirectory(atPath: "create_dir_test4/nested", withIntermediateDirectories: false)) { | ||
XCTAssertEqual(($0 as? CocoaError)?.code, .fileNoSuchFile) | ||
} | ||
XCTAssertThrowsError(try $0.createDirectory(atPath: "preexisting_file", withIntermediateDirectories: false)) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where do we expect an arc separator after the extension separator? That is, the extension should be on the final arc, and so there would be no slashes right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't expect it to occur, but this is to ensure that we validate that it doesn't. I can't come up with any scenarios where we would currently end up in this situation, but
invalidExtensionScalars
contains a/
and so to ensure that POSIX and Windows behaviors are consistent, I added this standardization here so that if we do somehow end up with a\
in the path extension that we mark it as invalid on Windows