wxURL.GetInputStream fails with file protocol Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
rogerjames99
In need of some credit
In need of some credit
Posts: 9
Joined: Fri Oct 01, 2004 8:21 pm

wxURL.GetInputStream fails with file protocol

Post by rogerjames99 » Wed Sep 28, 2005 6:51 pm

I am sure the code

wxURL Url("file:///c:/testfile.xml");

Url.GetInputStream();

used to work for me.

It now fails and logs the error message

wxLog: Error: can't open file 'file:///c:/testfile.xml' (error 123: the filename, directory name, or volume label syntax is incorrect.)

Stepping through the code it looks like the protcol part of the URI is not being stripped before the path is passed to wxFile::Open.

Is anyone else seeing this or am I doing something wrong?

Roger

Tyler
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 246
Joined: Fri Sep 03, 2004 12:37 am
Contact:

Post by Tyler » Wed Sep 28, 2005 7:16 pm

Try this:

Code: Select all

wxString path = "c:\\whatever.xml";
path = wxURL::ConvertToValidURI(path)
wxURL url(path);
wxInputStream *data;
data = url.GetInputStream();
That may not solve the problem but I read somewhere that you should call ConvertToValid first.

rogerjames99
In need of some credit
In need of some credit
Posts: 9
Joined: Fri Oct 01, 2004 8:21 pm

Post by rogerjames99 » Wed Sep 28, 2005 7:30 pm

I had a quick look at the code for ConvertToValid and it does not do very much, the URI file:///xxxxxxx is already a valid URI. The problem is that the whole URI as used as a path in wxFile::Open

Thanks,

Roger

rogerjames99
In need of some credit
In need of some credit
Posts: 9
Joined: Fri Oct 01, 2004 8:21 pm

Post by rogerjames99 » Sat Oct 15, 2005 11:54 am

I have found out this is fixed in 2.6.2

Post Reply