// Whole-file IO (std/file, ADR 0049): write, then read back; a missing // file is an `Error`, not a panic. The file is never deleted (both // backends may run this program at the same time), in the temp dir. import std/file import std/io import std/option import std/os pub fn main :: -> () / { let path = option.unwrap_or (os.env "TMPDIR") "/tmp" <> "/louise_run_file_test.txt" // Never created by this program: `exists` is `False` even on a rerun. let missing = path <> ".nope" io.println (show (file.exists missing)) io.println (show (file.write path "hello file")) io.println (show (file.exists path)) io.println (show (file.size path)) io.println (show (file.read path)) io.println (show (file.read missing)) } //> False //> Ok(()) //> True //> Ok(10) //> Ok(hello file) //> Error(No such file or directory (os error 2))