From: Jim Meyering Date: Wed, 5 Feb 2003 20:19:31 +0000 (+0000) Subject: (ftw_startup): When using FTW_DEPTH, call `func', the X-Git-Tag: v4.5.6~26 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5a5f1c2340ca53dcbd029e0f962ec16350fd5aab;p=thirdparty%2Fcoreutils.git (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'. --- diff --git a/lib/ftw.c b/lib/ftw.c index ceed7fdea1..fc1c5109cb 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 {