-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Recore FileManager on top of FoundationEssentials.FileManager #4957
Recore FileManager on top of FoundationEssentials.FileManager #4957
Conversation
@@ -1385,15 +1393,11 @@ class TestFileManager : XCTestCase { | |||
|
|||
XCTAssertThrowsError(try fm.attributesOfItem(atPath: "")) { | |||
let code = ($0 as? CocoaError)?.code | |||
XCTAssertEqual(code, .fileReadInvalidFileName) | |||
XCTAssertEqual(code, .fileReadNoSuchFile) |
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.
Do we simply throw a different error now, or is the former API somehow missing?
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 throw an error now. Previously the behavior for these empty paths differed between Darwin and non-Darwin. The swift-foundation implementation takes the behavior from Darwin and so this updates the test expectations accordingly. Previously, getting the file system representation of an empty string unconditionally threw .fileReadInvalidFileName
, but now we just create en empty cstring and provide it to the underlying system API and let it determine how to handle an empty path (which in most cases results in specifying that the file doesn't exist, unless you're working with a directory in which I believe some cases it can be considered the current directory)
XCTAssertNil(filemanger.homeDirectory(forUser: "someuser")) | ||
XCTAssertNil(filemanger.homeDirectory(forUser: "")) | ||
XCTAssertNotNil(filemanger.homeDirectory(forUser: "someuser")) | ||
XCTAssertNotNil(filemanger.homeDirectory(forUser: "")) |
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.
This is another change in behavior, correct?
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.
Yes, similar to the above this aligns non-Darwin behavior with Darwin behavior. Previously we returned nil
on non-Darwin for a non-existent user but now we always fallback to /var/empty
as a last resort if the user doesn't exist
This PR removes all of the functionality from
FileManager
that is already surfaced viaFoundationEssentials
. There are still some pieces (namely those that requireURLResourceValues
) that are not available inFoundationEssentials
yet, and those are left here in anextension
onFileManager
This change depends on swiftlang/swift-foundation#609, I'll update the dependency's commit hash once that PR has been approved and is merged