Skip to content

Commit

Permalink
Merge pull request vergoh#237 from cgzones/readdir
Browse files Browse the repository at this point in the history
handle DT_UNKNOWN type entries in remove_directory
  • Loading branch information
vergoh committed Sep 24, 2022
2 parents 0415b84 + d95bd19 commit 1f8867b
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/vnstat_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,23 @@ int remove_directory(const char *directory)
return 0;
}
break;
case DT_UNKNOWN:
if (strcmp(di->d_name, ".") == 0 || strcmp(di->d_name, "..") == 0) {
continue;
}
snprintf(entryname, 512, "%s/%s", directory, di->d_name);
if (unlink(entryname) != 0) {
if (errno == EISDIR) {
if (!remove_directory(entryname)) {
closedir(dir);
return 0;
}
} else {
closedir(dir);
return 0;
}
}
break;
default:
continue;
}
Expand Down

0 comments on commit 1f8867b

Please sign in to comment.