Replace mkpath with g_mkdir_with_parents

This commit is contained in:
LemonBoy 2016-02-13 13:12:29 +01:00
commit bb190be0bf
6 changed files with 4 additions and 44 deletions

View file

@ -407,44 +407,6 @@ int regexp_match(const char *str, const char *regexp)
#endif
}
/* Create the directory and all it's parent directories */
int mkpath(const char *path, int mode)
{
struct stat statbuf;
const char *p;
char *dir;
g_return_val_if_fail(path != NULL, -1);
p = g_path_skip_root((char *) path);
if (p == NULL) {
/* not a full path, maybe not what we wanted
but continue anyway.. */
p = path;
}
for (;;) {
if (*p != G_DIR_SEPARATOR && *p != '\0') {
p++;
continue;
}
dir = g_strndup(path, (int) (p-path));
if (stat(dir, &statbuf) != 0) {
if (mkdir(dir, mode) == -1)
{
g_free(dir);
return -1;
}
}
g_free(dir);
if (*p++ == '\0')
break;
}
return 0;
}
/* convert ~/ to $HOME */
char *convert_home(const char *path)
{