From 858107437bdeea5dd72e509addf93a5bf5277116 Mon Sep 17 00:00:00 2001 From: Soeren Sandmann Date: Sat, 12 Mar 2005 05:45:32 +0000 Subject: [PATCH] Don't try and generate a dotfile from the name -- it doesn't work with Fri Mar 11 23:51:12 2005 Soeren Sandmann * glib/gfileutils.c (write_to_temp_file): Don't try and generate a dotfile from the name -- it doesn't work with absolute paths. Also make documentation indicate that symlinks will be overwritten. Both pointed out by Alexis S. L. Carvalho. --- ChangeLog | 7 +++++++ ChangeLog.pre-2-10 | 7 +++++++ ChangeLog.pre-2-12 | 7 +++++++ ChangeLog.pre-2-8 | 7 +++++++ glib/gfileutils.c | 10 ++++++---- 5 files changed, 34 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 30ceb089c..bbd85e801 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Fri Mar 11 23:51:12 2005 Soeren Sandmann + + * glib/gfileutils.c (write_to_temp_file): Don't try and generate + a dotfile from the name -- it doesn't work with absolute + paths. Also make documentation indicate that symlinks will be + overwritten. Both pointed out by Alexis S. L. Carvalho. + 2005-03-11 Matthias Clasen * m4macros/glib-gettext.m4: Avoid stupid compiler complaints diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 30ceb089c..bbd85e801 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,10 @@ +Fri Mar 11 23:51:12 2005 Soeren Sandmann + + * glib/gfileutils.c (write_to_temp_file): Don't try and generate + a dotfile from the name -- it doesn't work with absolute + paths. Also make documentation indicate that symlinks will be + overwritten. Both pointed out by Alexis S. L. Carvalho. + 2005-03-11 Matthias Clasen * m4macros/glib-gettext.m4: Avoid stupid compiler complaints diff --git a/ChangeLog.pre-2-12 b/ChangeLog.pre-2-12 index 30ceb089c..bbd85e801 100644 --- a/ChangeLog.pre-2-12 +++ b/ChangeLog.pre-2-12 @@ -1,3 +1,10 @@ +Fri Mar 11 23:51:12 2005 Soeren Sandmann + + * glib/gfileutils.c (write_to_temp_file): Don't try and generate + a dotfile from the name -- it doesn't work with absolute + paths. Also make documentation indicate that symlinks will be + overwritten. Both pointed out by Alexis S. L. Carvalho. + 2005-03-11 Matthias Clasen * m4macros/glib-gettext.m4: Avoid stupid compiler complaints diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 30ceb089c..bbd85e801 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,10 @@ +Fri Mar 11 23:51:12 2005 Soeren Sandmann + + * glib/gfileutils.c (write_to_temp_file): Don't try and generate + a dotfile from the name -- it doesn't work with absolute + paths. Also make documentation indicate that symlinks will be + overwritten. Both pointed out by Alexis S. L. Carvalho. + 2005-03-11 Matthias Clasen * m4macros/glib-gettext.m4: Avoid stupid compiler complaints diff --git a/glib/gfileutils.c b/glib/gfileutils.c index 415d6fed0..f9f675617 100644 --- a/glib/gfileutils.c +++ b/glib/gfileutils.c @@ -841,7 +841,7 @@ rename_file (const char *old_name, static gchar * write_to_temp_file (const gchar *contents, - gsize length, + gssize length, const gchar *template, GError **err) { @@ -854,7 +854,7 @@ write_to_temp_file (const gchar *contents, retval = NULL; - tmp_name = g_strdup_printf (".%s.XXXXXX", template); + tmp_name = g_strdup_printf ("%s.XXXXXX", template); errno = 0; fd = g_mkstemp (tmp_name); @@ -954,7 +954,8 @@ write_to_temp_file (const gchar *contents, * * On Unix, if @filename already exists hard links to @filename will break. * Also since the file is recreated, existing permissions, access control - * lists, metadata etc. may be lost. + * lists, metadata etc. may be lost. If @filename is a symbolic link, + * the link itself will be replaced, not the linked file. * * * On Windows renaming a file will not remove an existing file with the @@ -989,7 +990,8 @@ g_file_replace (const gchar *filename, g_return_val_if_fail (filename != NULL, FALSE); g_return_val_if_fail (error == NULL || *error == NULL, FALSE); g_return_val_if_fail (contents != NULL || length == 0, FALSE); - + g_return_val_if_fail (length >= -1, FALSE); + if (length == -1) length = strlen (contents);