ref: 762a6325011ed30aa737ed4be0c22b7430f34366
parent: 65a5ecf2c2105ae46c7862aeb87339287bf08b46
author: Ori Bernstein <ori@eigenstate.org>
date: Thu Jan 7 16:48:29 EST 2016
add missing directory iterator file.
--- /dev/null
+++ b/lib/std/diriter.myr
@@ -1,0 +1,32 @@
+use "alloc.use"
+use "dir.use"
+use "option.use"
+
+pkg std =
+ type diriter = dir#
+ impl iterable diriter -> byte[:]
+
+ const byentry : (d : dir# -> diriter)
+;;
+
+const byentry = {d
+ -> d castto(diriter)
+}
+
+impl iterable diriter -> byte[:] =
+ __iternext__ = {itp, valp
+ match dirread(itp# castto(dir#))
+ | `Some ent:
+ valp# = ent
+ -> true
+ | `None:
+ -> false
+ ;;
+ }
+
+ __iterfin__ = {itp, valp
+ std.slfree(valp#)
+ }
+;;
+
+