diff options
author | Jeffrey Stedfast <fejj@ximian.com> | 2002-08-07 04:31:40 +0800 |
---|---|---|
committer | Jeffrey Stedfast <fejj@src.gnome.org> | 2002-08-07 04:31:40 +0800 |
commit | 71eabe9f8c8c6a31f26cd1a02d1f49612bc46f38 (patch) | |
tree | b607d2de6baa67786a11caa320d4991ac258472c /widgets/table/e-table-specification.c | |
parent | eb83dd4dd0cc797f1a83fbcd99a41cb4723a0e51 (diff) | |
download | gsoc2013-evolution-71eabe9f8c8c6a31f26cd1a02d1f49612bc46f38.tar gsoc2013-evolution-71eabe9f8c8c6a31f26cd1a02d1f49612bc46f38.tar.gz gsoc2013-evolution-71eabe9f8c8c6a31f26cd1a02d1f49612bc46f38.tar.bz2 gsoc2013-evolution-71eabe9f8c8c6a31f26cd1a02d1f49612bc46f38.tar.lz gsoc2013-evolution-71eabe9f8c8c6a31f26cd1a02d1f49612bc46f38.tar.xz gsoc2013-evolution-71eabe9f8c8c6a31f26cd1a02d1f49612bc46f38.tar.zst gsoc2013-evolution-71eabe9f8c8c6a31f26cd1a02d1f49612bc46f38.zip |
#include <string.h> for memset
2002-08-06 Jeffrey Stedfast <fejj@ximian.com>
* e-cell-progress.c: #include <string.h> for memset
* e-table.c (e_table_save_specification): Updated to use
e_xml_save_file() instead of xmlSaveFile(). Also fixed to save to
a tmp file first.
* e-table-specification.c (e_table_specification_save_to_file):
Same as above.
* e-table-state.c (e_table_state_save_to_file): Same here.
* e-tree-table-adapter.c
(e_tree_table_adapter_save_expanded_state): And here too.
svn path=/trunk/; revision=17717
Diffstat (limited to 'widgets/table/e-table-specification.c')
-rw-r--r-- | widgets/table/e-table-specification.c | 37 |
1 files changed, 33 insertions, 4 deletions
diff --git a/widgets/table/e-table-specification.c b/widgets/table/e-table-specification.c index 4c04d78c80..92f8b42921 100644 --- a/widgets/table/e-table-specification.c +++ b/widgets/table/e-table-specification.c @@ -21,12 +21,18 @@ * 02111-1307, USA. */ +#ifdef HAVE_CONFIG_H #include <config.h> +#endif #include "e-table-specification.h" +#include <stdio.h> #include <stdlib.h> #include <string.h> +#include <unistd.h> +#include <errno.h> + #include <gtk/gtksignal.h> #include <gnome-xml/parser.h> #include <gnome-xml/xmlmemory.h> @@ -272,21 +278,44 @@ e_table_specification_load_from_node (ETableSpecification *specification, * * This routine stores the @specification into @filename. * - * Returns: the number of bytes written or -1 on error. + * Returns: 0 on success or -1 on error. */ int e_table_specification_save_to_file (ETableSpecification *specification, const char *filename) { + char *tmp, *slash; xmlDoc *doc; - + int ret; + g_return_val_if_fail (specification != NULL, -1); g_return_val_if_fail (filename != NULL, -1); g_return_val_if_fail (E_IS_TABLE_SPECIFICATION (specification), -1); - doc = xmlNewDoc ("1.0"); + if ((doc = xmlNewDoc ("1.0")) == NULL) { + errno = ENOMEM; + return -1; + } + xmlDocSetRootElement (doc, e_table_specification_save_to_node (specification, doc)); - return xmlSaveFile (filename, doc); + + tmp = alloca (strlen (filename) + 5); + slash = strrchr (filename, '/'); + if (slash) + sprintf (tmp, "%.*s.#%s", slash - filename + 1, filename, slash + 1); + else + sprintf (tmp, ".#%s", filename); + + ret = e_xml_save_file (tmp, doc); + if (ret != -1) + ret = rename (tmp, filename); + + if (ret == -1) + unlink (tmp); + + xmlFreeDoc (doc); + + return ret; } /** |