After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 117925 - dir separator confusion in file utility functions under win32
dir separator confusion in file utility functions under win32
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: win32
2.2.x
Other other
: Normal normal
: ---
Assigned To: Tor Lillqvist
Tor Lillqvist
Depends on:
Blocks:
 
 
Reported: 2003-07-20 20:23 UTC by Dov Grobgeld
Modified: 2011-02-18 15:58 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Suggested patch to gutils.c (4.28 KB, patch)
2003-08-15 05:20 UTC, Tor Lillqvist
none Details | Review
Suggested patch to gfileutils.c and strfunc-test.c (6.84 KB, patch)
2003-08-16 05:00 UTC, Tor Lillqvist
none Details | Review

Description Dov Grobgeld 2003-07-20 20:23:35 UTC
Under Win32 most file operator functions allow either use of backslash or
forward slash as a directory separator E.g. to open a file either
one of the following will work:

    FILE *F = fopen("c:/users/me/foo.txt");

or 
    FILE *F = fopen("c:\\users\\me\\foo.txt");

It would therefore seem natural that the gfileutils and gutils functions of
glib would support both of these. But that is unfortunately not the case.
Thus the following does not work as expected under windows:

    gchar *path = "c:\\somewhere";
    gchar *a_file = g_strdup_printf("%s/a_file", path);
    gchar *extracted_path = g_path_get_dirname(a_file);

(It could be claimed that g_build_filename() should always be used, but if
fopen, mkdir, etc support both slashes, then, imho, so should
g_path_get_dirname() and g_path_get_basename().)
Comment 1 Tor Lillqvist 2003-07-30 09:28:58 UTC
I tend to agree that glib should handle either slash in its file name 
manipulating functions on Win32. But is this a new feature or a 
bugfix? I.e. can it be done already in the 2.2 branch, or only in 2.4?
Comment 2 Owen Taylor 2003-08-07 17:51:50 UTC
I'd consider this a 2.4-only thing. It's going to require
quite a bit of code change. Especially something like
g_build_filename() will require some thought.
 
(What is g_build_filename ("C:\foo", "bar/baz", NULL))
Comment 3 Tor Lillqvist 2003-08-15 05:20:56 UTC
Created attachment 19229 [details] [review]
Suggested patch to gutils.c
Comment 4 Tor Lillqvist 2003-08-15 05:45:35 UTC
Just having been bitten by this bug, I think we should after all 
consider it a thing for 2.2.3... At least the gutils.c part. Will do 
a patch for gfileutils.c later.
Comment 5 Tor Lillqvist 2003-08-16 04:49:01 UTC
g_build_filename ("C:\\foo", "bar/baz", NULL) should 
be "C:\\foo\\bar/baz".

(C syntax, i.e. backslashes appear doubled.)

I have modified fileutils.c and added Win32-only tests that use '/', 
and mix '\\' and '/' to strfunc-test.c, but the GNOME CVS server says 
no such user tml in CVSROOT/passwd (some temporary problem, 
hopefully), so I can't cvs diff...
Comment 6 Tor Lillqvist 2003-08-16 05:00:09 UTC
Created attachment 19257 [details] [review]
Suggested patch to gfileutils.c and strfunc-test.c
Comment 7 Tor Lillqvist 2003-08-16 16:43:12 UTC
Fix applied to glib-2-2, HEAD in a moment or two.