diff options
author | Ori Bernstein <ori@eigenstate.org> | 2016-11-24 17:44:22 -0800 |
---|---|---|
committer | Ori Bernstein <ori@eigenstate.org> | 2016-11-24 17:44:22 -0800 |
commit | 40c1498b2d4ef5a7a39dfad83812f03be0c6453e (patch) | |
tree | bfd63f1a0a50497bb90c6ade025345474796b89c /lib | |
parent | 204b05d910ebcaec8af1fe62e8bbd19f3f41932a (diff) | |
download | mc-40c1498b2d4ef5a7a39dfad83812f03be0c6453e.tar.gz |
Add homedir extraction.
This is not robust at all.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/fileutil/bld.sub | 2 | ||||
-rw-r--r-- | lib/fileutil/homedir.myr | 21 |
2 files changed, 23 insertions, 0 deletions
diff --git a/lib/fileutil/bld.sub b/lib/fileutil/bld.sub index 0b31cac..8971630 100644 --- a/lib/fileutil/bld.sub +++ b/lib/fileutil/bld.sub @@ -1,5 +1,7 @@ lib fileutil = walk.myr + homedir.myr + lib ../sys:sys lib ../std:std ;; diff --git a/lib/fileutil/homedir.myr b/lib/fileutil/homedir.myr new file mode 100644 index 0000000..a03ae18 --- /dev/null +++ b/lib/fileutil/homedir.myr @@ -0,0 +1,21 @@ +use std + +pkg fileutil = + const homedir : (-> byte[:]) +;; + +const homedir = { + match std.getenv("HOME") + | `std.Some h: -> h + | `std.None: /* nothing */ + ;; + + /* 9front uses $home */ + match std.getenv("home") + | `std.Some h: -> h + | `std.None: /* nothing */ + ;; + + /* really, we should read from /etc/passwd or ldap/nss */ + -> "" +} |