Relative Path(File) bug?

I found a weird behaviour in the RelativePath(file) node. Given an absolute path and a base path, it constructs a relative path, but includes the last folder in the base path.

If you actually connect relative path and absolute path using the same base path, shouldn’t the output be the same as the absolute path to begin with?

I dont understand why the folder of the base path is included in the relative path. Shouldn’t base path + relative path = Absolute path? Right now thats not what is happening.

Maybe there is something I am not considering, but it seems very odd. In my specific example I am trying to get the names of the subfolders in a folder, and it seemed logical that given a list of subfolders as the absolute paths and the parent folder as the base path, should result in just the names of the folders, yet it includes the parent folder in the relative paths!?

Here is basically the help patch of relative path showing what I think is not correct behaviour. In the example the relative path should just be “\Text.v4p”, since if I am in folder C:\temp (the base path), then including the folder name again wouldn’t work.

relative_path.v4p (7.2 KB)

this is indeed confusing, but if instead of “C:\temp” you write “C:\temp” it will work as you expected. i “fixed” that in the helppatch.

@joreg, okay I think I get where the “bug” is now. SubDir outputs the folders with a \ at the end, while an IOBox with a folder does not add the \ at the end.

So you have to add the \ to the base path manually and then it works as expected.

Of course in the help patch you can just add it manually, because the folder doesn’t exist, but if you select an actual folder, the trailing \ is missing, but a simple + (String) “solves” it.

I think SubDir should just output the folders without the trailing , because now using the example above, the relative path still contains the somewhat useless \ at the end:

So in the end I believe its simply 2 bugs or inconsistencies in the SubDir node, together with the other issue: Subdir not updating (unless observed)

gave this a second thought and fixed RelativePath so that it can cope with base-paths regardless if they have trailing slashes or not.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.