Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2004-09-10 15:15:53


Beman Dawes wrote:
> At 02:19 PM 9/10/2004, Peter Dimov wrote:
>> Beman Dawes wrote:
>>> An attempt to query the attributes, such as
>>> is_directory("pagefile.sys") would throw an exception, which can
>>> be avoided by checking is_accessible("pagefile.sys").
>>
>> I'm not sure why would anyone want to omit the is_accessible check
>> before calling is_directory.
>
> In software which is specified to cope with even rare eventualities
> without recourse to a general error catch, it probably shouldn't be
> omitted.
> In applications which run in a very controlled and tightly specified
> environment, anything not being accessible is virtually certain to be
> an error condition, so just letting is_directory() throw is best for
> those apps.

This sounds convincing. However if we get back to our real-world example,
what do I gain from is_directory("pagefile.sys") throwing an exception? We
know that this will happen. We also know that pagefile.sys is not a
directory.

A related issue is that if we had a recursive (or a richer) iterator, the
problem wouldn't occur because iteration with FindNextFile will give us the
attributes (0x00000026 for pagefile.sys on my machine.)

It's also possible to use FindFirstFile to query the attributes, of course.


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