-
-
Save laevandus/4f2122f4866251bad24df106abbbc565 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 self.channel != nil else { return false } | |
print("Opened a channel at \(fileURL)") | |
return true | |
} | |
func close() { | |
channel?.close() | |
channel = nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment