summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--capplets/appearance/mate-wp-xml.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/capplets/appearance/mate-wp-xml.c b/capplets/appearance/mate-wp-xml.c
index 8a998630..fb8ce905 100644
--- a/capplets/appearance/mate-wp-xml.c
+++ b/capplets/appearance/mate-wp-xml.c
@@ -23,6 +23,7 @@
#include <gio/gio.h>
#include <string.h>
#include <libxml/parser.h>
+#include <errno.h>
static gboolean mate_wp_xml_get_bool(const xmlNode* parent, const char* prop_name)
{
@@ -470,14 +471,11 @@ void mate_wp_xml_save_list(AppearanceData* data)
xmlNode* wallpaper;
//xmlNode* item;
GSList* list = NULL;
- char* wpfile;
g_hash_table_foreach(data->wp_hash, (GHFunc) mate_wp_list_flatten, &list);
g_hash_table_destroy(data->wp_hash);
list = g_slist_reverse(list);
- wpfile = g_build_filename(g_get_user_config_dir(), "mate", "backgrounds.xml", NULL);
-
xmlKeepBlanksDefault(0);
wplist = xmlNewDoc((xmlChar*) "1.0");
@@ -529,12 +527,24 @@ void mate_wp_xml_save_list(AppearanceData* data)
mate_wp_item_free(wpitem);
}
- /* Guardamos el archivo, solo si hay nodos en <wallpapers> */
+ /* save the xml document, only if there are nodes in <wallpapers> */
if (xmlChildElementCount(root) > 0)
{
- xmlSaveFormatFile(wpfile, wplist, 1);
+ g_autofree gchar *wpdir = NULL;
+ g_autofree gchar *wpfile = NULL;
+
+ wpdir = g_build_filename (g_get_user_config_dir(), "mate", NULL);
+ if (g_mkdir_with_parents (wpdir, 0700) == -1)
+ {
+ int errsv = errno;
+ g_warning ("failed, g_mkdir_with_parents(%s) failed: %s", wpdir, g_strerror (errsv));
+ }
+ else
+ {
+ wpfile = g_build_filename(wpdir, "backgrounds.xml", NULL);
+ xmlSaveFormatFile(wpfile, wplist, 1);
+ }
}
xmlFreeDoc(wplist);
- g_free(wpfile);
}