Skip to content

Instantly share code, notes, and snippets.

Last active Jan 31, 2021
What would you like to do?
func open() -> Bool {
guard channel == nil else { return true }
guard let path = (fileURL.path as NSString).utf8String else { return false }
channel = DispatchIO(type: .random, path: path, oflag: 0, mode: 0, queue: .main, cleanupHandler: { error in
print("Closed a channel with status: \(error)")
// Load the whole requested byte range at once
channel?.setLimit(lowWater: .max)
guard != nil else { return false }
print("Opened a channel at \(fileURL)")
return true
func close() {
channel = nil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment