Generating relative paths


#1

I’m in need of generating relative paths, like:

File one(“C:\My\First\Path\file.txt”);
File two(“C:\My\Second\Path\file.txt”);
String path = two.getRelativePathTo(one);
path -> “…\Second\Path\file.txt”

and on Mac + Windoze. I don’t think I’ve seen this in Juce, so do y’all have any tips? Don’t think boost filesystem can do this either…

TIA
/R


#2

Well you were only a couple of characters away… it’s File::getRelativePathFrom()

Did you look for it and miss it?


#3

[quote=“jules”]Well you were only a couple of characters away… it’s File::getRelativePathFrom()

Did you look for it and miss it?[/quote]

I think so! :lol:

I shouldn’t have cancelled that appointment with my optician… :wink:

Thnx!
/R


#4

Ok, now I want to normalize a file path so that:

File one(“C:\My\First\Path”);
one.appendPath("…\Second\Path\file.txt");
String path = one.getFullPathName();
path -> “C:\My\Second\Path\file.txt”

Don’t tell me I missed that too? :?

/R


#5

No, you didn’t miss it because there’s nothing to miss. Just use getChildFile() and it removes all the relative path stuff automatically…


#6

Doh! :oops:


#7