]> git.sur5r.net Git - i3/i3/blobdiff - src/util.c
Merge branch 'dont-match-placeholders'
[i3/i3] / src / util.c
index c40f6581b866b9862ae681b6b625087017a2205a..b382a586e09f2d8b545e663bcaa26b5b4eaf61cc 100644 (file)
@@ -249,6 +249,15 @@ char *store_restart_layout(void) {
         filename = resolve_tilde(config.restart_state_path);
     }
 
+    /* create the directory, it could have been cleaned up before restarting or
+     * may not exist at all in case it was user-specified. */
+    char *filenamecopy = sstrdup(filename);
+    char *base = dirname(filenamecopy);
+    DLOG("Creating \"%s\" for storing the restart layout\n", base);
+    if (!mkdirp(base))
+        ELOG("Could not create \"%s\" for storing the restart layout, layout will be lost.\n", base);
+    free(filenamecopy);
+
     int fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR);
     if (fd == -1) {
         perror("open()");