summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2003-02-05 20:19:31 +0000
committerJim Meyering <jim@meyering.net>2003-02-05 20:19:31 +0000
commit5a5f1c2340ca53dcbd029e0f962ec16350fd5aab (patch)
treefaf7d646abfc768c81273452c897115e361d2370
parent03975e728debdbe5ad3eb08ab1bfd7573224a174 (diff)
downloadcoreutils-5a5f1c2340ca53dcbd029e0f962ec16350fd5aab.tar.xz
(ftw_startup): When using FTW_DEPTH, call `func', the
user-supplied callback, once for the current directory before calling ftw_dir, in case that part of the hierarchy should be pruned. `func' does that by setting `data->skip'.
-rw-r--r--lib/ftw.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/ftw.c b/lib/ftw.c
index ceed7fdea..fc1c5109c 100644
--- a/lib/ftw.c
+++ b/lib/ftw.c
@@ -745,7 +745,15 @@ ftw_startup (const char *dir, int is_nftw, void *func, int descriptors,
result = add_object (&data, &st);
if (result == 0)
- result = ftw_dir (&data, &st);
+ {
+ /* If we're doing a depth-first traversal, give the user
+ a chance to prune the top-level directory. */
+ if ((flags & FTW_DEPTH)
+ && (result = (*data.func) (data.dirbuf, &st, FTW_DPRE,
+ &data.ftw)) == 0
+ && ! data.ftw.skip)
+ result = ftw_dir (&data, &st);
+ }
}
else
{