Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2003-11-26 08:28:23

Walter Landry wrote:
> Beman Dawes <bdawes_at_[hidden]> wrote:
>> Explicit dereferencing would be awfully cumbersome. People using
>> O/S's which natively support symbolic links would likely view it as
>> a giant step backward for them. Plus there would be interoperability
>> problems - programs using Boost.Filesystem wouldn't work the way
>> other programs worked.
> One solution is to have an extra argument which indicates whether to
> resolve symlinks, and have the default be yes. Something like
> bool exists(const path &ph, bool resolve_symlinks=true)
> Then remove_all would use exists(ph,false).

I don't see how this fixes things. remove_all should work on a symlinked
path. It should not _descend into_ symlinks.

   bool is_directory( const path &ph, bool symlink_allowed = true )

is a solution, but an explicit "is_symbolic_link" seems better.

I'd also consider something along the lines of

    recursive_directory_iterator it(ph, depth_first_traversal | return_files
| return_directories | follow_symlinks | detect_cycles), end;

    std::for_each(it, end, fs::remove);

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