glib r6466 - in trunk: . gio
- From: chpe svn gnome org
- To: svn-commits-list gnome org
- Subject: glib r6466 - in trunk: . gio
- Date: Wed, 6 Feb 2008 15:10:09 +0000 (GMT)
Author: chpe
Date: Wed Feb 6 15:10:08 2008
New Revision: 6466
URL: http://svn.gnome.org/viewvc/glib?rev=6466&view=rev
Log:
* gio/gdesktopappinfo.c: (ensure_dir):
* gio/glocalfile.c: (g_local_file_query_filesystem_info),
(g_local_file_read), (g_local_file_delete), (g_local_file_trash),
(g_local_file_move):
* gio/glocalfileinfo.c: (set_xattr), (_g_local_file_info_get),
(_g_local_file_info_get_from_fd), (set_unix_mode),
(set_unix_uid_gid), (set_symlink), (set_mtime_atime):
* gio/glocalfileinputstream.c: (g_local_file_input_stream_read),
(g_local_file_input_stream_skip),
(g_local_file_input_stream_close),
(g_local_file_input_stream_seek):
* gio/glocalfileoutputstream.c:
(g_local_file_output_stream_write),
(g_local_file_output_stream_close),
(g_local_file_output_stream_seek),
(g_local_file_output_stream_truncate), (copy_file_data),
(handle_overwrite_open):
* gio/gunixinputstream.c: (g_unix_input_stream_read),
(g_unix_input_stream_close), (read_async_cb), (close_async_cb):
* gio/gunixoutputstream.c: (g_unix_output_stream_write),
(g_unix_output_stream_close), (write_async_cb), (close_async_cb):
Save
errno before calling other funcs that potentially alter it. Bug
#514766.
Modified:
trunk/ChangeLog
trunk/gio/gdesktopappinfo.c
trunk/gio/glocalfile.c
trunk/gio/glocalfileinfo.c
trunk/gio/glocalfileinputstream.c
trunk/gio/glocalfileoutputstream.c
trunk/gio/gunixinputstream.c
trunk/gio/gunixoutputstream.c
Modified: trunk/gio/gdesktopappinfo.c
==============================================================================
--- trunk/gio/gdesktopappinfo.c (original)
+++ trunk/gio/gdesktopappinfo.c Wed Feb 6 15:10:08 2008
@@ -1096,7 +1096,7 @@
GError **error)
{
char *path, *display_name;
- int err;
+ int errsv;
if (type == APP_DIR)
path = g_build_filename (g_get_user_data_dir (), "applications", NULL);
@@ -1107,16 +1107,16 @@
if (g_mkdir_with_parents (path, 0700) == 0)
return path;
- err = errno;
+ errsv = errno;
display_name = g_filename_display_name (path);
if (type == APP_DIR)
- g_set_error (error, G_IO_ERROR, g_io_error_from_errno (err),
+ g_set_error (error, G_IO_ERROR, g_io_error_from_errno (errsv),
_("Can't create user application configuration folder %s: %s"),
- display_name, g_strerror (err));
+ display_name, g_strerror (errsv));
else
- g_set_error (error, G_IO_ERROR, g_io_error_from_errno (err),
+ g_set_error (error, G_IO_ERROR, g_io_error_from_errno (errsv),
_("Can't create user MIME configuration folder %s: %s"),
- display_name, g_strerror (err));
+ display_name, g_strerror (errsv));
g_free (display_name);
g_free (path);
Modified: trunk/gio/glocalfile.c
==============================================================================
--- trunk/gio/glocalfile.c (original)
+++ trunk/gio/glocalfile.c Wed Feb 6 15:10:08 2008
@@ -840,10 +840,12 @@
if (statfs_result == -1)
{
+ int errsv = errno;
+
g_set_error (error, G_IO_ERROR,
- g_io_error_from_errno (errno),
+ g_io_error_from_errno (errsv),
_("Error getting filesystem info: %s"),
- g_strerror (errno));
+ g_strerror (errsv));
return NULL;
}
@@ -1110,10 +1112,12 @@
fd = g_open (local->filename, O_RDONLY, 0);
if (fd == -1)
{
+ int errsv = errno;
+
g_set_error (error, G_IO_ERROR,
- g_io_error_from_errno (errno),
+ g_io_error_from_errno (errsv),
_("Error opening file: %s"),
- g_strerror (errno));
+ g_strerror (errsv));
return NULL;
}
@@ -1172,10 +1176,12 @@
if (g_remove (local->filename) == -1)
{
+ int errsv = errno;
+
g_set_error (error, G_IO_ERROR,
- g_io_error_from_errno (errno),
+ g_io_error_from_errno (errsv),
_("Error removing file: %s"),
- g_strerror (errno));
+ g_strerror (errsv));
return FALSE;
}
@@ -1464,10 +1470,12 @@
if (g_lstat (local->filename, &file_stat) != 0)
{
+ int errsv = errno;
+
g_set_error (error, G_IO_ERROR,
- g_io_error_from_errno (errno),
+ g_io_error_from_errno (errsv),
_("Error trashing file: %s"),
- g_strerror (errno));
+ g_strerror (errsv));
return FALSE;
}
@@ -1484,14 +1492,13 @@
if (g_mkdir_with_parents (trashdir, 0700) < 0)
{
char *display_name;
- int err;
+ int errsv = errno;
- err = errno;
display_name = g_filename_display_name (trashdir);
g_set_error (error, G_IO_ERROR,
- g_io_error_from_errno (err),
+ g_io_error_from_errno (errsv),
_("Unable to create trash dir %s: %s"),
- display_name, g_strerror (err));
+ display_name, g_strerror (errsv));
g_free (display_name);
g_free (trashdir);
return FALSE;
@@ -1639,15 +1646,17 @@
if (fd == -1)
{
+ int errsv = errno;
+
g_free (filesdir);
g_free (topdir);
g_free (trashname);
g_free (infofile);
g_set_error (error, G_IO_ERROR,
- g_io_error_from_errno (errno),
+ g_io_error_from_errno (errsv),
_("Unable to create trashing info file: %s"),
- g_strerror (errno));
+ g_strerror (errsv));
return FALSE;
}
@@ -1662,15 +1671,17 @@
if (g_rename (local->filename, trashfile) == -1)
{
+ int errsv = errno;
+
g_free (topdir);
g_free (trashname);
g_free (infofile);
g_free (trashfile);
g_set_error (error, G_IO_ERROR,
- g_io_error_from_errno (errno),
+ g_io_error_from_errno (errsv),
_("Unable to trash file: %s"),
- g_strerror (errno));
+ g_strerror (errsv));
return FALSE;
}
@@ -1822,10 +1833,12 @@
res = g_lstat (local_source->filename, &statbuf);
if (res == -1)
{
+ int errsv = errno;
+
g_set_error (error, G_IO_ERROR,
- g_io_error_from_errno (errno),
+ g_io_error_from_errno (errsv),
_("Error moving file: %s"),
- g_strerror (errno));
+ g_strerror (errsv));
return FALSE;
}
else
@@ -1884,10 +1897,12 @@
res = unlink (local_destination->filename);
if (res == -1)
{
+ int errsv = errno;
+
g_set_error (error, G_IO_ERROR,
- g_io_error_from_errno (errno),
+ g_io_error_from_errno (errsv),
_("Error removing target file: %s"),
- g_strerror (errno));
+ g_strerror (errsv));
return FALSE;
}
}
Modified: trunk/gio/glocalfileinfo.c
==============================================================================
--- trunk/gio/glocalfileinfo.c (original)
+++ trunk/gio/glocalfileinfo.c Wed Feb 6 15:10:08 2008
@@ -759,7 +759,7 @@
g_set_error (error, G_IO_ERROR,
g_io_error_from_errno (errsv),
_("Error setting extended attribute '%s': %s"),
- escaped_attribute, g_strerror (errno));
+ escaped_attribute, g_strerror (errsv));
return FALSE;
}
@@ -1388,11 +1388,13 @@
res = g_lstat (path, &statbuf);
if (res == -1)
{
+ int errsv = errno;
+
g_object_unref (info);
g_set_error (error, G_IO_ERROR,
- g_io_error_from_errno (errno),
+ g_io_error_from_errno (errsv),
_("Error stating file '%s': %s"),
- path, g_strerror (errno));
+ path, g_strerror (errsv));
return NULL;
}
@@ -1619,10 +1621,12 @@
if (fstat (fd, &stat_buf) == -1)
{
+ int errsv = errno;
+
g_set_error (error, G_IO_ERROR,
- g_io_error_from_errno (errno),
+ g_io_error_from_errno (errsv),
_("Error stating file descriptor: %s"),
- g_strerror (errno));
+ g_strerror (errsv));
return NULL;
}
@@ -1723,10 +1727,12 @@
if (g_chmod (filename, val) == -1)
{
+ int errsv = errno;
+
g_set_error (error, G_IO_ERROR,
- g_io_error_from_errno (errno),
+ g_io_error_from_errno (errsv),
_("Error setting permissions: %s"),
- g_strerror (errno));
+ g_strerror (errsv));
return FALSE;
}
return TRUE;
@@ -1772,10 +1778,12 @@
if (res == -1)
{
+ int errsv = errno;
+
g_set_error (error, G_IO_ERROR,
- g_io_error_from_errno (errno),
+ g_io_error_from_errno (errsv),
_("Error setting owner: %s"),
- g_strerror (errno));
+ g_strerror (errsv));
return FALSE;
}
return TRUE;
@@ -1803,10 +1811,12 @@
if (g_lstat (filename, &statbuf))
{
+ int errsv = errno;
+
g_set_error (error, G_IO_ERROR,
- g_io_error_from_errno (errno),
+ g_io_error_from_errno (errsv),
_("Error setting symlink: %s"),
- g_strerror (errno));
+ g_strerror (errsv));
return FALSE;
}
@@ -1820,19 +1830,23 @@
if (g_unlink (filename))
{
+ int errsv = errno;
+
g_set_error (error, G_IO_ERROR,
- g_io_error_from_errno (errno),
+ g_io_error_from_errno (errsv),
_("Error setting symlink: %s"),
- g_strerror (errno));
+ g_strerror (errsv));
return FALSE;
}
if (symlink (filename, val) != 0)
{
+ int errsv = errno;
+
g_set_error (error, G_IO_ERROR,
- g_io_error_from_errno (errno),
+ g_io_error_from_errno (errsv),
_("Error setting symlink: %s"),
- g_strerror (errno));
+ g_strerror (errsv));
return FALSE;
}
@@ -1932,10 +1946,12 @@
res = utimes (filename, times);
if (res == -1)
{
+ int errsv = errno;
+
g_set_error (error, G_IO_ERROR,
- g_io_error_from_errno (errno),
+ g_io_error_from_errno (errsv),
_("Error setting owner: %s"),
- g_strerror (errno));
+ g_strerror (errsv));
return FALSE;
}
return TRUE;
Modified: trunk/gio/glocalfileinputstream.c
==============================================================================
--- trunk/gio/glocalfileinputstream.c (original)
+++ trunk/gio/glocalfileinputstream.c Wed Feb 6 15:10:08 2008
@@ -150,13 +150,15 @@
res = read (file->priv->fd, buffer, count);
if (res == -1)
{
- if (errno == EINTR)
+ int errsv = errno;
+
+ if (errsv == EINTR)
continue;
g_set_error (error, G_IO_ERROR,
- g_io_error_from_errno (errno),
+ g_io_error_from_errno (errsv),
_("Error reading from file: %s"),
- g_strerror (errno));
+ g_strerror (errsv));
}
break;
@@ -182,20 +184,24 @@
start = lseek (file->priv->fd, 0, SEEK_CUR);
if (start == -1)
{
+ int errsv = errno;
+
g_set_error (error, G_IO_ERROR,
- g_io_error_from_errno (errno),
+ g_io_error_from_errno (errsv),
_("Error seeking in file: %s"),
- g_strerror (errno));
+ g_strerror (errsv));
return -1;
}
res = lseek (file->priv->fd, count, SEEK_CUR);
if (res == -1)
{
+ int errsv = errno;
+
g_set_error (error, G_IO_ERROR,
- g_io_error_from_errno (errno),
+ g_io_error_from_errno (errsv),
_("Error seeking in file: %s"),
- g_strerror (errno));
+ g_strerror (errsv));
return -1;
}
@@ -219,10 +225,14 @@
{
res = close (file->priv->fd);
if (res == -1)
- g_set_error (error, G_IO_ERROR,
- g_io_error_from_errno (errno),
- _("Error closing file: %s"),
- g_strerror (errno));
+ {
+ int errsv = errno;
+
+ g_set_error (error, G_IO_ERROR,
+ g_io_error_from_errno (errsv),
+ _("Error closing file: %s"),
+ g_strerror (errsv));
+ }
break;
}
@@ -295,10 +305,12 @@
if (pos == (off_t)-1)
{
+ int errsv = errno;
+
g_set_error (error, G_IO_ERROR,
- g_io_error_from_errno (errno),
+ g_io_error_from_errno (errsv),
_("Error seeking in file: %s"),
- g_strerror (errno));
+ g_strerror (errsv));
return FALSE;
}
Modified: trunk/gio/glocalfileoutputstream.c
==============================================================================
--- trunk/gio/glocalfileoutputstream.c (original)
+++ trunk/gio/glocalfileoutputstream.c Wed Feb 6 15:10:08 2008
@@ -158,13 +158,15 @@
res = write (file->priv->fd, buffer, count);
if (res == -1)
{
- if (errno == EINTR)
+ int errsv = errno;
+
+ if (errsv == EINTR)
continue;
g_set_error (error, G_IO_ERROR,
- g_io_error_from_errno (errno),
+ g_io_error_from_errno (errsv),
_("Error writing to file: %s"),
- g_strerror (errno));
+ g_strerror (errsv));
}
break;
@@ -200,10 +202,12 @@
if (unlink (file->priv->backup_filename) != 0 &&
errno != ENOENT)
{
+ int errsv = errno;
+
g_set_error (error, G_IO_ERROR,
G_IO_ERROR_CANT_CREATE_BACKUP,
_("Error removing old backup link: %s"),
- g_strerror (errno));
+ g_strerror (errsv));
goto err_out;
}
@@ -212,10 +216,12 @@
/* link failed or is not supported, try rename */
if (rename (file->priv->original_filename, file->priv->backup_filename) != 0)
{
+ int errsv = errno;
+
g_set_error (error, G_IO_ERROR,
G_IO_ERROR_CANT_CREATE_BACKUP,
_("Error creating backup copy: %s"),
- g_strerror (errno));
+ g_strerror (errsv));
goto err_out;
}
}
@@ -223,10 +229,12 @@
/* If link not supported, just rename... */
if (rename (file->priv->original_filename, file->priv->backup_filename) != 0)
{
+ int errsv = errno;
+
g_set_error (error, G_IO_ERROR,
G_IO_ERROR_CANT_CREATE_BACKUP,
_("Error creating backup copy: %s"),
- g_strerror (errno));
+ g_strerror (errsv));
goto err_out;
}
#endif
@@ -239,10 +247,12 @@
/* tmp -> original */
if (rename (file->priv->tmp_filename, file->priv->original_filename) != 0)
{
+ int errsv = errno;
+
g_set_error (error, G_IO_ERROR,
g_io_error_from_errno (errno),
_("Error renaming temporary file: %s"),
- g_strerror (errno));
+ g_strerror (errsv));
goto err_out;
}
}
@@ -258,10 +268,12 @@
res = close (file->priv->fd);
if (res == -1)
{
+ int errsv = errno;
+
g_set_error (error, G_IO_ERROR,
- g_io_error_from_errno (errno),
+ g_io_error_from_errno (errsv),
_("Error closing file: %s"),
- g_strerror (errno));
+ g_strerror (errsv));
}
break;
}
@@ -349,10 +361,12 @@
if (pos == (off_t)-1)
{
+ int errsv = errno;
+
g_set_error (error, G_IO_ERROR,
- g_io_error_from_errno (errno),
+ g_io_error_from_errno (errsv),
_("Error seeking in file: %s"),
- g_strerror (errno));
+ g_strerror (errsv));
return FALSE;
}
@@ -386,7 +400,9 @@
if (res == -1)
{
- if (errno == EINTR)
+ int errsv = errno;
+
+ if (errsv == EINTR)
{
if (g_cancellable_set_error_if_cancelled (cancellable, error))
return FALSE;
@@ -394,9 +410,9 @@
}
g_set_error (error, G_IO_ERROR,
- g_io_error_from_errno (errno),
+ g_io_error_from_errno (errsv),
_("Error truncating file: %s"),
- g_strerror (errno));
+ g_strerror (errsv));
return FALSE;
}
@@ -532,13 +548,15 @@
bytes_read = read (sfd, buffer, BUFSIZE);
if (bytes_read == -1)
{
- if (errno == EINTR)
+ int errsv = errno;
+
+ if (errsv == EINTR)
continue;
g_set_error (error, G_IO_ERROR,
- g_io_error_from_errno (errno),
+ g_io_error_from_errno (errsv),
_("Error reading from file: %s"),
- g_strerror (errno));
+ g_strerror (errsv));
ret = FALSE;
break;
}
@@ -551,13 +569,15 @@
bytes_written = write (dfd, write_buffer, bytes_to_write);
if (bytes_written == -1)
{
- if (errno == EINTR)
+ int errsv = errno;
+
+ if (errsv == EINTR)
continue;
g_set_error (error, G_IO_ERROR,
- g_io_error_from_errno (errno),
+ g_io_error_from_errno (errsv),
_("Error writing to file: %s"),
- g_strerror (errno));
+ g_strerror (errsv));
ret = FALSE;
break;
}
@@ -615,19 +635,23 @@
if (fd == -1)
{
+ int errsv = errno;
+
g_set_error (error, G_IO_ERROR,
- g_io_error_from_errno (errno),
+ g_io_error_from_errno (errsv),
_("Error opening file '%s': %s"),
- filename, g_strerror (errno));
+ filename, g_strerror (errsv));
return -1;
}
if (fstat (fd, &original_stat) != 0)
{
+ int errsv = errno;
+
g_set_error (error, G_IO_ERROR,
- g_io_error_from_errno (errno),
+ g_io_error_from_errno (errsv),
_("Error stating file '%s': %s"),
- filename, g_strerror (errno));
+ filename, g_strerror (errsv));
goto err_out;
}
@@ -809,10 +833,12 @@
/* Seek back to the start of the file after the backup copy */
if (lseek (fd, 0, SEEK_SET) == -1)
{
+ int errsv = errno;
+
g_set_error (error, G_IO_ERROR,
- g_io_error_from_errno (errno),
+ g_io_error_from_errno (errsv),
_("Error seeking in file: %s"),
- g_strerror (errno));
+ g_strerror (errsv));
goto err_out;
}
}
@@ -824,10 +850,12 @@
if (ftruncate (fd, 0) == -1)
#endif
{
+ int errsv = errno;
+
g_set_error (error, G_IO_ERROR,
- g_io_error_from_errno (errno),
+ g_io_error_from_errno (errsv),
_("Error truncating file: %s"),
- g_strerror (errno));
+ g_strerror (errsv));
goto err_out;
}
Modified: trunk/gio/gunixinputstream.c
==============================================================================
--- trunk/gio/gunixinputstream.c (original)
+++ trunk/gio/gunixinputstream.c Wed Feb 6 15:10:08 2008
@@ -195,10 +195,12 @@
if (poll_ret == -1)
{
+ int errsv = errno;
+
g_set_error (error, G_IO_ERROR,
- g_io_error_from_errno (errno),
+ g_io_error_from_errno (errsv),
_("Error reading from unix: %s"),
- g_strerror (errno));
+ g_strerror (errsv));
return -1;
}
}
@@ -210,13 +212,15 @@
res = read (unix_stream->priv->fd, buffer, count);
if (res == -1)
{
- if (errno == EINTR)
+ int errsv = errno;
+
+ if (errsv == EINTR)
continue;
g_set_error (error, G_IO_ERROR,
- g_io_error_from_errno (errno),
+ g_io_error_from_errno (errsv),
_("Error reading from unix: %s"),
- g_strerror (errno));
+ g_strerror (errsv));
}
break;
@@ -243,10 +247,14 @@
/* This might block during the close. Doesn't seem to be a way to avoid it though. */
res = close (unix_stream->priv->fd);
if (res == -1)
- g_set_error (error, G_IO_ERROR,
- g_io_error_from_errno (errno),
- _("Error closing unix: %s"),
- g_strerror (errno));
+ {
+ int errsv = errno;
+
+ g_set_error (error, G_IO_ERROR,
+ g_io_error_from_errno (errsv),
+ _("Error closing unix: %s"),
+ g_strerror (errsv));
+ }
break;
}
@@ -282,13 +290,15 @@
count_read = read (data->stream->priv->fd, data->buffer, data->count);
if (count_read == -1)
{
- if (errno == EINTR)
+ int errsv = errno;
+
+ if (errsv == EINTR)
continue;
g_set_error (&error, G_IO_ERROR,
- g_io_error_from_errno (errno),
+ g_io_error_from_errno (errsv),
_("Error reading from unix: %s"),
- g_strerror (errno));
+ g_strerror (errsv));
}
break;
}
@@ -419,10 +429,14 @@
{
res = close (unix_stream->priv->fd);
if (res == -1)
- g_set_error (&error, G_IO_ERROR,
- g_io_error_from_errno (errno),
- _("Error closing unix: %s"),
- g_strerror (errno));
+ {
+ int errsv = errno;
+
+ g_set_error (&error, G_IO_ERROR,
+ g_io_error_from_errno (errsv),
+ _("Error closing unix: %s"),
+ g_strerror (errsv));
+ }
break;
}
Modified: trunk/gio/gunixoutputstream.c
==============================================================================
--- trunk/gio/gunixoutputstream.c (original)
+++ trunk/gio/gunixoutputstream.c Wed Feb 6 15:10:08 2008
@@ -183,10 +183,12 @@
if (poll_ret == -1)
{
+ int errsv = errno;
+
g_set_error (error, G_IO_ERROR,
- g_io_error_from_errno (errno),
+ g_io_error_from_errno (errsv),
_("Error writing to unix: %s"),
- g_strerror (errno));
+ g_strerror (errsv));
return -1;
}
}
@@ -199,13 +201,15 @@
res = write (unix_stream->priv->fd, buffer, count);
if (res == -1)
{
- if (errno == EINTR)
+ int errsv = errno;
+
+ if (errsv == EINTR)
continue;
g_set_error (error, G_IO_ERROR,
- g_io_error_from_errno (errno),
+ g_io_error_from_errno (errsv),
_("Error writing to unix: %s"),
- g_strerror (errno));
+ g_strerror (errsv));
}
break;
@@ -233,10 +237,12 @@
res = close (unix_stream->priv->fd);
if (res == -1)
{
+ int errsv = errno;
+
g_set_error (error, G_IO_ERROR,
- g_io_error_from_errno (errno),
+ g_io_error_from_errno (errsv),
_("Error closing unix: %s"),
- g_strerror (errno));
+ g_strerror (errsv));
}
break;
}
@@ -273,13 +279,15 @@
count_written = write (data->stream->priv->fd, data->buffer, data->count);
if (count_written == -1)
{
- if (errno == EINTR)
+ int errsv = errno;
+
+ if (errsv == EINTR)
continue;
g_set_error (&error, G_IO_ERROR,
- g_io_error_from_errno (errno),
+ g_io_error_from_errno (errsv),
_("Error reading from unix: %s"),
- g_strerror (errno));
+ g_strerror (errsv));
}
break;
}
@@ -380,10 +388,12 @@
res = close (unix_stream->priv->fd);
if (res == -1)
{
+ int errsv = errno;
+
g_set_error (&error, G_IO_ERROR,
- g_io_error_from_errno (errno),
+ g_io_error_from_errno (errsv),
_("Error closing unix: %s"),
- g_strerror (errno));
+ g_strerror (errsv));
}
break;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]