mirror of
https://github.com/irssi/irssi.git
synced 2026-08-10 12:23:37 +02:00
Replace mkpath with g_mkdir_with_parents
This commit is contained in:
parent
1a6ec1b0b6
commit
bb190be0bf
6 changed files with 4 additions and 44 deletions
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue