Boost logo

Boost :

Subject: Re: [boost] [filesystem] Should recursive_directory_iterator follow directory symlinks by default?
From: Phil Richards (news_at_[hidden])
Date: 2011-02-12 03:37:41

On Wed, 2011-02-09 at 11:29 -0500, Dave Abrahams wrote:
> At Wed, 9 Feb 2011 09:15:24 -0500,
> Beman Dawes wrote:
> > recursive_directory_iterator currently always follows directory symlinks
> > Thus I'd like to add an option to either following directory symlinks
> > or not. Which should the default be?
> It might take extra logic on the user's part to avoid infinite recursions in a
> case where a directory symlinks an ancestor, so maybe it would make sense to
> have symlink-following be an explicit choice.

I agree with Dave.

Existing code *might* have been written with all the code that checks
for loops and escaping from a local tree. But...

Having written code using the recursive_directory_iterator (on Windows
XP), I know for a fact that I have never taken account of the fact that
it might happen because on that platform: it just isn't an issue that is
ever going to occur. On *nix, my mindset has been coloured by the
default behaviour of commands that process directories: they don't
follow symlinks unless you tell them to, so I've implicitly assumed
(incorrectly) that's what any recursive directory iterator would do.

Coding to safely handle automatically following of symlinks on a
recursive directory scan is sufficiently annoying that I'd suggest: (a)
most people haven't done it (properly); and (b) adding an extra flag
when it is to be done is a good reminder that the code is going to need
to be more complex.

As long as the change is documented in the release notes, I'd have
thought that would be sufficient.


Phil Richards, <news_at_[hidden]>

Boost list run by bdawes at, gregod at, cpdaniel at, john at