1
0
mirror of https://github.com/irssi/irssi.git synced 2025-02-02 15:08:01 -05:00

Replace mkpath with g_mkdir_with_parents

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

View File

@ -114,7 +114,7 @@ int log_start_logging(LOG_REC *log)
/* path may contain variables (%time, $vars),
make sure the directory is created */
dir = g_path_get_dirname(log->real_fname);
mkpath(dir, log_dir_create_mode);
g_mkdir_with_parents(dir, log_dir_create_mode);
g_free(dir);
}

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)
{

View File

@ -39,8 +39,6 @@ GSList *hashtable_get_keys(GHashTable *hash);
/* easy way to check if regexp matches */
int regexp_match(const char *str, const char *regexp);
/* Create the directory and all it's parent directories */
int mkpath(const char *path, int mode);
/* convert ~/ to $HOME */
char *convert_home(const char *path);

View File

@ -150,7 +150,7 @@ void rawlog_save(RAWLOG_REC *rawlog, const char *fname)
int f;
dir = g_path_get_dirname(fname);
mkpath(dir, log_dir_create_mode);
g_mkdir_with_parents(dir, log_dir_create_mode);
g_free(dir);
path = convert_home(fname);

View File

@ -683,7 +683,7 @@ static void init_configfile(void)
if (stat(get_irssi_dir(), &statbuf) != 0) {
/* ~/.irssi not found, create it. */
if (mkpath(get_irssi_dir(), 0700) != 0) {
if (g_mkdir_with_parents(get_irssi_dir(), 0700) != 0) {
g_error("Couldn't create %s directory", get_irssi_dir());
}
} else if (!S_ISDIR(statbuf.st_mode)) {

View File

@ -453,7 +453,7 @@ static void autolog_open(SERVER_REC *server, const char *server_tag,
log_item_add(log, LOG_ITEM_TARGET, target, server_tag);
dir = g_path_get_dirname(log->real_fname);
mkpath(dir, log_dir_create_mode);
g_mkdir_with_parents(dir, log_dir_create_mode);
g_free(dir);
log->temp = TRUE;