소스 검색

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 {
-        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)