From 5a5f1c2340ca53dcbd029e0f962ec16350fd5aab Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Wed, 5 Feb 2003 20:19:31 +0000 Subject: (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'. --- lib/ftw.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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 { -- cgit v1.2.3-70-g09d2