Merges to paths together, inserting a slash at the merge point if necessary. The returned string is then collapsed.
LOADLIB "wh::files.whlib"; STRING FUNCTION MergePath(STRING first, STRING second)
First part of the path
Second part of the path
The two paths merged together
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.
//Prints "/a/b/c" PRINT(MergePath("/a/b/", "/c")); //Prints "/a/b/c" PRINT(MergePath("/a/../a/.//b", "c")); //Prints "c" PRINT(MergePath("", "c"));