From ba034f0fd6343060eb03650504fe992843bc0261 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Thu, 23 Jul 2015 21:19:37 -0400 Subject: bftw: New struct BFTW type to hold file attributes. Like nftw()'s struct FTW. level is needed to implement -mindepth/ -maxdepth. --- bftw.h | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'bftw.h') diff --git a/bftw.h b/bftw.h index 09c7943..37e1524 100644 --- a/bftw.h +++ b/bftw.h @@ -11,21 +11,33 @@ #include +/** + * 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). -- cgit v1.2.3