Normalize mkdir() error codes

This commit is contained in:
Justine Tunney 2021-01-29 19:49:34 -08:00
parent 6070319f84
commit bf8b1623c8
11 changed files with 206 additions and 25 deletions

View file

@ -32,7 +32,7 @@ static int rmrfdir(const char *dirpath) {
char *path;
struct dirent *e;
if (!(d = opendir(dirpath))) return -1;
for (rc = 0; (e = readdir(d));) {
while ((e = readdir(d))) {
if (!strcmp(e->d_name, ".")) continue;
if (!strcmp(e->d_name, "..")) continue;
if (strchr(e->d_name, '/')) abort();
@ -44,7 +44,9 @@ static int rmrfdir(const char *dirpath) {
}
free(path);
}
return closedir(d);
rc = closedir(d);
rc |= rmdir(dirpath);
return rc;
}
/**