mirror of
https://github.com/GayPizzaSpecifications/darwin-apk.git
synced 2025-08-03 21:41:31 +00:00
zlib-based homecooked gzip reader for significantly faster decompression times
This commit is contained in:
@ -4,6 +4,8 @@
|
||||
*/
|
||||
|
||||
import Foundation
|
||||
import Darwin
|
||||
import System
|
||||
|
||||
public struct FileInputStream: InputStream {
|
||||
private var _hnd: FileHandle
|
||||
@ -72,4 +74,12 @@ public struct FileInputStream: InputStream {
|
||||
throw .fileHandleError(error)
|
||||
}
|
||||
}
|
||||
|
||||
public mutating func read(_ buffer: UnsafeMutablePointer<UInt8>, maxLength len: Int) throws(StreamError) -> Int {
|
||||
let res = unistd.read(self._hnd.fileDescriptor, buffer, len)
|
||||
if res < 0 {
|
||||
throw .fileHandleError(Errno(rawValue: errno))
|
||||
}
|
||||
return res
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user