Move mkdirp() to libutil

This commit is contained in:
sin
2015-04-20 18:02:11 +01:00
parent 31af8555a7
commit b9d60bee87
5 changed files with 32 additions and 46 deletions

23
mkdir.c
View File

@@ -6,29 +6,6 @@
#include "util.h"
static int
mkdirp(char *path)
{
char *p;
for (p = path + (*path == '/'); *p; p++) {
if (*p != '/')
continue;
*p = '\0';
if (mkdir(path, S_IRWXU | S_IRWXG | S_IRWXO) < 0 && errno != EEXIST) {
weprintf("mkdir %s:", path);
*p = '/';
return -1;
}
*p = '/';
}
if (mkdir(path, S_IRWXU | S_IRWXG | S_IRWXO) < 0 && errno != EEXIST) {
weprintf("mkdir %s:", path);
return -1;
}
return 0;
}
static void
usage(void)
{