lsi: When ~/.config doesn't exist, create it

This helps with problems under snapd build which fails to correctly store
settings on exit, due to a missing directory.

This is part of the ongoing work for issue #30.

Signed-off-by: Ikey Doherty <ikey@solus-project.com>
This commit is contained in:
Ikey Doherty
2017-11-10 01:15:29 +00:00
parent 60664c4c6b
commit a358864785
+12
View File
@@ -147,11 +147,23 @@ bool lsi_config_store(LsiConfig *config)
{
autofree(FILE) *fp = NULL;
autofree(char) *conf = NULL;
autofree(char) *dir = NULL;
if (!config) {
return false;
}
/* Ensure we have config directory, i.e. when as a snap.. */
dir = lsi_get_user_config_dir();
if (!dir) {
return false;
}
if (!lsi_file_exists(dir)) {
if (mkdir(dir, 00755) < 0) {
return false;
}
}
conf = lsi_get_user_config_file();
if (!conf) {
return false;