diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2017-02-05 17:28:44 -0500 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2017-02-05 19:04:25 -0500 |
commit | d8444e1ec6a51b53da55149a2d4a6847185d000d (patch) | |
tree | 946c9710a73b3cd26efc809a6af3f9157f1f2839 /bftw.c | |
parent | a6f94c132c425bbab543e98fcd19f4ff7519d1b7 (diff) | |
download | bfs-d8444e1ec6a51b53da55149a2d4a6847185d000d.tar.xz |
bftw: Compute nameoff correctly for the root in BFTW_DEPTH mode
Diffstat (limited to 'bftw.c')
-rw-r--r-- | bftw.c | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -777,10 +777,14 @@ static void bftw_init_buffers(struct bftw_state *state, const struct dirent *de) dircache_entry_base(&state->cache, current, &ftwbuf->at_fd, &ftwbuf->at_path); } } else { - ftwbuf->nameoff = basename_offset(ftwbuf->path); ftwbuf->depth = 0; } + if (ftwbuf->depth == 0) { + // Compute the name offset for root paths like "foo/bar" + ftwbuf->nameoff = basename_offset(ftwbuf->path); + } + ftwbuf->typeflag = BFTW_UNKNOWN; if (de) { ftwbuf_use_dirent(ftwbuf, de); |