summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2017-09-10 19:11:29 -0700
committerOri Bernstein <ori@eigenstate.org>2017-09-10 19:12:10 -0700
commit38941f5eadd5e3606776d3c0004b997fb53ba399 (patch)
tree617630fe1f94bde8fe34aaf8cd7d2f49207c1430 /lib
parent73c618bf4af5f96b4d1c0790662b6bd9e0a1f33e (diff)
downloadmc-38941f5eadd5e3606776d3c0004b997fb53ba399.tar.gz
Add `tmpdir` function.
Diffstat (limited to 'lib')
-rw-r--r--lib/fileutil/bld.sub1
-rw-r--r--lib/fileutil/tmpdir.myr12
2 files changed, 13 insertions, 0 deletions
diff --git a/lib/fileutil/bld.sub b/lib/fileutil/bld.sub
index 8971630..f308f6a 100644
--- a/lib/fileutil/bld.sub
+++ b/lib/fileutil/bld.sub
@@ -1,6 +1,7 @@
lib fileutil =
walk.myr
homedir.myr
+ tmpdir.myr
lib ../sys:sys
lib ../std:std
diff --git a/lib/fileutil/tmpdir.myr b/lib/fileutil/tmpdir.myr
new file mode 100644
index 0000000..1138588
--- /dev/null
+++ b/lib/fileutil/tmpdir.myr
@@ -0,0 +1,12 @@
+use std
+
+pkg fileutil =
+ const homedir : (-> byte[:])
+;;
+
+const homedir = {
+ match std.getenv("TMPDIR")
+ | `std.Some h: -> d
+ | `std.None: -> "/tmp"
+ ;;
+}