-
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
Wrap more filesystem calls with fileSystemRepresentation() #1994
Conversation
@swift-ci test |
cc @compnerd |
Foundation/FileManager.swift
Outdated
@@ -1450,7 +1450,7 @@ open class FileManager : NSObject { | |||
#if os(Windows) | |||
NSUnimplemented() | |||
#else | |||
if rmdir(path) == 0 { | |||
if _fileSystemRepresentation(withPath: path, { rmdir($0) }) == 0 { |
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.
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 { |
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.
Again, I think its better to wrap this at the public API side where the call to _openFileDescriptorURL
is made.
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.
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:)
@swift-ci test |
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.
Thanks for doing this! LGTM
@swift-ci test and merge |
No description provided.