accounting for files "." and ".."

This commit is contained in:
nova
2025-07-08 00:43:19 +02:00
parent b77c9a2a29
commit bc6fb162c5
3 changed files with 14 additions and 9 deletions

View File

@ -38,6 +38,10 @@ unsigned long get_dir_size(char *path){
}
}
closedir(dir);
if (file_modifiers & FILE_MODIFIERS_HIDDEN_FILES) {
/* removes files "." and ".." */
entry_count -= 2;
}
return entry_count;
}
@ -45,7 +49,7 @@ unsigned long get_dir_size(char *path){
void get_dir_content(char *path, unsigned long *dir_file_count, file *dir_content){
struct dirent **entry;
if (file_modifiers & FILE_MODIFIERS_HIDDEN_FILES) { /* print hidden files */
scandir(path, &entry, NULL, alphasort);
scandir(path, &entry, skip_dot, alphasort);
} else {
scandir(path, &entry, skip_hidden_files, alphasort);
}