Re: small patch for g_dir_open()



Michael Natterer <mitch gimp org> writes:

> 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...

Please don't add the __EMX__ stuff. I've never been happy with the way
OS/2 compatibilty stuff was added into GLib/GTK+ before:

 - Our standard define would be something like #ifdef G_OS_OS2
 - In many cases, it should be integrated with the Win32 dirname handling

If someone cares about OS/2, and has a machine to test it on, we can
look at adding OS/2 handling to GLib as a whole.

The g_return_if_fail() is fine.

Regards,
                                        Owen



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