Converting a file url to a windows path name. - Programmer
This is a discussion on Converting a file url to a windows path name. - Programmer ; Hi, my application receives a drag and drop event to load new files
(dragging a file icon) and it receives the filename as a file:// url.
Its no problem to strip the file://, or convert the /s into \s but ...
-
Converting a file url to a windows path name.
Hi, my application receives a drag and drop event to load new files
(dragging a file icon) and it receives the filename as a file:// url.
Its no problem to strip the file://, or convert the /s into \s but it
looks like I also have to convert all the %20s into spaces.
Is there any function I can use to do all this automatically, including
other special % chars that might need converting?
Thanks
Kurt
-
Re: Converting a file url to a windows path name.
Nothing automatic -- but you could write something -- it would be trivial to
convert it
On 31 Aug 2006 08:53:51 -0700, "kza" wrote:
>Hi, my application receives a drag and drop event to load new files
>(dragging a file icon) and it receives the filename as a file:// url.
>
>Its no problem to strip the file://, or convert the /s into \s but it
>looks like I also have to convert all the %20s into spaces.
>
>Is there any function I can use to do all this automatically, including
>other special % chars that might need converting?
>
>Thanks
>
>Kurt
--- AntiSpam/harvest ---
Remove X's to send email to me.
-
Re: Converting a file url to a windows path name.
On 31 Aug 2006 08:53:51 -0700, "kza" wrote:
>Its no problem to strip the file://, or convert the /s into \s...
FWIW, you don't have to switch the slashes. Everything on the system can handle either,
except the command prompt. I always use /, so I don't mess up on the number of \\'s I
have to put in.
>but it
>looks like I also have to convert all the %20s into spaces.
That's pretty straightforward: see the % character, get the next two hex digits and stuff
a character. You might want to actually verify that the two characters *are* hex digits,
and convert any nasty characters (e.g. '\', '/') into something friendly.
--
#include
_
Kevin D Quitt USA 91387-4454 96.37% of all statistics are made up
-
Re: Converting a file url to a windows path name.
kza wrote:
> Hi, my application receives a drag and drop event to load new files
> (dragging a file icon) and it receives the filename as a file:// url.
>
> Its no problem to strip the file://, or convert the /s into \s but it
> looks like I also have to convert all the %20s into spaces.
>
> Is there any function I can use to do all this automatically, including
> other special % chars that might need converting?
>
> Thanks
>
> Kurt
>
Look at InternetCrackUrl().
Norm
--
--
To reply, change domain to an adult feline.
-
Re: Converting a file url to a windows path name.
Thanks everyone for all your replys. I guess I could have written my
own conversion function but I wasnt sure if it was only the file:///
bit, the slashes and the % chars I had to convert or whether there were
any number of extra things that might pop up in certain URLs that I
wouldnt know in advance.
Since I was using the Qt library in the project anyway, I used the QUrl
object and its member functions to decode it. Turns out I still needed
to go through and swap the slashes, I know its not always neccessary,
but in this case, I pass the filename onto the xerces xml parser, and
that seems to only accept the slashes around the windows way.
Thanks for all the tips.