return 1;
// We have arrived at the top of the tree
- if (*dirname == '.' || *dirname == '/')
+ if (*dirname == '.' || strcmp(dirname, "/") == 0)
return 0;
// Ensure the parent directory exists
r = pakfire_mkparentdir(dirname);
- if (r) {
- if (errno == EEXIST)
- r = 0;
-
+ if (r)
goto END;
- }
// Create this directory
r = mkdir(dirname, 0);
+ // Ignore when the directory already exists
+ if (r && errno == EEXIST)
+ r = 0;
+
END:
free(dirname);
}
FILE* pakfire_mktemp(char* path) {
- pakfire_mkparentdir(path);
+ int r = pakfire_mkparentdir(path);
+ if (r)
+ return NULL;
// Create a temporary result file
int fd = mkostemp(path, O_CLOEXEC);