Preserve errno, and always use g_strerror()

Bug #592461.
This commit is contained in:
Christian Persch
2009-08-20 15:32:22 +02:00
parent a79f929dd6
commit e8dcf330cc
4 changed files with 27 additions and 11 deletions

View File

@ -220,7 +220,7 @@ gif_read (GifContext *context, guchar *buffer, size_t len)
G_FILE_ERROR, G_FILE_ERROR,
g_file_error_from_errno (save_errno), g_file_error_from_errno (save_errno),
_("Failure reading GIF: %s"), _("Failure reading GIF: %s"),
strerror (save_errno)); g_strerror (save_errno));
} }
#ifdef IO_GIFDEBUG #ifdef IO_GIFDEBUG

View File

@ -1355,8 +1355,10 @@ gtk_file_selection_create_dir_confirmed (GtkWidget *widget,
if (g_mkdir (sys_full_path, 0777) < 0) if (g_mkdir (sys_full_path, 0777) < 0)
{ {
int errsv = errno;
buf = g_strdup_printf (_("Error creating folder '%s': %s"), buf = g_strdup_printf (_("Error creating folder '%s': %s"),
dirname, g_strerror (errno)); dirname, g_strerror (errsv));
gtk_file_selection_fileop_error (fs, buf); gtk_file_selection_fileop_error (fs, buf);
} }
@ -1484,8 +1486,10 @@ gtk_file_selection_delete_file_response (GtkDialog *dialog,
if (g_unlink (sys_full_path) < 0) if (g_unlink (sys_full_path) < 0)
{ {
int errsv = errno;
buf = g_strdup_printf (_("Error deleting file '%s': %s"), buf = g_strdup_printf (_("Error deleting file '%s': %s"),
fs->fileop_file, g_strerror (errno)); fs->fileop_file, g_strerror (errsv));
gtk_file_selection_fileop_error (fs, buf); gtk_file_selection_fileop_error (fs, buf);
} }
@ -1602,9 +1606,11 @@ gtk_file_selection_rename_file_confirmed (GtkWidget *widget,
if (g_rename (sys_old_filename, sys_new_filename) < 0) if (g_rename (sys_old_filename, sys_new_filename) < 0)
{ {
int errsv = errno;
buf = g_strdup_printf (_("Error renaming file \"%s\" to \"%s\": %s"), buf = g_strdup_printf (_("Error renaming file \"%s\" to \"%s\": %s"),
sys_old_filename, sys_new_filename, sys_old_filename, sys_new_filename,
g_strerror (errno)); g_strerror (errsv));
gtk_file_selection_fileop_error (fs, buf); gtk_file_selection_fileop_error (fs, buf);
goto out2; goto out2;
} }

View File

@ -952,6 +952,8 @@ _gtk_mount_operation_kill_process (GPid pid,
if (kill ((pid_t) pid, SIGTERM) != 0) if (kill ((pid_t) pid, SIGTERM) != 0)
{ {
int errsv = errno;
/* TODO: On EPERM, we could use a setuid helper using polkit (very easy to implement /* TODO: On EPERM, we could use a setuid helper using polkit (very easy to implement
* via pkexec(1)) to allow the user to e.g. authenticate to gain the authorization * via pkexec(1)) to allow the user to e.g. authenticate to gain the authorization
* to kill the process. But that's not how things currently work. * to kill the process. But that's not how things currently work.
@ -960,10 +962,10 @@ _gtk_mount_operation_kill_process (GPid pid,
ret = FALSE; ret = FALSE;
g_set_error (error, g_set_error (error,
G_IO_ERROR, G_IO_ERROR,
g_io_error_from_errno (errno), g_io_error_from_errno (errsv),
_("Cannot end process with pid %d: %s"), _("Cannot end process with pid %d: %s"),
pid, pid,
strerror (errno)); g_strerror (errsv));
} }
return ret; return ret;

View File

@ -1516,9 +1516,11 @@ opentmp:
g_unlink (bak_cache_path); g_unlink (bak_cache_path);
if (g_rename (cache_path, bak_cache_path) == -1) if (g_rename (cache_path, bak_cache_path) == -1)
{ {
int errsv = errno;
g_printerr (_("Could not rename %s to %s: %s, removing %s then.\n"), g_printerr (_("Could not rename %s to %s: %s, removing %s then.\n"),
cache_path, bak_cache_path, cache_path, bak_cache_path,
g_strerror (errno), g_strerror (errsv),
cache_path); cache_path);
g_unlink (cache_path); g_unlink (cache_path);
bak_cache_path = NULL; bak_cache_path = NULL;
@ -1528,16 +1530,22 @@ opentmp:
if (g_rename (tmp_cache_path, cache_path) == -1) if (g_rename (tmp_cache_path, cache_path) == -1)
{ {
int errsv = errno;
g_printerr (_("Could not rename %s to %s: %s\n"), g_printerr (_("Could not rename %s to %s: %s\n"),
tmp_cache_path, cache_path, tmp_cache_path, cache_path,
g_strerror (errno)); g_strerror (errsv));
g_unlink (tmp_cache_path); g_unlink (tmp_cache_path);
#ifdef G_OS_WIN32 #ifdef G_OS_WIN32
if (bak_cache_path != NULL) if (bak_cache_path != NULL)
if (g_rename (bak_cache_path, cache_path) == -1) if (g_rename (bak_cache_path, cache_path) == -1)
g_printerr (_("Could not rename %s back to %s: %s.\n"), {
bak_cache_path, cache_path, errsv = errno;
g_strerror (errno));
g_printerr (_("Could not rename %s back to %s: %s.\n"),
bak_cache_path, cache_path,
g_strerror (errsv));
}
#endif #endif
exit (1); exit (1);
} }