Fallback to rename() if link() is not available (when no support on target

2008-02-06  Tomas Bzatek  <tbzatek@redhat.com> 

        * 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
This commit is contained in:
Tomas Bzatek 2008-02-06 13:45:26 +00:00 committed by Tomas Bzatek
parent 2b02891ef7
commit c907c2832e
2 changed files with 16 additions and 6 deletions

View File

@ -1,3 +1,9 @@
2008-02-06 Tomas Bzatek <tbzatek@redhat.com>
* 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 <mitch@imendio.com>
* gfileinfo.c (g_file_info_get_icon): replace

View File

@ -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,