summaryrefslogtreecommitdiffstats
path: root/src/common.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/common.c')
-rw-r--r--src/common.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/common.c b/src/common.c
index 7646361..49df778 100644
--- a/src/common.c
+++ b/src/common.c
@@ -234,13 +234,19 @@ int mkdir_with_parents(const char *dir, int mode)
if (__mkdir(dir, mode) == 0) {
return 0;
} else {
- if (errno == EEXIST) return 0;
+ if (errno == EEXIST) {
+ return 0;
+ } else if (errno == ENOENT) {
+ // ignore
+ } else {
+ return -1;
+ }
}
int res;
char *parent = strdup(dir);
- parent = dirname(parent);
- if (parent && (strcmp(parent, ".") != 0) && (strcmp(parent, dir) != 0)) {
- res = mkdir_with_parents(parent, mode);
+ char *parentdir = dirname(parent);
+ if (parentdir && (strcmp(parentdir, ".") != 0) && (strcmp(parentdir, dir) != 0)) {
+ res = mkdir_with_parents(parentdir, mode);
} else {
res = -1;
}
@@ -287,4 +293,4 @@ void plist_dict_merge(plist_t* dictionary, plist_t node)
plist_dict_next_item(node, it, &key, &subnode);
}
free(it);
-} \ No newline at end of file
+}