diff options
author | Harry Jeffery <harry@exec64.co.uk> | 2019-08-07 22:08:43 +0100 |
---|---|---|
committer | Harry Jeffery <harry@exec64.co.uk> | 2019-08-07 22:08:43 +0100 |
commit | 6d43f274030ffc6f828e699eb8542ddab50d8d88 (patch) | |
tree | 839ecba6b186e6a220abbf65c2e62e911b934ae5 | |
parent | 4d90834f887478754948b7bc5febc155716d9313 (diff) | |
download | imv-6d43f274030ffc6f828e699eb8542ddab50d8d88.tar.gz |
navigator: Don't pickup child directories when non-recursive
-rw-r--r-- | src/navigator.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/navigator.c b/src/navigator.c index a927be4..63db338 100644 --- a/src/navigator.c +++ b/src/navigator.c @@ -83,11 +83,14 @@ int imv_navigator_add(struct imv_navigator *nav, const char *path, continue; } snprintf(path_buf, sizeof path_buf, "%s/%s", path, dir->d_name); - if (recursive) { + struct stat new_path_info; + stat(path_buf, &new_path_info); + int is_dir = S_ISDIR(new_path_info.st_mode); + if (is_dir && recursive) { if (imv_navigator_add(nav, path_buf, recursive) != 0) { return 1; } - } else { + } else if (!is_dir) { if (add_item(nav, path_buf) != 0) { return 1; } |