diff options
author | Ori Bernstein <ori@eigenstate.org> | 2015-08-26 12:20:58 -0700 |
---|---|---|
committer | Ori Bernstein <ori@eigenstate.org> | 2015-08-26 12:20:58 -0700 |
commit | 2bc852bda98762d3bc01548bf972e3f1b137fbfb (patch) | |
tree | 74831deed3c9057c5fe0cbb8790d220e855bc792 /lib/std/blat.myr | |
parent | 3de952510eb2a23350d24ed926f19c0cf72a12f2 (diff) | |
download | mc-2bc852bda98762d3bc01548bf972e3f1b137fbfb.tar.gz |
Move Myrddin libs to lib/ subdirectory.
Diffstat (limited to 'lib/std/blat.myr')
-rw-r--r-- | lib/std/blat.myr | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/lib/std/blat.myr b/lib/std/blat.myr new file mode 100644 index 0000000..90c0f94 --- /dev/null +++ b/lib/std/blat.myr @@ -0,0 +1,32 @@ +use "syswrap.use" + +pkg std = + const blat : (path : byte[:], buf : byte[:], perm : int64 -> bool) + const fblat : (f : fd, buf : byte[:] -> bool) +;; + +const blat = {path, buf, perm + var fd + + fd = openmode(path, Ocreat|Owronly, perm) + if fd < 0 + -> false + ;; + -> fblat(fd, buf) +} + + +const fblat = {fd, buf + var written, n + + n = 0 + while true + written = write(fd, buf[n:]) + if written <= 0 + goto done + ;; + n += written + ;; +:done + -> written == 0 && n == buf.len +} |