[gimp/gimp-2-8] 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/gimp-2-8] Bug 763202 - Create $XDG_DATA_HOME if it doesn't exist.
- Date: Mon, 13 Jun 2016 01:47:13 +0000 (UTC)
commit 25dd2c33da360b84de69541b0ca7f69ad35b2372
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.
(cherry picked from commit 8ac1e407c585510080173446220b328d3294019a)
libgimpbase/gimpenv.c | 18 +++++++++++++++++-
1 files changed, 17 insertions(+), 1 deletions(-)
---
diff --git a/libgimpbase/gimpenv.c b/libgimpbase/gimpenv.c
index 1b74b4c..977a660 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>
@@ -98,7 +99,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!");
@@ -133,6 +135,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]