summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--stream.c14
-rw-r--r--stream.h2
-rw-r--r--txr.111
3 files changed, 19 insertions, 8 deletions
diff --git a/stream.c b/stream.c
index 912ec0bb..c25a9739 100644
--- a/stream.c
+++ b/stream.c
@@ -3835,11 +3835,15 @@ static val sh(val command)
#error port me!
#endif
-val remove_path(val path)
+val remove_path(val path, val throw_on_error)
{
- if (w_remove(c_str(path)) < 0)
- uw_throwf(file_error_s, lit("trying to remove ~a: ~d/~s"),
- path, num(errno), string_utf8(strerror(errno)), nao);
+ if (w_remove(c_str(path)) < 0) {
+ if (throw_on_error)
+ uw_throwf(file_error_s, lit("trying to remove ~a: ~d/~s"),
+ path, num(errno), string_utf8(strerror(errno)), nao);
+ return nil;
+ }
+
return t;
}
@@ -3992,7 +3996,7 @@ void stream_init(void)
reg_fun(intern(lit("open-process"), user_package), func_n3o(open_process, 2));
reg_fun(intern(lit("sh"), user_package), func_n1(sh));
reg_fun(intern(lit("run"), user_package), func_n2o(run, 1));
- reg_fun(intern(lit("remove-path"), user_package), func_n1(remove_path));
+ reg_fun(intern(lit("remove-path"), user_package), func_n2o(remove_path, 1));
reg_fun(intern(lit("rename-path"), user_package), func_n2(rename_path));
reg_fun(intern(lit("open-files"), user_package), func_n2o(open_files, 1));
reg_fun(intern(lit("open-files*"), user_package), func_n2o(open_files_star, 1));
diff --git a/stream.h b/stream.h
index 192f7bbb..db054730 100644
--- a/stream.h
+++ b/stream.h
@@ -198,7 +198,7 @@ val make_catenated_stream(val stream_list);
val make_catenated_stream_v(struct args *streams);
val catenated_stream_p(val obj);
val catenated_stream_push(val new_stream, val cat_stream);
-val remove_path(val path);
+val remove_path(val path, val throw_on_error);
val rename_path(val from, val to);
val abs_path_p(val path);
diff --git a/txr.1 b/txr.1
index 89f8d115..b7fa864c 100644
--- a/txr.1
+++ b/txr.1
@@ -36407,7 +36407,7 @@ an exception will be thrown.
.coNP Function @ remove-path
.synb
-.mets (remove-path << path )
+.mets (remove-path < path <> [ throw-on-error-p ])
.syne
.desc
The
@@ -36421,7 +36421,14 @@ If successful, it returns
.codn t .
A failure to remove the object results in an exception of type
-.codn file-error .
+.codn file-error ,
+unless
+.meta throw-on-error-p
+is present, and its value is
+.codn nil .
+In that case, failure is indicated by a
+.code nil
+return value.
.coNP Function @ rename-path
.synb