summaryrefslogtreecommitdiffstats
path: root/bftw.h
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2015-07-23 21:19:37 -0400
committerTavian Barnes <tavianator@tavianator.com>2015-07-23 21:19:37 -0400
commitba034f0fd6343060eb03650504fe992843bc0261 (patch)
treece08bbb037bbeb0ea7857bb682992b58a15bed49 /bftw.h
parenta47cee3a89da7a2cff6b615e381fd486d5d9c06e (diff)
downloadbfs-ba034f0fd6343060eb03650504fe992843bc0261.tar.xz
bftw: New struct BFTW type to hold file attributes.
Like nftw()'s struct FTW. level is needed to implement -mindepth/ -maxdepth.
Diffstat (limited to 'bftw.h')
-rw-r--r--bftw.h22
1 files changed, 17 insertions, 5 deletions
diff --git a/bftw.h b/bftw.h
index 09c7943..37e1524 100644
--- a/bftw.h
+++ b/bftw.h
@@ -12,20 +12,32 @@
#include <sys/stat.h>
/**
+ * Data about the current file for the bftw() callback.
+ */
+struct BFTW {
+ /** A stat() buffer; may be NULL if no stat() call was needed. */
+ const struct stat *statbuf;
+ /** A typeflag value (see below). */
+ int typeflag;
+ /** The string offset of the filename in the path. */
+ int base;
+ /** The depth of this file in the walk. */
+ int level;
+};
+
+/**
* 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 ftwbuf
+ * Additional data about the current file.
* @param ptr
* The pointer passed to bftw().
* @return
* An action value (see below).
*/
-typedef int bftw_fn(const char *fpath, const struct stat *sb, int typeflag, void *ptr);
+typedef int bftw_fn(const char *fpath, const struct BFTW *ftwbuf, void *ptr);
/**
* Breadth First Tree Walk (or Better File Tree Walk).