-
-
Save aav/f0c1bf47793a2bc2e901228e1078911f 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
fun box readFile(auth: AmbientAuth, fname: String): (Array[U8] | FileErrNo) => | |
let caps = recover val FileCaps.>set(FileRead).>set(FileStat) end | |
try | |
let path = FilePath(auth, fname, caps) | |
match OpenFile(path) | |
| let file: File => | |
let result = file.read(1024) | |
file.dispose() | |
result | |
| let err: FileErrNo => err | |
else | |
FileError // will never happen | |
end | |
else | |
FilePermissionDenied // also unreachable, since FilePath(AmbientAuth, ...) will never raise error | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment