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