louise
The Louise language: compiler, runtime, std, tooling
Clone avec HTTPS, un jeton personnel en mot de passe, ou avec SSH, une clé ajoutée dans vos paramètres.
Dernier runRéussi#125 · main · 16 min 13 s
0Étoiles
0Forks
40Issues
| 1 | // Whole-file IO (std/file, ADR 0049): write, then read back; a missing |
| 2 | // file is an `Error`, not a panic. The file is never deleted (both |
| 3 | // backends may run this program at the same time), in the temp dir. |
| 4 | |
| 5 | import std/file |
| 6 | import std/io |
| 7 | import std/option |
| 8 | import std/os |
| 9 | |
| 10 | pub fn main :: -> () / <io> |
| 11 | { |
| 12 | let path = |
| 13 | option.unwrap_or (os.env "TMPDIR") "/tmp" <> "/louise_run_file_test.txt" |
| 14 | // Never created by this program: `exists` is `False` even on a rerun. |
| 15 | let missing = path <> ".nope" |
| 16 | io.println (show (file.exists missing)) |
| 17 | io.println (show (file.write path "hello file")) |
| 18 | io.println (show (file.exists path)) |
| 19 | io.println (show (file.size path)) |
| 20 | io.println (show (file.read path)) |
| 21 | io.println (show (file.read missing)) |
| 22 | } |
| 23 | //> False |
| 24 | //> Ok(()) |
| 25 | //> True |
| 26 | //> Ok(10) |
| 27 | //> Ok(hello file) |
| 28 | //> Error(No such file or directory (os error 2)) |