Boost logo

Boost :

From: Carlo Wood (carlo_at_[hidden])
Date: 2004-09-10 08:17:32


On Thu, Sep 09, 2004 at 03:32:28PM -0400, Beman Dawes wrote:
> Yes, is_accessable() might be useful. But the use cases I can think of are
> a bit theoretical. Anyone else have an opinion? I think I'd like to hear
> about so real-life needs (rather than theoretical or hypothetical needs)
> before deciding.

It makes sense. The only reasonable result for is_directory()
when a parent directory in the path is not reachable, is to
return false or throwing. But you can't return 'false' because
it is possible that the path really is a directory OR it
doesn't exist even; and the policy is to thrwo when it doesn't
exist. You also can't throw because, like you said, that should
be a real error; I don't think that inaccessibility for a mere
query should be considered a serious error of this type.

My conclusion is that throwing is the only option, but that
the coder should get a fair chance of avoiding the need to
catch that exception by providing the additional test is_accessable.
is_accessable then should return false when it is not possible
to determine the existance and/or type of the path passed to it.

I understand that the original proposal also tried to solve
a possible race condition. For example, code now will look
like:

if (is_accessable(p) && is_directory(p))

in an attempt to avoid exceptions.
However, it is possible that right after the call to
is_accessable - a parent directory is made in-accessable;
in which case you still get an exception; that doesn't seem
right I have to admit. Not that I'd care ;)

Thanks

-- 
Carlo Wood <carlo_at_[hidden]>

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