omega-mv
Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.
Brought by drakestapleton
omega-mv / seed / host / tests / stat.om
| 1 | note stat: path-based metadata without opening the file. st_size is at byte 48 of the ARM64 stat structure. |
| 2 | text p "stat.tmp" |
| 3 | text body "abcdefgh" |
| 4 | text miss "no.such.file" |
| 5 | fn main to int |
| 6 | fd = int fopen p 0 len p 577 420 |
| 7 | if lt fd 0 |
| 8 | ret 1 |
| 9 | end |
| 10 | w = write fd body 0 len body |
| 11 | if ne w long len body |
| 12 | ret 2 |
| 13 | end |
| 14 | r = fclose fd |
| 15 | if ne r 0 |
| 16 | ret 3 |
| 17 | end |
| 18 | buf = new uchar 128 0 |
| 19 | r = stat p 0 len p buf 0 128 |
| 20 | if ne r 0 |
| 21 | ret 4 |
| 22 | end |
| 23 | if ne get buf 48 8 |
| 24 | ret 5 |
| 25 | end |
| 26 | k = ulong 49 |
| 27 | while lt k 56 bound 8 |
| 28 | if ne get buf k 0 |
| 29 | ret 6 |
| 30 | end |
| 31 | k = add k 1 |
| 32 | end |
| 33 | r = stat miss 0 len miss buf 0 128 |
| 34 | if ge r 0 |
| 35 | ret 7 |
| 36 | end |
| 37 | r = unlink p 0 len p |
| 38 | if ne r 0 |
| 39 | ret 8 |
| 40 | end |
| 41 | ret 0 |
| 42 | end |