small patch for g_dir_open()



Hi all,

while porting GIMP to g_dir_open() to get rid of our own wrappers
i noticed some __EMX__ portability code which is missing in gdir.c:

Index: glib/gdir.c
===================================================================
RCS file: /cvs/gnome/glib/glib/gdir.c,v
retrieving revision 1.4
diff -u -p -r1.4 gdir.c
--- glib/gdir.c 2001/11/08 06:47:33     1.4
+++ glib/gdir.c 2002/02/08 15:12:52
@@ -61,7 +61,21 @@ g_dir_open (const gchar  *path,
             guint         flags,
             GError      **error)
 {
-  GDir *dir = g_new (GDir, 1);
+  GDir *dir;
+
+  g_return_val_if_fail (path != NULL, NULL);
+
+#ifdef __EMX__
+  /*
+   *  Change drive so opendir works.
+   */
+  if (path[0] && path[1] == ':')
+    {
+      _chdrive (path[0]);
+    }
+#endif
+
+  dir = g_new (GDir, 1);
 
   dir->dir = opendir (path);


The g_return_val_if_fail() is absolutely neccessary because opendir(NULL)
simply crashes. The #ifdef __EMX__'s correctness is out of my scope :)
but looks like the right thing to do...

OK to commit?

ciao,
--Mitch



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]