Reputation: 67
I have a relative url and an absolute path and i want to resolve it to an absolute path.
Have tried using filename:abspath("test", "/root/"). and it works but not with relative paths like "../" for example filename:abspath("../", "/root/"). gives "/root/../"
Does anyone have a simple solution?
Upvotes: 2
Views: 1485
Reputation: 10567
As the documentation of filename:absname/1 says: "No attempt is made to create the shortest absolute name, because this can give incorrect results on file systems which allow links."
If your example filename:abspath("../", "/root/") would give you "/" (an "optimized" path) instead of "/root/../", it could actually refer to the wrong directory if "/root" is a link to some other directory like "/foo/bar/baz". Are you sure that an optimized path is what you want? The result from abspath/2 is correct, but perhaps not "pretty".
Upvotes: 2