On Fri, Jul 08, 2005 at 11:49:59PM +0200, demerphq wrote:
canonpath() should never be inserting the CWD when cleaning up. "./bar" is
the same as "bar" but "$CWD/bar" is not! Its important that cannonical
relative paths remain relative.
Sorry, i guess I didnt express myself properly. You cant clean up acanonpath() should never be inserting the CWD when cleaning up. "./bar" is
the same as "bar" but "$CWD/bar" is not! Its important that cannonical
relative paths remain relative.
relative path properly without knowing where it is relative to.
Consider the following path:
..\..\foo
If we are in \bar then ..\..\foo is the same as ..\foo and \foo but
if we are in \bar\baz\bat then its not the same as either as it maps
to \bar\foo.
Your proposed "cleanup" is actually changing the meaning of the path.
..\..\foo means "go up two levels and then down into foo". ..\foo means
"go up one level and then down into foo". They represent different things.
canonpath() is about producing filepaths with the same meaning and NOT
about determining if they might point to the same file given the current
CWD. For that you can just run it through rel2abs().
Would would be nice is some sort of collapse() method which does collapse
.. so that canonpath("foo/../bar") == 'foo/../bar' but
collapse(canonpath("foo/../bar")) == 'bar'.
I like this solution. canonpath() can remain strict and work the same
across platforms. The user can decide if they want .. collapsed or not.
We stop having to second guess the user's needs.
--
Michael G Schwern schwern@pobox.com http://www.pobox.com/~schwern
You are wicked and wrong to have broken inside and peeked at the
implementation and then relied upon it.
-- tchrist in <31832.969261130@chthon>