aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ephy-file-helpers.c
diff options
context:
space:
mode:
authorChristian Persch <chpe@cvs.gnome.org>2003-11-08 20:56:44 +0800
committerChristian Persch <chpe@src.gnome.org>2003-11-08 20:56:44 +0800
commit6b00de66025093218127fa74d9a423d58e377025 (patch)
treef2bee4a1f06f16128aa1a2e64da8023d882e1e58 /lib/ephy-file-helpers.c
parent5e5d25f08036ef3f2ac9af3071a36def13f5b2c6 (diff)
downloadgsoc2013-epiphany-6b00de66025093218127fa74d9a423d58e377025.tar
gsoc2013-epiphany-6b00de66025093218127fa74d9a423d58e377025.tar.gz
gsoc2013-epiphany-6b00de66025093218127fa74d9a423d58e377025.tar.bz2
gsoc2013-epiphany-6b00de66025093218127fa74d9a423d58e377025.tar.lz
gsoc2013-epiphany-6b00de66025093218127fa74d9a423d58e377025.tar.xz
gsoc2013-epiphany-6b00de66025093218127fa74d9a423d58e377025.tar.zst
gsoc2013-epiphany-6b00de66025093218127fa74d9a423d58e377025.zip
Port node db saving and RDF export to xml writer api.
2003-11-08 Christian Persch <chpe@cvs.gnome.org> * embed/ephy-favicon-cache.c: (ephy_favicon_cache_get_type), (ephy_favicon_cache_finalize): * embed/ephy-history.c: (ephy_history_save): * lib/ephy-file-helpers.c: (ephy_file_switch_temp_file): * lib/ephy-file-helpers.h: * lib/ephy-node-db.c: (ephy_node_db_load_from_file), (ephy_node_db_write_to_xml_valist), (ephy_node_db_write_to_xml_safe): * lib/ephy-node-db.h: * lib/ephy-node.c: (write_parent), (ephy_node_write_to_xml): * lib/ephy-node.h: * lib/ephy-state.c: (ephy_states_save), (ensure_states): * src/bookmarks/ephy-bookmarks-export.c: (write_topics_list), (ephy_bookmarks_export_rdf): * src/bookmarks/ephy-bookmarks.c: (ephy_bookmarks_save): Port node db saving and RDF export to xml writer api.
Diffstat (limited to 'lib/ephy-file-helpers.c')
-rw-r--r--lib/ephy-file-helpers.c32
1 files changed, 12 insertions, 20 deletions
diff --git a/lib/ephy-file-helpers.c b/lib/ephy-file-helpers.c
index 0d61f5bfc..1161f6ac7 100644
--- a/lib/ephy-file-helpers.c
+++ b/lib/ephy-file-helpers.c
@@ -190,41 +190,35 @@ ephy_file_find (const char *path,
}
gboolean
-ephy_file_save_xml (const char *xml_file, xmlDocPtr doc)
+ephy_file_switch_temp_file (const char *filename,
+ const char *filename_temp)
{
- char *tmp_file;
char *old_file;
gboolean old_exist;
gboolean retval = TRUE;
- tmp_file = g_strconcat (xml_file, ".tmp", NULL);
- old_file = g_strconcat (xml_file, ".old", NULL);
+ old_file = g_strconcat (filename, ".old", NULL);
- if (xmlSaveFormatFile (tmp_file, doc, 1) <= 0)
- {
- g_warning ("Failed to write XML data to %s", tmp_file);
- goto failed;
- }
-
- old_exist = g_file_test (xml_file, G_FILE_TEST_EXISTS);
+ old_exist = g_file_test (filename, G_FILE_TEST_EXISTS);
if (old_exist)
{
- if (rename (xml_file, old_file) < 0)
+ if (rename (filename, old_file) < 0)
{
- g_warning ("Failed to rename %s to %s", xml_file, old_file);
+ g_warning ("Failed to rename %s to %s", filename, old_file);
retval = FALSE;
goto failed;
}
}
- if (rename (tmp_file, xml_file) < 0)
+ if (rename (filename_temp, filename) < 0)
{
- g_warning ("Failed to rename %s to %s", tmp_file, xml_file);
+ g_warning ("Failed to rename %s to %s", filename_temp, filename);
- if (rename (old_file, xml_file) < 0)
+ if (rename (old_file, filename) < 0)
{
- g_warning ("Failed to restore %s from %s", xml_file, tmp_file);
+ g_warning ("Failed to restore %s from %s",
+ filename, filename_temp);
}
retval = FALSE;
goto failed;
@@ -238,10 +232,8 @@ ephy_file_save_xml (const char *xml_file, xmlDocPtr doc)
}
}
- failed:
+failed:
g_free (old_file);
- g_free (tmp_file);
return retval;
}
-