Procházet zdrojové kódy

Merge pull request #143 from mbarnach/fix_short_name_issue

Fix issue #142
Damian Kołakowski před 10 roky
rodič
revize
56961dbeb3
1 změnil soubory, kde provedl 7 přidání a 1 odebrání
  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())
         }