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 59387 - g_filename_to/from_uri() win32 details
g_filename_to/from_uri() win32 details
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: general
1.3.x
Other Windows
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on: 59388
Blocks:
 
 
Reported: 2001-08-22 19:16 UTC by Alexander Larsson
Modified: 2011-02-18 15:47 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
The patch, now with tests (20.12 KB, patch)
2001-08-24 23:17 UTC, Alexander Larsson
none Details | Review

Description Alexander Larsson 2001-08-22 19:16:39 UTC
Add this API to gconvert.h:

gchar *g_filename_from_uri (const char *uri,
			    char      **hostname,
			    GError    **error);
  
gchar *g_filename_to_uri   (const char *filename,
			    char       *hostname,
			    GError    **error);


This helps file DnD implementations tremendously, because these functions
are very easy to get wrong.

I've posted a patch to the gtk-devel-list, but i need to update it.
Comment 1 Alexander Larsson 2001-08-24 23:17:44 UTC
Created attachment 954 [details] [review]
The patch, now with tests
Comment 2 Alexander Larsson 2001-08-24 23:18:43 UTC
Ok. Here is the final patch. This thing uses g_ascii_isspace(), so it
blocks on #59388.
Comment 3 Darin Adler 2001-08-26 05:34:16 UTC
I think there should be a few more tests, but I can add them after
this is in. I always like to include edge case tests like "", "/",
a single letter "a" and the like. Also, the Windows-style path tests
need to be run under non-Windows systems too, even though the results
might be different on those systems, and the Windows-style paths
should show up in tests for conversion in both directions.

I'm a little sad that we didn't go with file:/ instead of file:///
-- I guess that discussion is still going on.
Comment 4 Alexander Larsson 2001-08-26 16:24:42 UTC
On the file:/ vs. file:/// issue i defered to the judgement of Daniel
Veilard. He seemed to think that file:/// was better, alhough it seems
that it is not mandated by the standard.
Comment 5 Darin Adler 2001-08-26 18:52:17 UTC
Daniel Veillard just said on the XML mailing list that the proper
format for "c:\windows" as a URI is "file:///c%3A\windows". So I think
the test case for (and the code to handle) Windows paths is incorrect.

See <http://lists.gnome.org/archives/xml/2001-August/msg00134.html>.

(I still don't buy that "file:///" is better, but I don't know
how to convince Daniel.)
Comment 6 Alexander Larsson 2001-08-26 19:36:13 UTC
Interesting discussion on this at:

http://lists.xml.org/archives/xml-dev/200005/msg00005.html

They seem to completely agree on convertin \ to /, something which
also corresponds with the VMS example in 3.10 in RFC 1738.

Escaping the colon seems to be optional. That is even said my Daniel
in this mail: http://xmlsoft.org/messages/0856.html

I think we should generate file:///c:/dir/file.txt and accept
file:///c:/dir/file.txt, file:/c:/dir/file.txt and the same with colon
escaped.

I will implement this.
Comment 7 Alexander Larsson 2001-08-26 21:41:22 UTC
Ok. I checked in the current version.

I'm changing this bug to handle the win32 behaviour details. It is no
longer on the API milestone.
Comment 8 Tor Lillqvist 2002-01-23 00:09:06 UTC
Fix committed to CVS. On Windows, backslashes in filenames are now 
always converted to slashes in the URI, and vice versa. Drive letters 
(followed by colon or vertical bar) are correctly handled in URIs. An 
initial slash in the filename part is no longer skipped on Unix. See 
ChangeLog for details.