From: Tomas Bzatek Date: Wed, 6 Feb 2008 13:45:26 +0000 (+0000) Subject: Fallback to rename() if link() is not available (when no support on target X-Git-Url: http://git.openbox.org/?a=commitdiff_plain;h=c907c2832e0499491a10936c5dbea8b0f9b5b0b7;p=dana%2Fcg-glib.git 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 --- diff --git a/gio/ChangeLog b/gio/ChangeLog index 7534e949..6f05953f 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 38def658..c0888576 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,