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 / si / mcp / data / examples / dirs.om
| 1 | note directories, links and renames; paths pairs are packed lists (u16 count, then u16 length + bytes) |
| 2 | text dir "sub" |
| 3 | text gone "tmp" |
| 4 | text fa "a" |
| 5 | text dot "." |
| 6 | global buf uchar 512 |
| 7 | fn ck yes bool to void |
| 8 | if not yes |
| 9 | exit 80 |
| 10 | end |
| 11 | end |
| 12 | fn main to int |
| 13 | ck eq makedir dir 0 len dir 448 0 |
| 14 | ck eq makedir gone 0 len gone 448 0 |
| 15 | ck eq rmdir gone 0 len gone 0 |
| 16 | ck eq chdir dir 0 len dir 0 |
| 17 | ck gt cwd buf 0 512 0 |
| 18 | fd = int fopen fa 0 len fa 577 384 |
| 19 | ck ge fd 0 |
| 20 | ck eq fclose fd 0 |
| 21 | p = new uchar 8 0 |
| 22 | put p 0 2 |
| 23 | put p 2 1 |
| 24 | put p 4 97 |
| 25 | put p 5 1 |
| 26 | put p 7 98 |
| 27 | ck eq link p 0 8 0 |
| 28 | put p 7 99 |
| 29 | ck eq symlnk p 0 8 0 |
| 30 | c = new uchar 1 99 |
| 31 | ck eq readlnk c 0 1 buf 0 64 1 |
| 32 | put p 4 98 |
| 33 | put p 7 100 |
| 34 | ck eq renames p 0 8 1 0 |
| 35 | ck eq chown fa 0 len fa int getuid int getgid 0 |
| 36 | ck ge add geteuid getegid 0 |
| 37 | d = int fopen dot 0 len dot 0 0 |
| 38 | ck ge d 0 |
| 39 | ck gt getdnts d buf 0 512 0 |
| 40 | ck eq fchdir d 0 |
| 41 | ret 0 |
| 42 | end |