[latexila] BuildToolsPersonal: create parent directories before saving file
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [latexila] BuildToolsPersonal: create parent directories before saving file
- Date: Tue, 18 Aug 2015 09:35:36 +0000 (UTC)
commit 181f3e89268dd5c72a1a7046e1fd213aabf4ff1b
Author: Sébastien Wilmet <swilmet gnome org>
Date: Tue Aug 18 11:32:01 2015 +0200
BuildToolsPersonal: create parent directories before saving file
https://bugzilla.redhat.com/show_bug.cgi?id=1241825
src/liblatexila/latexila-build-tools-personal.c | 43 +++++++++++++++--------
1 files changed, 28 insertions(+), 15 deletions(-)
---
diff --git a/src/liblatexila/latexila-build-tools-personal.c b/src/liblatexila/latexila-build-tools-personal.c
index bb7d76b..4ce917a 100644
--- a/src/liblatexila/latexila-build-tools-personal.c
+++ b/src/liblatexila/latexila-build-tools-personal.c
@@ -30,6 +30,7 @@
#include "latexila-build-tools-personal.h"
#include <gio/gio.h>
#include "latexila-build-tool.h"
+#include "latexila-utils.h"
struct _LatexilaBuildToolsPersonalPrivate
{
@@ -161,6 +162,7 @@ latexila_build_tools_personal_save (LatexilaBuildToolsPersonal *build_tools)
GString *contents;
GList *cur_build_tool;
GFile *xml_file;
+ GError *error = NULL;
g_return_if_fail (LATEXILA_IS_BUILD_TOOLS_PERSONAL (build_tools));
@@ -184,23 +186,34 @@ latexila_build_tools_personal_save (LatexilaBuildToolsPersonal *build_tools)
g_string_append (contents, "</tools>\n");
- /* Avoid finalization of build_tools during the async operation. And keep the
- * application running.
- */
- g_object_ref (build_tools);
- g_application_hold (g_application_get_default ());
-
xml_file = get_xml_file ();
- g_file_replace_contents_async (xml_file,
- contents->str,
- contents->len,
- NULL,
- TRUE, /* make a backup */
- G_FILE_CREATE_NONE,
- NULL,
- (GAsyncReadyCallback) save_cb,
- build_tools);
+ latexila_utils_create_parent_directories (xml_file, &error);
+
+ if (error == NULL)
+ {
+ /* Avoid finalization of build_tools during the async operation. And keep the
+ * application running.
+ */
+ g_object_ref (build_tools);
+ g_application_hold (g_application_get_default ());
+
+ g_file_replace_contents_async (xml_file,
+ contents->str,
+ contents->len,
+ NULL,
+ TRUE, /* make a backup */
+ G_FILE_CREATE_NONE,
+ NULL,
+ (GAsyncReadyCallback) save_cb,
+ build_tools);
+ }
+ else
+ {
+ g_warning ("Error while saving the personal build tools: %s",
+ error->message);
+ g_error_free (error);
+ }
g_object_unref (xml_file);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]