summaryrefslogtreecommitdiff
path: root/lib/std/syswrap+posixy.myr
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2018-06-24 13:38:25 -0700
committerOri Bernstein <ori@eigenstate.org>2018-06-24 13:38:25 -0700
commit0f959a0c6f79986cc32d8456b503957476bdae83 (patch)
tree01e0abf2b8732ba50091107121494ca5a029846a /lib/std/syswrap+posixy.myr
parentfde9deac883c3f2ae6ffb7d05b4f5e404f5c2249 (diff)
downloadmc-0f959a0c6f79986cc32d8456b503957476bdae83.tar.gz
Add recursive file removal.
Also makes `std.remove` remove directories the same way it removes leaf files.
Diffstat (limited to 'lib/std/syswrap+posixy.myr')
-rw-r--r--lib/std/syswrap+posixy.myr8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/std/syswrap+posixy.myr b/lib/std/syswrap+posixy.myr
index d0c63c8..23b8e04 100644
--- a/lib/std/syswrap+posixy.myr
+++ b/lib/std/syswrap+posixy.myr
@@ -92,7 +92,13 @@ const dup2 = {ofd, nfd; -> check((sys.dup2((ofd : sys.fd), (nfd : sys.fd)) : fd)
/* path manipulation */
const mkdir = {path, mode; -> (sys.mkdir(path, mode) : errno)}
const chdir = {path; -> sys.chdir(path) == 0}
-const remove = {path; -> sys.unlink(path) == 0}
+const remove = {path;
+ if std.fisdir(path)
+ -> sys.rmdir(sys.cstring(path)) == 0
+ else
+ -> sys.unlink(path) == 0
+ ;;
+}
/* useful/portable bits of uname */
const getsysinfo = {si