From: Peter Dimov (pdimov_at_[hidden])
Date: 2004-03-09 12:55:33
Walter Landry wrote:
> Beman Dawes <bdawes_at_[hidden]> wrote:
>> At 01:55 AM 3/9/2004, Vladimir Prus wrote:
>> >After all, caller only cares if directory exists, if it was
>> created by >another thread it's ok.
>> That's an interesting thought. Of course, it might not be another
>> thread but rather another process that created the directory, and
>> that could be a sign of real trouble.
> Exactly. Normally people use lock-files, but I personally have a use
> for lock-directories. If boost::filesystem starts swallowing errors,
> it makes it more difficult to achieve that.
It doesn't have to swallow errors. It can simply signal some errors via
exceptions and some errors via return values.
> I would say that people who don't care whether a directory is created
> should just catch the exception themselves. Alternately, you could
> generalize make_directory to take an extra, optional argument that
> specifies whether to throw if the directory already exists. Of
> course, it should always throw if the error is something different
> (e.g. if the parent directory doesn't exist).
This almost goes without saying.
post: p exists and is a directory
If the postcondition cannot be satisfied, create_directory _must_ throw. But
if p already exists and is a directory, the postcondition already holds, so
we are free to report the "error" via a different mechanism (COM, for
example, has a conventional "alternate success code" S_FALSE for such
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk