Skip to content
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

Wrap more filesystem calls with fileSystemRepresentation() #1994

Merged
merged 1 commit into from
Mar 27, 2019

Conversation

spevans
Copy link
Contributor

@spevans spevans commented Mar 12, 2019

No description provided.

@spevans
Copy link
Contributor Author

spevans commented Mar 12, 2019

@swift-ci test

@spevans
Copy link
Contributor Author

spevans commented Mar 12, 2019

cc @compnerd

@@ -1450,7 +1450,7 @@ open class FileManager : NSObject {
#if os(Windows)
NSUnimplemented()
#else
if rmdir(path) == 0 {
if _fileSystemRepresentation(withPath: path, { rmdir($0) }) == 0 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that it would be better to wrap the path conversion at the _removeItem call site.

@@ -752,8 +752,10 @@ extension FileHandle {
}

internal static func _openFileDescriptorForURL(_ url : URL, flags: Int32, reading: Bool) throws -> Int32 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, I think its better to wrap this at the public API side where the call to _openFileDescriptorURL is made.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The advantage of doing it here is you dont need to fix up every caller or any new callers.

Also the type for the file system representaion is not a URL or String so it would change the method signature.

- FileManager._removeItem() and FileHandle._openFileDescriptorForURL()
  now wrap the system calls with _fileSystemRepresentation(withPath:)
@spevans
Copy link
Contributor Author

spevans commented Mar 13, 2019

@swift-ci test

2 similar comments
@spevans
Copy link
Contributor Author

spevans commented Mar 13, 2019

@swift-ci test

@spevans
Copy link
Contributor Author

spevans commented Mar 14, 2019

@swift-ci test

Copy link
Member

@compnerd compnerd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for doing this! LGTM

@spevans
Copy link
Contributor Author

spevans commented Mar 27, 2019

@swift-ci test and merge

@swift-ci swift-ci merged commit 98c3925 into swiftlang:master Mar 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants