summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--stream.c16
-rw-r--r--txr.117
2 files changed, 26 insertions, 7 deletions
diff --git a/stream.c b/stream.c
index 3dd3ed30..3dd76a4d 100644
--- a/stream.c
+++ b/stream.c
@@ -4503,23 +4503,31 @@ val rename_path(val from, val to)
return t;
}
-static val open_files(val file_list, val substitute_stream)
+static val open_files(val file_list, val substitute_stream, val mode)
{
substitute_stream = default_null_arg(substitute_stream);
+ mode = default_null_arg(mode);
if (nilp(file_list) && substitute_stream) {
return substitute_stream;
+ } else if (mode) {
+ return make_catenated_stream(mapcar(curry_12_1(func_n2o(open_file, 1),
+ mode), file_list));
} else {
return make_catenated_stream(mapcar(func_n2o(open_file, 1), file_list));
}
}
-static val open_files_star(val file_list, val substitute_stream)
+static val open_files_star(val file_list, val substitute_stream, val mode)
{
substitute_stream = default_null_arg(substitute_stream);
+ mode = default_null_arg(mode);
if (nilp(file_list) && substitute_stream) {
return substitute_stream;
+ } else if (mode) {
+ return make_catenated_stream(lazy_mapcar(curry_12_1(func_n2o(open_file, 1),
+ mode), file_list));
} else {
return make_catenated_stream(lazy_mapcar(func_n2o(open_file, 1), file_list));
}
@@ -4875,8 +4883,8 @@ void stream_init(void)
reg_fun(intern(lit("run"), user_package), func_n2o(run, 1));
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));
+ reg_fun(intern(lit("open-files"), user_package), func_n3o(open_files, 1));
+ reg_fun(intern(lit("open-files*"), user_package), func_n3o(open_files_star, 1));
reg_fun(intern(lit("abs-path-p"), user_package), func_n1(abs_path_p));
reg_fun(intern(lit("pure-rel-path-p"), user_package), func_n1(pure_rel_path_p));
reg_fun(intern(lit("base-name"), user_package), func_n2o(base_name, 1));
diff --git a/txr.1 b/txr.1
index dc0fad41..d58ff298 100644
--- a/txr.1
+++ b/txr.1
@@ -50010,8 +50010,8 @@ of
.coNP Functions @ open-files and @ open-files*
.synb
-.mets (open-files < path-list <> [ alternative-stream ])
-.mets (open-files* < path-list <> [ alternative-stream ])
+.mets (open-files < path-list >> [ alternative-stream <> [ mode-string ]])
+.mets (open-files* < path-list >> [ alternative-stream <> [ mode-string ]])
.syne
.desc
The
@@ -50019,8 +50019,19 @@ The
and
.code open-files*
functions create a list of streams by invoking
-the open-file function on each element of
+the
+.code open-file
+function on each element of
.metn path-list .
+By default, the mode string
+.str r
+is passed to
+.codn open-file ;
+if the
+.meta mode-string
+argument specified, it overrides this default. In that situation,
+the specified mode should permit reading.
+
These streams are turned
into a catenated stream as if applied as arguments to
.codn make-catenated-stream .