]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
(ftw_startup): When using FTW_DEPTH, call `func', the
authorJim Meyering <jim@meyering.net>
Wed, 5 Feb 2003 20:19:31 +0000 (20:19 +0000)
committerJim Meyering <jim@meyering.net>
Wed, 5 Feb 2003 20:19:31 +0000 (20:19 +0000)
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

index ceed7fdea1e5fb58c26245a8479c45b294d45f97..fc1c5109cbb51a8006b652bc890c9eeae01ddc8f 100644 (file)
--- 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
            {