Commit 27686195 authored by Drew's avatar Drew

Even more Linux support

parent d1c88034
Pipeline #971 passed with stage
......@@ -37,7 +37,7 @@ extension NSString {
// MARK: NSFileManager.copyItemAtPath
// https://github.com/apple/swift-corelibs-foundation/pull/248
// https://github.com/apple/swift-corelibs-foundation/pull/248
enum CopyError: ErrorType {
case CantOpenSourceFile(Int32)
case CantOpenDestFile(Int32)
......@@ -53,7 +53,13 @@ extension NSFileManager {
throw CopyError.CantOpenSourceFile(errno)
}
defer { precondition(close(fd_from) >= 0) }
let permission = (try! attributesOfItemAtPath(srcPath)[NSFilePosixPermissions] as! NSNumber).unsignedShortValue
let permission_ = (try! attributesOfItemAtPath(srcPath)[NSFilePosixPermissions] as! NSNumber)
#if os(OSX) || os(iOS)
let permission = permission_.unsignedShortValue
#elseif os(Linux)
let permission = permission_.unsignedIntValue
#endif
let fd_to = open(dstPath, O_WRONLY | O_CREAT | O_EXCL, permission)
if fd_to < 0 {
throw CopyError.CantOpenDestFile(errno)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment