From ef4d522b9b6d8be56f25d730401dad3e61e19cd7 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 30 Sep 2008 20:40:31 +0000 Subject: [PATCH] =?utf8?q?Bug=20554092=20=E2=80=93=20glib=20doesn't=20retu?= =?utf8?q?rn=20G=5FFILE=5FERROR=5FNOENT=20et=20al=20on=20OS=20X?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 2008-09-30 Behdad Esfahbod Bug 554092 – glib doesn't return G_FILE_ERROR_NOENT et al on OS X * glib/giounix.c (g_io_unix_read), (g_io_unix_write), (g_io_unix_seek), (g_io_unix_close), (g_io_unix_set_flags), (g_io_unix_get_flags), (g_io_channel_new_file): Like mclasen says: "well, thats the way errno works..., save it or loose it". Save errno. svn path=/trunk/; revision=7565 --- ChangeLog | 10 ++++++++++ glib/giounix.c | 42 +++++++++++++++++++++++++----------------- 2 files changed, 35 insertions(+), 17 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5496d819..e568dd0d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2008-09-30 Behdad Esfahbod + + Bug 554092 – glib doesn't return G_FILE_ERROR_NOENT et al on OS X + + * glib/giounix.c (g_io_unix_read), (g_io_unix_write), + (g_io_unix_seek), (g_io_unix_close), (g_io_unix_set_flags), + (g_io_unix_get_flags), (g_io_channel_new_file): + Like mclasen says: "well, thats the way errno works..., + save it or loose it". Save errno. + 2008-09-30 Tor Lillqvist * Makefile.decl diff --git a/glib/giounix.c b/glib/giounix.c index e7449b85..8045910e 100644 --- a/glib/giounix.c +++ b/glib/giounix.c @@ -190,9 +190,10 @@ g_io_unix_read (GIOChannel *channel, if (result < 0) { + int err = errno; *bytes_read = 0; - switch (errno) + switch (err) { #ifdef EINTR case EINTR: @@ -204,8 +205,8 @@ g_io_unix_read (GIOChannel *channel, #endif default: g_set_error_literal (err, G_IO_CHANNEL_ERROR, - g_io_channel_error_from_errno (errno), - g_strerror (errno)); + g_io_channel_error_from_errno (err), + g_strerror (err)); return G_IO_STATUS_ERROR; } } @@ -230,9 +231,10 @@ g_io_unix_write (GIOChannel *channel, if (result < 0) { + int err = errno; *bytes_written = 0; - switch (errno) + switch (err) { #ifdef EINTR case EINTR: @@ -244,8 +246,8 @@ g_io_unix_write (GIOChannel *channel, #endif default: g_set_error_literal (err, G_IO_CHANNEL_ERROR, - g_io_channel_error_from_errno (errno), - g_strerror (errno)); + g_io_channel_error_from_errno (err), + g_strerror (err)); return G_IO_STATUS_ERROR; } } @@ -295,9 +297,10 @@ g_io_unix_seek (GIOChannel *channel, if (result < 0) { + int err = errno; g_set_error_literal (err, G_IO_CHANNEL_ERROR, - g_io_channel_error_from_errno (errno), - g_strerror (errno)); + g_io_channel_error_from_errno (err), + g_strerror (err)); return G_IO_STATUS_ERROR; } @@ -313,9 +316,10 @@ g_io_unix_close (GIOChannel *channel, if (close (unix_channel->fd) < 0) { + int err = errno; g_set_error_literal (err, G_IO_CHANNEL_ERROR, - g_io_channel_error_from_errno (errno), - g_strerror (errno)); + g_io_channel_error_from_errno (err), + g_strerror (err)); return G_IO_STATUS_ERROR; } @@ -376,9 +380,10 @@ g_io_unix_set_flags (GIOChannel *channel, if (fcntl (unix_channel->fd, F_SETFL, fcntl_flags) == -1) { + int err = errno; g_set_error_literal (err, G_IO_CHANNEL_ERROR, - g_io_channel_error_from_errno (errno), - g_strerror (errno)); + g_io_channel_error_from_errno (err), + g_strerror (err)); return G_IO_STATUS_ERROR; } @@ -396,8 +401,9 @@ g_io_unix_get_flags (GIOChannel *channel) if (fcntl_flags == -1) { + int err = errno; g_warning (G_STRLOC "Error while getting flags for FD: %s (%d)\n", - g_strerror (errno), errno); + g_strerror (err), err); return 0; } @@ -512,18 +518,20 @@ g_io_channel_new_file (const gchar *filename, fid = open (filename, flags, create_mode); if (fid == -1) { + int err = errno; g_set_error_literal (error, G_FILE_ERROR, - g_file_error_from_errno (errno), - g_strerror (errno)); + g_file_error_from_errno (err), + g_strerror (err)); return (GIOChannel *)NULL; } if (fstat (fid, &buffer) == -1) /* In case someone opens a FIFO */ { + int err = errno; close (fid); g_set_error_literal (error, G_FILE_ERROR, - g_file_error_from_errno (errno), - g_strerror (errno)); + g_file_error_from_errno (err), + g_strerror (err)); return (GIOChannel *)NULL; } -- 2.34.1