Boost logo

Boost :

From: Beman Dawes (bdawes_at_[hidden])
Date: 2005-03-31 21:03:22

At 07:17 PM 3/31/2005, Peter Dimov wrote:
>Beman Dawes wrote:
>> At 01:06 PM 3/31/2005, Rob Stewart wrote:
>>> I disagree. All the caller wants to know is whether the supplied
>>> pathname refers to an existing file.
>> But if it isn't possible to reliably answer that query, shouldn't it
>> be an error?
>The answer to this question is probably "no", if by error you mean
>exception, and here is why.
>Every exception-throwing function has spawned a predicate that is used to

>avoid the exception (because exceptions cancel the currently active
>operation and this is undesirable in some cases).
>If you make 'exists' throw an exception, you will create a demand for a
>'preexists' query that will be used to detect whether the actual 'exists'

>will throw.

I agree, but don't think that has to lead to a "no" answer. One plan would
be to supply a status query function, perhaps named status(), which would
never throw and which would return a bitmask which could be queried as to
the exact attributes that apply. Including an attribute that indicates one
of these oddball errors has occurred. As with POSIX, there would presumably
be an lstat()-like query function that did not resolve symbolic links.

Presumably then exists() and the is_x() functions would be specified in
terms of status() and lstatus() results. So in effect exists() and the
is_x() functions are conveniences, very useful in many but not all cases,
and safe to use casually since obscure errors will cause exceptions.


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