[gimp] Bug 763202 - Create $XDG_DATA_HOME if it doesn't exist.
- From: Jehan Pagès <jehanp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] Bug 763202 - Create $XDG_DATA_HOME if it doesn't exist.
- Date: Mon, 13 Jun 2016 01:38:08 +0000 (UTC)
commit 8ac1e407c585510080173446220b328d3294019a
Author: Jehan <jehan girinstud io>
Date: Mon Jun 13 03:26:57 2016 +0200
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.
libgimpbase/gimpenv.c | 18 +++++++++++++++++-
1 files changed, 17 insertions(+), 1 deletions(-)
---
diff --git a/libgimpbase/gimpenv.c b/libgimpbase/gimpenv.c
index 04fe249..be0d705 100644
--- a/libgimpbase/gimpenv.c
+++ b/libgimpbase/gimpenv.c
@@ -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));
+ }
+ }
}
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]