         let buffer = UnsafeMutablePointer<UInt8>.allocate(capacity: Int(fileInfo.st_blksize))
         defer { buffer.deallocate() }
 
-        var bytesRemaining = Int(fileInfo.st_size)
+        // Casted to Int64 because fileInfo.st_size is 64 bits long even on 32 bit platforms
+        var bytesRemaining = Int64(fileInfo.st_size)
         while bytesRemaining > 0 {
-            let bytesToRead = min(bytesRemaining, Int(fileInfo.st_blksize))
-            let bytesRead = try _readFrom(fd: srcfd, toBuffer: buffer, length: bytesToRead, filename: srcPath)
+            let bytesToRead = min(bytesRemaining, Int64(fileInfo.st_blksize))
+            let bytesRead = try _readFrom(fd: srcfd, toBuffer: buffer, length: Int(bytesToRead), filename: srcPath)
             if bytesRead == 0 {
                 // Early EOF
                 return
             }
             try _writeTo(fd: dstfd, fromBuffer: buffer, length: bytesRead, filename: dstPath)
-            bytesRemaining -= bytesRead
+            bytesRemaining -= Int64(bytesRead)
         }
     }
 

            guard memcmp(buffer1, buffer2, bytesToRead) == 0 else {
                return false
            }
            bytesLeft -= bytesToRead
        }
        return true
    }

    /* Process working directory management. Despite the fact that these are instance methods on FileManager, these methods report and change (respectively) the working directory for the entire process. Developers are cautioned that doing so is fraught with peril.
     */
    open var currentDirectoryPath: String {
        let length = Int(PATH_MAX) + 1
        var buf = [Int8](repeating: 0, count: length)
        getcwd(&buf, length)
        return string(withFileSystemRepresentation: buf, length: Int(strlen(buf)))
    }
    
    @discardableResult
