|
Boost : |
From: Beman Dawes (bdawes_at_[hidden])
Date: 2002-03-21 20:40:15
At 02:26 PM 3/21/2002, Stewart, Robert wrote:
>> * 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.
Yes, I've been having similar thoughts. The first (OK if...) option is
worthwhile because it causes the default behavior to be safe behavior, yet
allows permissive behavior if desired. The second (recurse) option is
worthwhile because it is very commonly needed, yet the code to write it
would be messy and error prone.
The last three could easily be dropped as you suggest. The user can
trivially achieve the behavior in all three cases, with either a predicate
or one additional line of code.
>> 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!
The same options apply to remove, copy, and create_directory, except that
the condition tested is flipped for create_directory. So I was thinking of
"permissive" and "recursive" for the names, but hope we can do better than
"permissive".
I'll sleep on the decision for "explicitly named functions" versus "single
function name with options", and try to come to a decision tomorrow.
Thanks for the comments,
--Beman
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk