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 »

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 »

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 »

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 »

I have found out this is fixed in 2.6.2
Post Reply