Boost logo

Boost Users :

Subject: Re: [Boost-users] filesystem::recursive_directory_iterator quits on unreadable directory
From: Charles Karney (ckarney_at_[hidden])
Date: 2008-10-06 11:47:11


Ravi wrote:
> On Thursday 02 October 2008 16:42:24 Charles Karney wrote:
>> The increment operator in filesystem::recursive_directory_iterator
>> throws an exception when trying to enter an unreadable directory
>> (permissions, no-such-device, etc.). Often (usually?), a user wants to
>> be able to skip the unreadable directory and continue the iteration over
>> the rest of the directory tree.
>>
>> Catching this exception doesn't help because the iterator hasn't been
>> incremented and I couldn't figure a way to skip over the unreadble
>> directory.
>
> Could you please file a trac item for this? The patch that you have proposed
> does not seem right; the user might wish to be informed. Perhaps the right
> approach is to throw the exception but ensure that the user can still skip
> over the unreadable directory after catching the exception.
>
> Regards,
> Ravi

It's not obvious where I file a trac item... Please tell me where or else
feel free to file on my behalf. (I'm not a registered boost developer.)

I agree that it's not obvious how this error should be handled. Letting
the user trap the error and then skip the unreadable directory is a
possibility. However, wrapping a try/catch around the increment clause
of a for loop seems to be awkward. My patch effectively treats unreadable
directories as empty which would seem to be plausible default (and such
behavior should be documented of course).

-- 
Charles Karney <ckarney_at_[hidden]>
Sarnoff Corporation, Princeton, NJ 08543-5300
URL: http://charles.karney.info
Tel: +1 609 734 2312
Fax: +1 609 734 2662

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net