interplane.Get Omega
Read in your language

omega-harness

Agent skills for operating, encoding and communicating in Omega (.om) and the AIEN repositories

Brought by drakestapleton

branch main Branches Tags History

omega-harness / examples / pwrite_text.om

29 lines · 828 bytes Raw Blame History
1note pwrite_text: pwrite only reads its array, so a text is a valid source (omega-mv #904, e2662fff).
2note pread writes its array, so its destination must be writable: a global here (err20_pread_text.om
3note is the text case). Up to omc 2c824805 (omega-mv e5b32567) the check sat on the wrong word and
4note this program was error 20 at the pwrite line. Run in an empty scratch directory; Linux AArch64
5note O_RDWR|O_CREAT|O_EXCL = 194, mode 0600 = 384.
6text fname "f.bin"
7text body "pwrite\n"
8global rb uchar 16
9fn main to int
10fd = fopen fname 0 len fname 194 384
11if lt fd 0
12exit 90
13end
14w = pwrite int fd body 0 len body 0
15if ne w long len body
16exit 91
17end
18r = pread int fd rb 0 len body 0
19if ne r long len body
20exit 92
21end
22k = write 1 rb 0 ulong r
23c = fclose int fd
24u = unlink fname 0 len fname
25if ne u 0
26exit 93
27end
28ret 0
29end