Fs.open¶
open :: fn (filepath: string, mode: ...OpenMode) (_0: File, _1: Error) #inline
Open an file specified by filepath. Function return file handle and OK status when file was openned, otherwise return invalid handle and proper error. File must be closed by Fs.close call.
File open mode is optional, any combination of OpenMode can be used. When Create mode is specified, new file is created on filepath only if it does not exist, otherwise already existing file is used. Read mode is used as default when nither Read, Write or Append is specified.
Example¶
#import "std/fs"
main :: fn () s32 {
file, err :: Fs.open(#file);
defer Fs.close(file);
if !is_ok(err) {
print_err("%", err);
return 1;
}
return 0;
}
Declared in: fs.bl