summaryrefslogtreecommitdiffstats
path: root/bftw.c
diff options
context:
space:
mode:
Diffstat (limited to 'bftw.c')
-rw-r--r--bftw.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/bftw.c b/bftw.c
index 70826ea..4ac1240 100644
--- a/bftw.c
+++ b/bftw.c
@@ -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);