From: Ben Pfaff Date: Tue, 8 Jun 2010 04:45:33 +0000 (-0700) Subject: gui: Create user settings directory if it doesn't already exist. X-Git-Tag: v0.7.6~375 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=22f5cb71af029deb1c919b7c6bc958572f8da9f9;p=pspp-builds.git gui: Create user settings directory if it doesn't already exist. The user settings directory doesn't necessarily exist. Some program has to create it, and PSPPIRE might be the first program that wants it, so it should try to create it. Discovered on OpenBSD. --- diff --git a/src/ui/gui/psppire-conf.c b/src/ui/gui/psppire-conf.c index 07db3b58..dbcdf0e0 100644 --- a/src/ui/gui/psppire-conf.c +++ b/src/ui/gui/psppire-conf.c @@ -20,7 +20,9 @@ */ #include +#include #include +#include #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, 0777); conf->filename = g_strdup_printf ("%s/%s", dirname, "psppirerc");