Browse Source

Build fixes for iOS and Linux targets

Peter Zignego 9 years ago
parent
commit
13836f629d
1 changed files with 8 additions and 3 deletions
  1. 8 3
      Sources/Swifter/Socket+File.swift

+ 8 - 3
Sources/Swifter/Socket+File.swift

@@ -16,8 +16,8 @@
     
     struct sf_hdtr { }
     
-    private func sendfileImpl(source: Int32, _ target: Int32, _: off_t, _: UnsafeMutablePointer<off_t>, _: UnsafeMutablePointer<sf_hdtr>, _: Int32) -> Int32 {
-        var buffer = [UInt8](count: 1024, repeatedValue: 0)
+    private func sendfileImpl(source: Int32, _ target: Int32, _: off_t, _: UnsafeMutablePointer<off_t>, _: UnsafeMutablePointer<sf_hdtr>?, _: Int32) -> Int32 {
+        var buffer = [UInt8](repeating: 0, count: 1024)
         while true {
             let readResult = read(source, &buffer, buffer.count)
             guard readResult > 0 else {
@@ -40,14 +40,19 @@
     
 #endif
 
+#if os(iOS) || os (Linux)
+
 extension Socket {
     
     public func writeFile(file: String.File) throws -> Void {
         var offset: off_t = 0
-        let result = sendfileImpl(fileno(file.pointer), self.socketFileDescriptor, 0, &offset, nil, 0)
+        let result = sendfileImpl(source: fileno(file.pointer), self.socketFileDescriptor, 0, &offset, nil, 0)
         if result == -1 {
             throw SocketError.writeFailed("sendfile: " + Process.lastErrno)
         }
     }
     
 }
+
+#endif
+