diff options
author | LemonBoy <thatlemon@gmail.com> | 2016-02-13 13:12:29 +0100 |
---|---|---|
committer | LemonBoy <thatlemon@gmail.com> | 2016-06-05 16:24:55 +0200 |
commit | bb190be0bfac956ada4f74a514ff70f28b114efa (patch) | |
tree | 5abd9b45a6a65e0f0ed02e1885a4c2b671367718 | |
parent | 1a6ec1b0b63c4ffbaf22137157a6fae3570b6839 (diff) | |
download | irssi-bb190be0bfac956ada4f74a514ff70f28b114efa.zip |
Replace mkpath with g_mkdir_with_parents
-rw-r--r-- | src/core/log.c | 2 | ||||
-rw-r--r-- | src/core/misc.c | 38 | ||||
-rw-r--r-- | src/core/misc.h | 2 | ||||
-rw-r--r-- | src/core/rawlog.c | 2 | ||||
-rw-r--r-- | src/core/settings.c | 2 | ||||
-rw-r--r-- | src/fe-common/core/fe-log.c | 2 |
6 files changed, 4 insertions, 44 deletions
diff --git a/src/core/log.c b/src/core/log.c index 8306d2df..6af1effc 100644 --- a/src/core/log.c +++ b/src/core/log.c @@ -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); } diff --git a/src/core/misc.c b/src/core/misc.c index c26610ec..a8a0975a 100644 --- a/src/core/misc.c +++ b/src/core/misc.c @@ -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) { diff --git a/src/core/misc.h b/src/core/misc.h index 7e78d3b9..58b665bf 100644 --- a/src/core/misc.h +++ b/src/core/misc.h @@ -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); diff --git a/src/core/rawlog.c b/src/core/rawlog.c index 875c0ef2..2b46c50d 100644 --- a/src/core/rawlog.c +++ b/src/core/rawlog.c @@ -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); diff --git a/src/core/settings.c b/src/core/settings.c index 8e493124..17fc4115 100644 --- a/src/core/settings.c +++ b/src/core/settings.c @@ -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)) { diff --git a/src/fe-common/core/fe-log.c b/src/fe-common/core/fe-log.c index f2c4c014..5bc5c4e1 100644 --- a/src/fe-common/core/fe-log.c +++ b/src/fe-common/core/fe-log.c @@ -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; |