summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2016-05-02 21:21:49 -0700
committerOri Bernstein <ori@eigenstate.org>2016-05-03 21:56:20 -0700
commita986d1d8ae4c6f75384b62347c733a226edcafba (patch)
treea815f069e2772d207f3c05b84ac656fdb0a79eef /lib
parentdff9fe20898ba0d2165dd55b2e47486acbef45c1 (diff)
downloadmc-a986d1d8ae4c6f75384b62347c733a226edcafba.tar.gz
Regenerate bootstrap
Diffstat (limited to 'lib')
-rw-r--r--lib/std/bld.sub1
-rw-r--r--lib/std/readall.myr26
2 files changed, 27 insertions, 0 deletions
diff --git a/lib/std/bld.sub b/lib/std/bld.sub
index a90f949..932fb40 100644
--- a/lib/std/bld.sub
+++ b/lib/std/bld.sub
@@ -43,6 +43,7 @@ lib std {inc=.} =
pathjoin.myr
putint.myr
rand.myr
+ readall.myr
result.myr
search.myr
slcp.myr
diff --git a/lib/std/readall.myr b/lib/std/readall.myr
new file mode 100644
index 0000000..33fbc0c
--- /dev/null
+++ b/lib/std/readall.myr
@@ -0,0 +1,26 @@
+use "errno"
+use "result"
+use "option"
+use "syswrap"
+use "types"
+
+pkg std =
+ const readall : (fd : fd, dst : byte[:] -> result(size, errno))
+;;
+
+const readall = {fd, dst
+ var sz
+
+ sz = dst.len
+ while dst.len != 0
+ match std.read(fd, dst)
+ | `Ok 0:
+ break
+ | `Ok n:
+ dst = dst[n:]
+ | `Fail e:
+ -> `Fail e
+ ;;
+ ;;
+ -> `Ok sz - dst.len
+}