8 * Emulates mkdir -p (creates any missing folders)
11 bool mkdirp(const char *path) {
12 if (mkdir(path, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) == 0)
14 if (errno != ENOENT) {
15 ELOG("mkdir(%s) failed: %s\n", path, strerror(errno));
18 char *copy = sstrdup(path);
19 /* strip trailing slashes, if any */
20 while (copy[strlen(copy) - 1] == '/')
21 copy[strlen(copy) - 1] = '\0';
23 char *sep = strrchr(copy, '/');
34 result = mkdirp(path);