
On Sat, Feb 7, 2009 at 05:55, Rob <robrimmer@atrico.net> 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).