             buffer2.deallocate()
         }
 
-        var bytesLeft = Int(size)
+        var bytesLeft = size
         while bytesLeft > 0 {
-            let bytesToRead = min(bufSize, bytesLeft)
+            let bytesToRead = Int(min(Int64(bufSize), bytesLeft))
             guard read(fd1, buffer1, bytesToRead) == bytesToRead else {
                 return false
             }

        let buffer = UnsafeMutablePointer<UInt8>.allocate(capacity: Int(fileInfo.st_blksize))
        defer { buffer.deallocate() }

        var bytesRemaining = Int(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)
            if bytesRead == 0 {
                // Early EOF
                return
            }
            try _writeTo(fd: dstfd, fromBuffer: buffer, length: bytesRead, filename: dstPath)
            bytesRemaining -= bytesRead
        }
    }


    /* 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
