I think it’s doing the right thing then. An empty string is used as a kind of error, like it says in the docs, that’s returned if the paths are invalid.
I think the behaviour’s the right thing - typically you’d use this to create a string that’s stored somewhere and which would make no sense to be blank, e.g. the projucer uses it extensively to create relative paths inside projects where a blank string would be meaningless, but a partial path would be fine.
my main grip with the current behavior and as you said it is used in Projucer, is that if I store this path and rename the directory, then the path is wrong even though it would have worked as those are in he same directory.
Seems bogus to me.
OK, I guess ‘.’ is a reasonable return value if the files are the same.
This of course assumes that they’re both referring to a folder, not a file, but the method isn’t supposed to be given a file anyway, so if you do that you’re already on shaky ground!
hahh, I was debugging today exactly the problem that @otristan described and thought this is a JUCE bug, so it was interesting to find this topic…
“I store this path and rename the directory, then the path is wrong even though it would have worked as those are in the same directory.”
I stored relative paths in preferences, but when I renamed the parent folder, it stopped working…
File("D:\\xxx\\yyy\\zzz").getRelativePathFrom("D:\\xxx\\yyy\zzz\\___\\!!!")
returns this, that I stored: "..\\..\\..\\zzz" instead of "..\\.." or "..\\..\\"
while I thought "zzz" is not stored as that's still common in both...
the extra "..\\zzz" is ok, but only until I rename "zzz" as I didn't thought that's part of the relative path as that's common part.