Bug 554092 – glib doesn't return G_FILE_ERROR_NOENT et al on OS X

2008-09-30  Behdad Esfahbod  <behdad@gnome.org>

        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
This commit is contained in:
Behdad Esfahbod
2008-09-30 20:40:31 +00:00
committed by Behdad Esfahbod
parent 23a4ae82e5
commit ef4d522b9b
2 changed files with 35 additions and 17 deletions

View File

@@ -1,3 +1,13 @@
2008-09-30 Behdad Esfahbod <behdad@gnome.org>
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 <tml@novell.com> 2008-09-30 Tor Lillqvist <tml@novell.com>
* Makefile.decl * Makefile.decl

View File

@@ -190,9 +190,10 @@ g_io_unix_read (GIOChannel *channel,
if (result < 0) if (result < 0)
{ {
int err = errno;
*bytes_read = 0; *bytes_read = 0;
switch (errno) switch (err)
{ {
#ifdef EINTR #ifdef EINTR
case EINTR: case EINTR:
@@ -204,8 +205,8 @@ g_io_unix_read (GIOChannel *channel,
#endif #endif
default: default:
g_set_error_literal (err, G_IO_CHANNEL_ERROR, g_set_error_literal (err, G_IO_CHANNEL_ERROR,
g_io_channel_error_from_errno (errno), g_io_channel_error_from_errno (err),
g_strerror (errno)); g_strerror (err));
return G_IO_STATUS_ERROR; return G_IO_STATUS_ERROR;
} }
} }
@@ -230,9 +231,10 @@ g_io_unix_write (GIOChannel *channel,
if (result < 0) if (result < 0)
{ {
int err = errno;
*bytes_written = 0; *bytes_written = 0;
switch (errno) switch (err)
{ {
#ifdef EINTR #ifdef EINTR
case EINTR: case EINTR:
@@ -244,8 +246,8 @@ g_io_unix_write (GIOChannel *channel,
#endif #endif
default: default:
g_set_error_literal (err, G_IO_CHANNEL_ERROR, g_set_error_literal (err, G_IO_CHANNEL_ERROR,
g_io_channel_error_from_errno (errno), g_io_channel_error_from_errno (err),
g_strerror (errno)); g_strerror (err));
return G_IO_STATUS_ERROR; return G_IO_STATUS_ERROR;
} }
} }
@@ -295,9 +297,10 @@ g_io_unix_seek (GIOChannel *channel,
if (result < 0) if (result < 0)
{ {
int err = errno;
g_set_error_literal (err, G_IO_CHANNEL_ERROR, g_set_error_literal (err, G_IO_CHANNEL_ERROR,
g_io_channel_error_from_errno (errno), g_io_channel_error_from_errno (err),
g_strerror (errno)); g_strerror (err));
return G_IO_STATUS_ERROR; return G_IO_STATUS_ERROR;
} }
@@ -313,9 +316,10 @@ g_io_unix_close (GIOChannel *channel,
if (close (unix_channel->fd) < 0) if (close (unix_channel->fd) < 0)
{ {
int err = errno;
g_set_error_literal (err, G_IO_CHANNEL_ERROR, g_set_error_literal (err, G_IO_CHANNEL_ERROR,
g_io_channel_error_from_errno (errno), g_io_channel_error_from_errno (err),
g_strerror (errno)); g_strerror (err));
return G_IO_STATUS_ERROR; 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) if (fcntl (unix_channel->fd, F_SETFL, fcntl_flags) == -1)
{ {
int err = errno;
g_set_error_literal (err, G_IO_CHANNEL_ERROR, g_set_error_literal (err, G_IO_CHANNEL_ERROR,
g_io_channel_error_from_errno (errno), g_io_channel_error_from_errno (err),
g_strerror (errno)); g_strerror (err));
return G_IO_STATUS_ERROR; return G_IO_STATUS_ERROR;
} }
@@ -396,8 +401,9 @@ g_io_unix_get_flags (GIOChannel *channel)
if (fcntl_flags == -1) if (fcntl_flags == -1)
{ {
int err = errno;
g_warning (G_STRLOC "Error while getting flags for FD: %s (%d)\n", g_warning (G_STRLOC "Error while getting flags for FD: %s (%d)\n",
g_strerror (errno), errno); g_strerror (err), err);
return 0; return 0;
} }
@@ -512,18 +518,20 @@ g_io_channel_new_file (const gchar *filename,
fid = open (filename, flags, create_mode); fid = open (filename, flags, create_mode);
if (fid == -1) if (fid == -1)
{ {
int err = errno;
g_set_error_literal (error, G_FILE_ERROR, g_set_error_literal (error, G_FILE_ERROR,
g_file_error_from_errno (errno), g_file_error_from_errno (err),
g_strerror (errno)); g_strerror (err));
return (GIOChannel *)NULL; return (GIOChannel *)NULL;
} }
if (fstat (fid, &buffer) == -1) /* In case someone opens a FIFO */ if (fstat (fid, &buffer) == -1) /* In case someone opens a FIFO */
{ {
int err = errno;
close (fid); close (fid);
g_set_error_literal (error, G_FILE_ERROR, g_set_error_literal (error, G_FILE_ERROR,
g_file_error_from_errno (errno), g_file_error_from_errno (err),
g_strerror (errno)); g_strerror (err));
return (GIOChannel *)NULL; return (GIOChannel *)NULL;
} }