Boost logo

Boost :

From: Beman Dawes (bdawes_at_[hidden])
Date: 2005-12-29 22:17:44


"Seb Martel" <smartel_at_[hidden]> wrote in message
news:20051229114129035.00000002196_at_hagar...
>>
>> > 2. Any chance of having a non-throwing version of directory_iterator
>> > (similar
>> > to status). Since such a common error like not having access to a
>> > directory
>> > throws an exception, every directory_iterator construction needs a
>> > try/catch.
>> > The recursive_directory_iterator is kind of useless since it will stop
>> > as
>> > soon
>> > as you get an "access denied".
>> > (Maybe a portable can_be_iterated function can be added)
>>
>> Hum. Worth considering.
>>
>
> I would welcome a non-throwing iterator as well. Most of our path
> iterating routines are littered with try catches to handle cases that
> aren't truly exceptional.

Is the litter just to deal with exceptions coming out of directory_iterator
constructors? Or are there other use cases needing excessive try/catch
blocks?

Also, what should the interface to a non-throwing directory_iterator look
like?

First try - in addition to the current public members, add:

     directory_iterator( const path & ph, std::nothrow_t );
     // Effects (in addition to normal construction): If error occurs, save
errno, and make iterator == the end iterator.

     system_error_type error();
     // Returns 0 if no constructor error, else errno saved by the
constructor

Comments?

Thanks,

--Beman


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