Skip to content

Commit 991ea5c

Browse files
committed
config: more friendly error message on mkdir failure
mkdir may fail in case user sets cm_dir to something non-existent expecting clipmenu to create the parent dir as well. give a nicer error message on such failure.
1 parent 45dd26a commit 991ea5c

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

src/config.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ char *get_cache_dir(struct config *cfg) {
4444
// In case config changed, do the write anyway
4545
snprintf_safe(cache_dir, PATH_MAX, "%s/clipmenu.%d.%ld", cfg->runtime_dir,
4646
CLIPMENU_VERSION, (long)getuid());
47-
expect(mkdir(cache_dir, S_IRWXU) == 0 || errno == EEXIST);
47+
die_on(mkdir(cache_dir, S_IRWXU) != 0 && errno != EEXIST,
48+
"Failed to create directory: %s\n", cache_dir);
4849
return cache_dir;
4950
}
5051

0 commit comments

Comments
 (0)