diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2020-01-28 05:58:05 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2020-01-28 05:58:05 -0800 |
commit | 9c5fbe2bfbd85f5fd14973d4fe83cde34f00a1a9 (patch) | |
tree | 643b98fc461e77126794e8b2a28982412a4eaf98 /sysif.c | |
parent | 354824aeceb339dbd854c90f397d9a6c8a27505b (diff) | |
download | txr-9c5fbe2bfbd85f5fd14973d4fe83cde34f00a1a9.tar.gz txr-9c5fbe2bfbd85f5fd14973d4fe83cde34f00a1a9.tar.bz2 txr-9c5fbe2bfbd85f5fd14973d4fe83cde34f00a1a9.zip |
New function: rmdir.
* sysif.c (rmdir_wrap): New static function.
(sysif_init): rmdir intrinsic registered.
* txr.1: Documented.
Diffstat (limited to 'sysif.c')
-rw-r--r-- | sysif.c | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -437,6 +437,21 @@ val getcwd_wrap(void) } } } + +static val rmdir_wrap(val path) +{ + char *u8path = utf8_dup_to(c_str(path)); + int err = rmdir(u8path); + free(u8path); + + if (err < 0) { + int eno = errno; + uw_throwf(errno_to_file_error(eno), lit("rmdir ~a: ~d/~s"), + path, num(eno), string_utf8(strerror(eno)), nao); + } + + return t; +} #endif #if HAVE_MAKEDEV @@ -2116,6 +2131,7 @@ void sysif_init(void) #if HAVE_UNISTD_H reg_fun(intern(lit("chdir"), user_package), func_n1(chdir_wrap)); reg_fun(intern(lit("pwd"), user_package), func_n0(getcwd_wrap)); + reg_fun(intern(lit("rmdir"), user_package), func_n1(rmdir_wrap)); #endif #if HAVE_MAKEDEV |