From 51cdc93b40dbebd65b14e931385cb3bd354a8082 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Fri, 22 Apr 2016 06:50:55 -0700 Subject: Support list of paths in ftw. * ftw.c (ftw_wrap): Handle case when dirpath is a list, by recursion. * txr.1: Documented. --- ftw.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'ftw.c') diff --git a/ftw.c b/ftw.c index 6128a652..c906d6a3 100644 --- a/ftw.c +++ b/ftw.c @@ -91,6 +91,18 @@ val ftw_wrap(val dirpath, val fn, val flags_in, val nopenfd_in) if (s_callback) { uw_throwf(error_s, lit("ftw: cannot be re-entered from " "ftw callback"), nao); + } else if (dirpath == nil) { + return t; + } else if (consp(dirpath)) { + uses_or2; + val ret = nil; + for (; dirpath; dirpath = cdr(dirpath)) { + val res = ftw_wrap(car(dirpath), fn, flags_in, nopenfd_in); + if (res != t && res != nil) + return res; + ret = or2(ret, res); + } + return ret; } else { int nopenfd = c_num(default_arg(nopenfd_in, num_fast(20))); int flags = c_num(default_arg(flags_in, zero)); -- cgit v1.2.3