[gimp] libgimpconfig: create parent directories for config file if necessary.
- From: Jehan Pagès <jehanp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] libgimpconfig: create parent directories for config file if necessary.
- Date: Sun, 22 Apr 2018 20:17:43 +0000 (UTC)
commit 08cc37271fc73c430fd382a4b593bc5e502a502b
Author: Jehan <jehan girinstud io>
Date: Sun Apr 22 22:11:13 2018 +0200
libgimpconfig: create parent directories for config file if necessary.
The directory should be already created by GIMP. But just in case it is
not there, for whatever reason, don't just fail. Try and create all
parents.
libgimpconfig/gimpconfigwriter.c | 15 +++++++++++++++
1 files changed, 15 insertions(+), 0 deletions(-)
---
diff --git a/libgimpconfig/gimpconfigwriter.c b/libgimpconfig/gimpconfigwriter.c
index d408452..7da9a9a 100644
--- a/libgimpconfig/gimpconfigwriter.c
+++ b/libgimpconfig/gimpconfigwriter.c
@@ -170,10 +170,25 @@ gimp_config_writer_new_gfile (GFile *file,
{
GimpConfigWriter *writer;
GOutputStream *output;
+ GFile *dir;
g_return_val_if_fail (G_IS_FILE (file), NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
+ dir = g_file_get_parent (file);
+ if (dir && ! g_file_query_exists (dir, NULL))
+ {
+ if (! g_file_make_directory_with_parents (dir, NULL, error))
+ g_prefix_error (error,
+ _("Could not create directory '%s' for '%s': "),
+ gimp_file_get_utf8_name (dir),
+ gimp_file_get_utf8_name (file));
+ }
+ g_object_unref (dir);
+
+ if (error && *error)
+ return NULL;
+
if (atomic)
{
output = G_OUTPUT_STREAM (g_file_replace (file,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]