|
Boost : |
From: Stewart, Robert (stewart_at_[hidden])
Date: 2002-03-28 08:53:28
From: Beman Dawes [mailto:bdawes_at_[hidden]]
>
> At 03:20 PM 3/26/2002, Jan Langer wrote:
>
> >- what does the prune option do? its value is the same as
> recurse (is
> >this intended) and shouldn't the comment be replaced by
> "operate only on
> >directory contents". please say a few more words on this.
>
> The meaning of prune is to make directory removal conditional
> depending on
> whether or not the directory is empty.
>
> For example,
>
> // remove "foo", which must be empty, and must exist
> remove( "foo" );
>
> // remove "foo", which must be empty, if it exists
> remove( "foo", optional );
>
> // unconditionally remove "foo", and all its sub-directories
> remove( "foo", recurse );
>
> // remove "foo", and any of its sub-directories, but
> only if empty
> remove( "foo", recurse+prune );
I find the progression confusing. The most restrictive semantics takes no
options, which is fine. Then, you relax the existence requirement with an
option, which is fine. Then, you add semantic behavior -- removing
subdirectories, and any files -- with a single option. Finally, you
subtract semantic behavior -- removing any files found -- by the addition of
a second option.
I would expect the addition of an option to tell remove() to remove files it
happens to find, and the absence of that option to tell remove() to throw an
exception if a directory is not empty. Thus, I'd expect "prune" -- or
whatever name you may prefer -- to mean that the directory to remove need
not be empty.
Those points lead to this progression:
// remove "foo," which must be empty and must exist
remove("foo");
// remove "foo," which must be empty but need not exist
remove("foo", optional);
// remove "foo," which may have subdirectories; all
// directories must be empty
remove("foo", recurse);
// remove "foo," which may have subdirectories but need
// not exist; all directories must be empty
remove("foo", recurse + optional);
// remove "foo," which may have subdirectories; any
// directory may have files
remove("foo", recurse + prune);
// remove "foo," which may have subdirectories but need
// not exist; any directory may have files
remove("foo", recurse + prune + optional);
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