i18n: Introduce C_ENCODING as replacement for LEGACY_NATIVE.
[pspp-builds.git] / src / ui / gui / psppire-conf.c
index 07db3b58c21e5d07e16d8789a285f2ad20978450..02cc2751212a2a0de931fe7a2b9e722b342255e2 100644 (file)
@@ -20,7 +20,9 @@
 */
 
 #include <config.h>
+#include <errno.h>
 #include <stdio.h>
+#include <sys/stat.h>
 
 #include "psppire-conf.h"
 
@@ -140,7 +142,15 @@ psppire_conf_class_init (PsppireConfClass *class)
 static void
 psppire_conf_init (PsppireConf *conf)
 {
-  const gchar *dirname = g_get_user_config_dir ();
+  const gchar *dirname;
+  struct stat s;
+
+  /* Get the name of the directory for user configuration files, then, if it
+     doesn't already exist, create it, since we might be the first program
+     to want to put files there. */
+  dirname = g_get_user_config_dir ();
+  if (stat (dirname, &s) == -1 && errno == ENOENT)
+    mkdir (dirname, 0700);
 
   conf->filename = g_strdup_printf ("%s/%s", dirname, "psppirerc");