Bug 763202 - Create $XDG_DATA_HOME if it doesn't exist.

This has shown a problem especially on non-Linux platforms since XDG
is more of a Linux standard.
This commit is contained in:
Jehan 2016-06-13 03:26:57 +02:00
parent 93d9265f0a
commit 8ac1e407c5
1 changed files with 17 additions and 1 deletions

View File

@ -21,6 +21,7 @@
#include "config.h"
#include <errno.h>
#include <string.h>
#include <sys/types.h>
@ -116,7 +117,8 @@ const guint gimp_micro_version = GIMP_MICRO_VERSION;
void
gimp_env_init (gboolean plug_in)
{
static gboolean gimp_env_initialized = FALSE;
static gboolean gimp_env_initialized = FALSE;
const gchar *data_home = g_get_user_data_dir ();
if (gimp_env_initialized)
g_error ("gimp_env_init() must only be called once!");
@ -153,6 +155,20 @@ gimp_env_init (gboolean plug_in)
g_free (libdir);
}
#endif
/* The user data directory (XDG_DATA_HOME on Unix) is used to store
* various data, like crash logs (win32) or recently used file history
* (by GTK+). Yet it may be absent, in particular on non-Linux
* platforms. Make sure it exists.
*/
if (! g_file_test (data_home, G_FILE_TEST_IS_DIR))
{
if (g_mkdir_with_parents (data_home, S_IRUSR | S_IWUSR | S_IXUSR) != 0)
{
g_warning ("Failed to create the data directory '%s': %s",
data_home, g_strerror (errno));
}
}
}
/**