From 0014666cf4b36f768ef063089f58fd1c66a888d6 Mon Sep 17 00:00:00 2001 From: "Weisser, Pascal" Date: Tue, 1 Jul 2025 13:18:36 +0200 Subject: [PATCH] logging: Create intermediate directories of log file path. Create directories ${HOME}/.local and ${HOME}/.local/share before creating ${HOME}/.local/share/clight directory as they do not necessarily exist. This resolves issue #318. Signed-off-by: Weisser, Pascal --- src/utils/log.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/utils/log.c b/src/utils/log.c index 0ec38a5..186220b 100644 --- a/src/utils/log.c +++ b/src/utils/log.c @@ -23,7 +23,11 @@ void open_log(void) { } else if (getenv("XDG_DATA_HOME")) { snprintf(log_path, PATH_MAX, "%s/clight/", getenv("XDG_DATA_HOME")); } else { - snprintf(log_path, PATH_MAX, "%s/.local/share/clight/", getpwuid(getuid())->pw_dir); + snprintf(log_path, PATH_MAX, "%s/.local/", getpwuid(getuid())->pw_dir); + mkdir(log_path, 0755); + strcat(log_path, "share/"); + mkdir(log_path, 0755); + strcat(log_path, "clight/"); } /* Create log folder if it does not exist! */