diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2015-07-25 20:14:34 -0400 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2015-07-25 20:14:34 -0400 |
commit | 781f5902b7bbb91811f1f810f8a419607ed36294 (patch) | |
tree | 8ff1acf48ba81b2f35190a4f3d811ad1b6bf68f7 /bfs.c | |
parent | e674297be6be114a530cd06d2ca773baff1ce7cc (diff) | |
download | bfs-781f5902b7bbb91811f1f810f8a419607ed36294.tar.xz |
Recover from errors in diropen().
Fixes #4.
Diffstat (limited to 'bfs.c')
-rw-r--r-- | bfs.c | 11 |
1 files changed, 8 insertions, 3 deletions
@@ -23,9 +23,14 @@ typedef struct { bool hidden; } options; -static int callback(const char *fpath, const struct BFTW* ftwbuf, void *ptr) { +static int callback(const char *fpath, const struct BFTW *ftwbuf, void *ptr) { const options *opts = ptr; + if (ftwbuf->typeflag == BFTW_ERROR) { + print_error(opts->colors, fpath, ftwbuf); + return BFTW_SKIP_SUBTREE; + } + if (!opts->hidden) { if (ftwbuf->base > 0 && fpath[ftwbuf->base] == '.') { return BFTW_SKIP_SUBTREE; @@ -36,7 +41,7 @@ static int callback(const char *fpath, const struct BFTW* ftwbuf, void *ptr) { return BFTW_CONTINUE; } -int main(int argc, char* argv[]) { +int main(int argc, char *argv[]) { int ret = EXIT_FAILURE; options opts; @@ -73,7 +78,7 @@ int main(int argc, char* argv[]) { opts.path = "."; } - int flags = 0; + int flags = BFTW_RECOVER; if (color) { flags |= BFTW_STAT; |