wxFileName 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
asadilan
Earned some good credits
Earned some good credits
Posts: 147
Joined: Tue Jul 27, 2010 10:42 pm

wxFileName

Post by asadilan » Wed Feb 22, 2012 10:08 pm

Hi all,

i have got wxFileName x(filename).
i would like to get a string with the following format:
../../../x.txt.
is this possible?

i know there is a function called makerelativeto but how do i retrieve the filename in wxString in that format?

TIA

DavidHart
Site Admin
Site Admin
Posts: 3967
Joined: Thu Jan 12, 2006 6:23 pm
Location: IoW, UK

Re: wxFileName

Post by DavidHart » Wed Feb 22, 2012 11:09 pm

Hi,

Code: Select all

x.MakeRelativeTo(wherever);
wxString relative = x.GetFullPath();
Regards,

David

asadilan
Earned some good credits
Earned some good credits
Posts: 147
Joined: Tue Jul 27, 2010 10:42 pm

Re: wxFileName

Post by asadilan » Thu Feb 23, 2012 5:11 pm

that will give you the full path. in the format c:\dir1\dir2\file.ext.
not in ..\..\file.ext.
unless there is something i am missing..

DavidHart
Site Admin
Site Admin
Posts: 3967
Joined: Thu Jan 12, 2006 6:23 pm
Location: IoW, UK

Re: wxFileName

Post by DavidHart » Thu Feb 23, 2012 5:59 pm

Hmm. Testing (on Linux) it does what it says on the label, but perhaps not quite what you want.

After making /usr/lib/foo/bar/baz relative to /home/david/, GetFullPath() returns ../../usr/lib/foo/bar/baz.

After making /home/david/foo/bar/baz relative to /home/david/, GetFullPath() returns foo/bar/baz. i.e. it's correct, but no dots.

asadilan
Earned some good credits
Earned some good credits
Posts: 147
Joined: Tue Jul 27, 2010 10:42 pm

Re: wxFileName

Post by asadilan » Fri Feb 24, 2012 10:37 pm

yes it works ok.
I was testing it in a different setting.
THanx

Post Reply