Explorar o código

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

Damian Kołakowski %!s(int64=10) %!d(string=hai) anos
pai
achega
8251c11ae2
Modificáronse 1 ficheiros con 1 adicións e 1 borrados
  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)