Boost logo

Boost :

Subject: Re: [boost] FW: [filesystem] : basic_path : Feature request
From: Scott McMurray (me22.ca+boost_at_[hidden])
Date: 2009-02-07 13:38:21


On Sat, Feb 7, 2009 at 05:55, Rob <robrimmer_at_[hidden]> wrote:
>
> My code above to remove '.' was part of a 'canonicalize' function which
> removed both '.' and '..' where possible. (This may be a candidate for a
> convenience function within the library?)
>

In fact, boost::filesystem::canonize already exists, albeit
deprecated. It doesn't appear to do anything, though, which confuses
me. boost::filesystem::normalize is too much, as it does the foo/..
=> . reduction, which is unsafe.

p: dir1/./dir2/./dir3/../dir4
p.canonize(): dir1/./dir2/./dir3/../dir4
p.normalize(): dir1/dir2/dir4

I would like to see similar things return, though. I'd advocate a
clean() member function that does the foo/./bar => foo/bar reduction
and ensures that all relative paths start with ./ or ../, and a
non-member expand that removes all symlinks and ..s (which would
require that it have a root).


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk