]> git.tue.mpg.de Git - paraslash.git/commitdiff
play: Create ~/.paraslash.
authorAndre Noll <maan@tuebingen.mpg.de>
Tue, 25 May 2021 15:10:16 +0000 (17:10 +0200)
committerAndre Noll <maan@tuebingen.mpg.de>
Fri, 28 May 2021 13:06:17 +0000 (15:06 +0200)
Currently para_play won't save its history if this directory does
not exist. This patch makes it create the directory at startup.

play.c

diff --git a/play.c b/play.c
index 2346c6b0101045d51e87b5d40abb5b983df6f014..7369c33fe7f3ee2d30505de21e692ce48f33428a 100644 (file)
--- a/play.c
+++ b/play.c
@@ -1051,9 +1051,16 @@ static void session_open(void)
                history_file = para_strdup(OPT_STRING_VAL(HISTORY_FILE));
        else {
                char *home = para_homedir();
-               history_file = make_message("%s/.paraslash/play.history",
-                       home);
+               char *dot_para = make_message("%s/.paraslash", home);
+
                free(home);
+               ret = para_mkdir(dot_para, 0777);
+               /* warn, but otherwise ignore mkdir error */
+               if (ret < 0 && ret != -ERRNO_TO_PARA_ERROR(EEXIST))
+                       PARA_WARNING_LOG("Can not create %s: %s\n", dot_para,
+                               para_strerror(-ret));
+               history_file = make_message("%s/play.history", dot_para);
+               free(dot_para);
        }
        ici.history_file = history_file;
        ici.loglevel = loglevel;