summaryrefslogtreecommitdiffstats
path: root/bftw.h
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2015-06-18 23:35:43 -0400
committerTavian Barnes <tavianator@tavianator.com>2015-06-18 23:35:43 -0400
commitac11476e20136976bf689acf847fdcea4e05e37a (patch)
tree00479528e76f3af42645635da0fa959f784eecfc /bftw.h
parent3f7290f5fd7b5c441b35896dfa3333e2f4989ea4 (diff)
downloadbfs-ac11476e20136976bf689acf847fdcea4e05e37a.tar.xz
bftw: Add flags parameter and BFTW_STAT flag.
Diffstat (limited to 'bftw.h')
-rw-r--r--bftw.h13
1 files changed, 11 insertions, 2 deletions
diff --git a/bftw.h b/bftw.h
index be538a8..09c7943 100644
--- a/bftw.h
+++ b/bftw.h
@@ -9,11 +9,15 @@
* the COPYING file or http://www.wtfpl.net/ for more details. *
*********************************************************************/
+#include <sys/stat.h>
+
/**
* Callback function type for bftw().
*
* @param fpath
* The path to the encountered file.
+ * @param sb
+ * A stat() buffer; may be NULL if no stat() call was needed.
* @param typeflag
* A typeflag value (see below).
* @param ptr
@@ -21,7 +25,7 @@
* @return
* An action value (see below).
*/
-typedef int bftw_fn(const char *fpath, int typeflag, void *ptr);
+typedef int bftw_fn(const char *fpath, const struct stat *sb, int typeflag, void *ptr);
/**
* Breadth First Tree Walk (or Better File Tree Walk).
@@ -36,12 +40,14 @@ typedef int bftw_fn(const char *fpath, int typeflag, void *ptr);
* The callback to invoke.
* @param nopenfd
* The maximum number of file descriptors to keep open.
+ * @param flags
+ * Flags that control bftw() behavior (see below).
* @param ptr
* A generic pointer which is passed to fn().
* @return
* 0 on success, or -1 on failure.
*/
-int bftw(const char *dirpath, bftw_fn *fn, int nopenfd, void *ptr);
+int bftw(const char *dirpath, bftw_fn *fn, int nopenfd, int flags, void *ptr);
/** typeflag: Directory. */
#define BFTW_D 0
@@ -60,3 +66,6 @@ int bftw(const char *dirpath, bftw_fn *fn, int nopenfd, void *ptr);
#define BFTW_SKIP_SUBTREE 2
/** action: Stop walking. */
#define BFTW_STOP 3
+
+/** flag: stat() each encountered file. */
+#define BFTW_STAT (1 << 0)