diff options
author | Jim Meyering <jim@meyering.net> | 2003-02-05 20:19:31 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 2003-02-05 20:19:31 +0000 |
commit | 5a5f1c2340ca53dcbd029e0f962ec16350fd5aab (patch) | |
tree | faf7d646abfc768c81273452c897115e361d2370 | |
parent | 03975e728debdbe5ad3eb08ab1bfd7573224a174 (diff) | |
download | coreutils-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.c | 10 |
1 files changed, 9 insertions, 1 deletions
@@ -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 { |