Skip to content

Instantly share code, notes, and snippets.

@laevandus

laevandus/FileReader.swift Secret

Created Jan 31, 2021
Embed
What would you like to do?
func read(byteRange: CountableRange<Int>, queue: DispatchQueue = .main, completionHandler: @escaping (DispatchData?) -> Void) {
if let channel = channel {
channel.read(offset: off_t(byteRange.startIndex), length: byteRange.count, queue: queue, ioHandler: { done, data, error in
print(done, data?.count ?? -1, error)
completionHandler(data)
})
}
else {
print("Channel is closed")
completionHandler(nil)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment