Bug 554092 – glib doesn't return G_FILE_ERROR_NOENT et al on OS X
authorBehdad Esfahbod <behdad@gnome.org>
Tue, 30 Sep 2008 20:40:31 +0000 (20:40 +0000)
committerBehdad Esfahbod <behdad@src.gnome.org>
Tue, 30 Sep 2008 20:40:31 +0000 (20:40 +0000)
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

ChangeLog
glib/giounix.c

index 5496d819957f3d993eaeac7d50653f83372d7ca5..e568dd0db820c1f0ce3f770a6326908a40d11967 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -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>
 
        * Makefile.decl
index e7449b859c6b1ccbcc9d8300723e165689a4789f..8045910e8c3b880bfd3d4863f6992213b5722a79 100644 (file)
@@ -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;
     }