interplane.Get Omega
Read in your language

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

branch main Branches Tags History

omega-mv / seed / host / tests / truncate.om

33 lines · 517 bytes Raw Blame History
1note truncate: path form of ftrunc; st_size at byte 48 becomes 4, a missing path returns negative.
2text p "tr.tmp"
3text body "abcdefgh"
4text miss "no.such.file"
5fn main to int
6fd = int fopen p 0 len p 578 420
7if lt fd 0
8ret 1
9end
10w = write fd body 0 len body
11r = fclose fd
12r = truncate p 0 len p 4
13if ne r 0
14ret 2
15end
16st = new uchar 128 0
17r = stat p 0 len p st 0 128
18if ne r 0
19ret 3
20end
21if ne get st 48 4
22ret 4
23end
24r = truncate miss 0 len miss 4
25if ge r 0
26ret 5
27end
28r = unlink p 0 len p
29if ne r 0
30ret 6
31end
32ret 0
33end