From c907c2832e0499491a10936c5dbea8b0f9b5b0b7 Mon Sep 17 00:00:00 2001 From: Tomas Bzatek Date: Wed, 6 Feb 2008 13:45:26 +0000 Subject: [PATCH] Fallback to rename() if link() is not available (when no support on target 2008-02-06 Tomas Bzatek * glocalfileoutputstream.c (g_local_file_output_stream_close): Fallback to rename() if link() is not available (when no support on target filesystem) svn path=/trunk/; revision=6464 --- gio/ChangeLog | 6 ++++++ gio/glocalfileoutputstream.c | 16 ++++++++++------ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/gio/ChangeLog b/gio/ChangeLog index 7534e9494..6f05953f4 100644 --- a/gio/ChangeLog +++ b/gio/ChangeLog @@ -1,3 +1,9 @@ +2008-02-06 Tomas Bzatek + + * glocalfileoutputstream.c (g_local_file_output_stream_close): + Fallback to rename() if link() is not available + (when no support on target filesystem) + 2008-02-06 Michael Natterer * gfileinfo.c (g_file_info_get_icon): replace diff --git a/gio/glocalfileoutputstream.c b/gio/glocalfileoutputstream.c index 38def6583..c0888576b 100644 --- a/gio/glocalfileoutputstream.c +++ b/gio/glocalfileoutputstream.c @@ -209,15 +209,19 @@ g_local_file_output_stream_close (GOutputStream *stream, if (link (file->priv->original_filename, file->priv->backup_filename) != 0) { - g_set_error (error, G_IO_ERROR, - G_IO_ERROR_CANT_CREATE_BACKUP, - _("Error creating backup link: %s"), - g_strerror (errno)); - goto err_out; + /* link failed or is not supported, try rename */ + if (rename (file->priv->original_filename, file->priv->backup_filename) != 0) + { + g_set_error (error, G_IO_ERROR, + G_IO_ERROR_CANT_CREATE_BACKUP, + _("Error creating backup copy: %s"), + g_strerror (errno)); + goto err_out; + } } #else /* If link not supported, just rename... */ - if (!rename (file->priv->original_filename, file->priv->backup_filename) != 0) + if (rename (file->priv->original_filename, file->priv->backup_filename) != 0) { g_set_error (error, G_IO_ERROR, G_IO_ERROR_CANT_CREATE_BACKUP,