From a358864785bca553e94314ed65717fe5aeb93d3d Mon Sep 17 00:00:00 2001 From: Ikey Doherty Date: Fri, 10 Nov 2017 01:14:56 +0000 Subject: [PATCH] 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 --- src/lsi/lsi.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/lsi/lsi.c b/src/lsi/lsi.c index 3a1e2e7..5f2f606 100644 --- a/src/lsi/lsi.c +++ b/src/lsi/lsi.c @@ -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;