Skip to content

Commit b2aec24

Browse files
committed
Wrap more filesystem calls with fileSystemRepresentation()
1 parent a132f6e commit b2aec24

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

Foundation/FileHandle.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -752,8 +752,10 @@ extension FileHandle {
752752
}
753753

754754
internal static func _openFileDescriptorForURL(_ url : URL, flags: Int32, reading: Bool) throws -> Int32 {
755-
let path = url.path
756-
let fd = _CFOpenFile(path, flags)
755+
let fd = url.withUnsafeFileSystemRepresentation( { (fsRep) -> Int32 in
756+
guard let fsRep = fsRep else { return -1 }
757+
return _CFOpenFile(fsRep, flags)
758+
})
757759
if fd < 0 {
758760
throw _NSErrorWithErrno(errno, reading: reading, url: url)
759761
}

Foundation/FileManager.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1450,7 +1450,7 @@ open class FileManager : NSObject {
14501450
#if os(Windows)
14511451
NSUnimplemented()
14521452
#else
1453-
if rmdir(path) == 0 {
1453+
if _fileSystemRepresentation(withPath: path, { rmdir($0) }) == 0 {
14541454
return
14551455
} else if errno == ENOTEMPTY {
14561456

0 commit comments

Comments
 (0)