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. --- bfs.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'bfs.c') diff --git a/bfs.c b/bfs.c index c637ba3..a3a969c 100644 --- a/bfs.c +++ b/bfs.c @@ -23,17 +23,16 @@ typedef struct { bool hidden; } options; -static int callback(const char *fpath, const struct stat *sb, int typeflag, void *ptr) { +static int callback(const char *fpath, const struct BFTW* ftwbuf, void *ptr) { const options *opts = ptr; if (!opts->hidden) { - const char *filename = strrchr(fpath, '/'); - if (filename && filename[1] == '.') { + if (ftwbuf->base > 0 && fpath[ftwbuf->base] == '.') { return BFTW_SKIP_SUBTREE; } } - pretty_print(opts->colors, fpath, sb); + pretty_print(opts->colors, fpath, ftwbuf->statbuf); return BFTW_CONTINUE; } -- cgit v1.2.3