Boost logo

Boost :

From: Stewart, Robert (stewart_at_[hidden])
Date: 2002-03-21 14:26:37


From: Beman Dawes [mailto:bdawes_at_[hidden]]
>
> At 03:01 AM 3/21/2002, Dylan Nicholson wrote:
>
> But with remove/prune, there end up being something like 7
> names, and many
> of those have several overloads. Minimum 13 signatures in
> all, and that
> doesn't even cover a few of the behavior corner cases.
>
> An alternative would be to have a single name ("remove") with four
> signatures (unfiltered, filtered by name, filtered by regex,
> filtered by
> Predicate). All would take an options argument, which would
> be a bitmask
> type (17.3.2.1.2) with the following entries (I haven't tried
> to pick names
> yet):
>
> * OK if !exist(path) [otherwise throw if !exist(path)]
> * recurse into subdirectories [otherwise don't recurse]
> * error if !is_directory(path), or,

This should be handled by a predicate.

> error if !is_file(path),

This should be handled by a predicate.

> * remove path itself if filter results in
> is_empty_directory(path)

I think this is reasonably handled with other means. For example, never
remove the directory itself; just its contents. Or, always try to remove
the directory and throw an exception. Finally, you could add an overload
that handles this case separately.

> Dropping from 7 names to 1, and 13 signatures to 4 is
> certainly attractive.

Agreed.

I'll suggest names for the options I left: must_exist, recurse (or
recurse_directories). That was easy since I only kept two options!

Rob
Susquehanna International Group, LLP
http://www.sig.com


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