aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThorsten Töpper <atsutane@freethoughts.de>2026-02-24 20:15:08 +0100
committerThorsten Töpper <atsutane@freethoughts.de>2026-02-24 20:15:08 +0100
commitf6e1fa9b6a18379d8c1ff2cee27a069e6ad465f1 (patch)
treeed4ab915fd926dc24d91b83a596bf47d3c1f5e10
parenteb50073ce5fe7bc7cb3749fd7674096ce767d095 (diff)
downloadduplicate_finder-f6e1fa9b6a18379d8c1ff2cee27a069e6ad465f1.tar.gz
duplicate_finder-f6e1fa9b6a18379d8c1ff2cee27a069e6ad465f1.tar.bz2
directory_scanner: fix ignorance of parent dir entry
-rw-r--r--src/directory_scanner.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/directory_scanner.c b/src/directory_scanner.c
index 27627d5..0ae1e31 100644
--- a/src/directory_scanner.c
+++ b/src/directory_scanner.c
@@ -124,7 +124,7 @@ int traverse_directory_tree(const char *starting_point) {
int process_directory(char *path) {
char *fullpath = NULL, *fname_in_path = NULL, *stack_entry = NULL;
char type = 0;
- size_t path_length = 0;
+ size_t path_length = 0, dnamelen = 0;
DIR *dir;
struct dirent *de = NULL;
struct stat stat_res;
@@ -159,8 +159,19 @@ int process_directory(char *path) {
}
while ((de = readdir(dir)) != NULL) {
- if (de->d_name[0] == '.' && option_show_hidden_entries == false)
- continue;
+ /* Current dir . and parent dir .. everywhere,
+ * invisible files on UNIXoid filesystems*/
+ if (de->d_name[0] == '.') {
+ if (option_show_hidden_entries == false) {
+ continue;
+ }
+ dnamelen = strlen(de->d_name);
+
+ if ((dnamelen == 1) ||
+ (dnamelen == 2 && de->d_name[1] == '.')) {
+ continue;
+ }
+ }
sprintf(fname_in_path, "%s", de->d_name);
DBGTRC("DEBUG: fullpath: '%s'\n", fullpath);