removal of possible NULL argument
This commit is contained in:
22
dir.c
22
dir.c
@@ -28,20 +28,22 @@ unsigned long get_dir_size(char *path){
|
|||||||
DIR *dir = opendir(path);
|
DIR *dir = opendir(path);
|
||||||
unsigned long entry_count = 0;
|
unsigned long entry_count = 0;
|
||||||
struct dirent *entry;
|
struct dirent *entry;
|
||||||
if (dir && file_modifiers & FILE_MODIFIERS_HIDDEN_FILES) {
|
if (dir) {
|
||||||
while ((entry=readdir(dir))) {
|
if (file_modifiers & FILE_MODIFIERS_HIDDEN_FILES) {
|
||||||
entry_count++;
|
while ((entry=readdir(dir))) {
|
||||||
}
|
|
||||||
/* removes files "." and ".." */
|
|
||||||
entry_count -= 2;
|
|
||||||
} else if (dir) {
|
|
||||||
while ((entry=readdir(dir))) {
|
|
||||||
if (entry->d_name[0] != '.') {
|
|
||||||
entry_count++;
|
entry_count++;
|
||||||
}
|
}
|
||||||
|
/* removes files "." and ".." */
|
||||||
|
entry_count -= 2;
|
||||||
|
} else {
|
||||||
|
while ((entry=readdir(dir))) {
|
||||||
|
if (entry->d_name[0] != '.') {
|
||||||
|
entry_count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
closedir(dir);
|
||||||
}
|
}
|
||||||
closedir(dir);
|
|
||||||
return entry_count;
|
return entry_count;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user