فهرست منبع

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

Damian Kołakowski 10 سال پیش
والد
کامیت
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 {
     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())
             throw FileError.OpenFailed(descriptionOfLastError())
         }
         }
         return File(file)
         return File(file)