Bläddra i källkod

Merge pull request #143 from mbarnach/fix_short_name_issue

Fix issue #142
Damian Kołakowski 10 år sedan
förälder
incheckning
56961dbeb3
1 ändrade filer med 7 tillägg och 1 borttagningar
  1. 7 1
      Sources/File.swift

+ 7 - 1
Sources/File.swift

@@ -34,7 +34,13 @@ public class File {
     }
     
     public static func openFileForMode(path: String, _ mode: String) throws -> File {
-        let file = fopen(path.withCString({ $0 }), mode.withCString({ $0 }))
+        #if os(Linux)
+            let file = fopen(path.withCString({ $0 }), mode.withCString({ $0 }))
+        #else
+            let filename = UnsafePointer<Int8>((path as NSString).UTF8String)
+            let filemode = UnsafePointer<Int8>((mode as NSString).UTF8String)
+            let file = fopen(filename, filemode)
+        #endif
         guard file != nil else {
             throw FileError.OpenFailed(descriptionOfLastError())
         }