Просмотр исходного кода

Fixed the wrong usage of withCString reported at https://github.com/httpswift/swifter/issues/142.

Damian Kołakowski 10 лет назад
Родитель
Сommit
8251c11ae2
1 измененных файлов с 1 добавлено и 1 удалено
  1. 1 1
      Sources/Swifter/File.swift

+ 1 - 1
Sources/Swifter/File.swift

@@ -35,7 +35,7 @@ public class File {
     }
     
     public static func openFileForMode(_ path: String, _ mode: String) throws -> File {
-        guard let file = fopen(path.withCString({ $0 }), mode.withCString({ $0 })) else {
+        guard let file = path.withCString({ pathPointer in mode.withCString({ fopen(pathPointer, $0) }) }) else {
             throw FileError.OpenFailed(descriptionOfLastError())
         }
         return File(file)