xdg: init_configfiles() accomodate for new paths

- if xdg is being used, check if the special directories exist, if so,
create them
This commit is contained in:
altffour 2021-01-07 14:34:51 +03:00
commit 95ae4f1ed4
No known key found for this signature in database
GPG key ID: B4ADFA86EDF5CCE9

View file

@ -778,6 +778,33 @@ static void init_configfile(void)
"You should remove it with command: rm %s", "You should remove it with command: rm %s",
get_irssi_dir(), get_irssi_dir()); get_irssi_dir(), get_irssi_dir());
} }
/* check XDG path, if it is being used */
if (get_irssi_dir() != get_irssi_cache_dir()) {
if (stat(get_irssi_cache_dir(), &statbuf) != 0) {
if (g_mkdir_with_parents(get_irssi_cache_dir(), 0700) != 0) {
g_error("Couldn't create %s directory: %s",
get_irssi_cache_dir(), g_strerror(errno));
}
}
else if (!S_ISDIR(statbuf.st_mode)) {
g_error("%s is not a directory.\n"
"You should remove it with command: rm %s",
get_irssi_cache_dir(), get_irssi_cache_dir());
}
}
if (get_irssi_dir() != get_irssi_runtime_dir()) {
if (stat(get_irssi_runtime_dir(), &statbuf) != 0) {
if (g_mkdir_with_parents(get_irssi_runtime_dir(), 0700) != 0) {
g_error("Couldn't create %s directory: %s",
get_irssi_runtime_dir(), g_strerror(errno));
}
}
else if (!S_ISDIR(statbuf.st_mode)) {
g_error("%s is not a directory.\n"
"You should remove it with command: rm %s",
get_irssi_runtime_dir(), get_irssi_runtime_dir());
}
}
mainconfig = parse_configfile(NULL); mainconfig = parse_configfile(NULL);
config_last_modifycounter = mainconfig->modifycounter; config_last_modifycounter = mainconfig->modifycounter;