You are here: Home → Forums → Challenge Suggestions → Path resolver
Add a reply
cwd: /foo/foo/bar/baz.php => /foo/bar/baz.phpbar/baz.php => /foo/bar/baz.php/foo/bar/../../baz.php => /baz.php/foo/bar/../.././baz.php => /baz.php/foo/bar/../.././/baz.php => /baz.php/foo/bar/../../../baz.php => invalid
A 29degrees diversion |
Given the absolute path to the current directory and another path, resolve the second path to its absolute form.
E.g.:
cwd: /foo
/foo/bar/baz.php => /foo/bar/baz.php
bar/baz.php => /foo/bar/baz.php
/foo/bar/../../baz.php => /baz.php
/foo/bar/../.././baz.php => /baz.php
/foo/bar/../.././/baz.php => /baz.php
/foo/bar/../../../baz.php => invalid
NB: The input paths shouldn't point to real files, otherwise (in PHP at least) people could just use realpath().