MergePath (open)
Merges to paths together, inserting a slash at the merge point if necessary. The returned string is then collapsed.
Syntax
LOADLIB "wh::files.whlib";
STRING FUNCTION MergePath(STRING first, STRING second)
Parameters
STRING first
First part of the path
STRING second
Second part of the path
Return value
STRING
The two paths merged together
Description
This functions returns the merge of two paths. If the first path isn't empty and doesn't end in a slash and the second path doesn't begin with a slash, a slash is added between the two paths. The merged path is then collapsed, eliminating all unnecessary path elements.
Examples
//Prints "/a/b/c"
PRINT(MergePath("/a/b/", "/c"));
//Prints "/a/b/c"
PRINT(MergePath("/a/../a/.//b", "c"));
//Prints "c"
PRINT(MergePath("", "c"));