
Version: boost 1.36 Library: filesystem Platform: Linux Compiler: g++ 4.3.0 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. The following modification of filesystem/convenience.hpp catches the exception at a low enough level to allow the directory to be skipped over. Is there a better way of handling this? Thanks. --- /usr/local/include/boost-1_36/boost/filesystem/convenience.hpp 2008-09-30 17:34:10.000000000 -0400 +++ boost/filesystem/convenience.hpp 2008-10-02 16:40:43.000000000 -0400 @@ -239,10 +239,15 @@ else if ( is_directory( m_imp->m_stack.top()->status() ) ) { system::error_code ec; - m_imp->m_stack.push( - m_imp->m_no_throw - ? basic_directory_iterator<Path>( *m_imp->m_stack.top(), ec ) - : basic_directory_iterator<Path>( *m_imp->m_stack.top() ) ); + const Path& top = *m_imp->m_stack.top(); + m_imp->m_stack.push(end_itr); + try { + m_imp->m_stack.top() = + m_imp->m_no_throw + ? basic_directory_iterator<Path>( top, ec ) + : basic_directory_iterator<Path>( top ); + } + catch ( ... ) { } if ( m_imp->m_stack.top() != end_itr ) { ++m_imp->m_level; -- Charles Karney <ckarney@sarnoff.com> Sarnoff Corporation, Princeton, NJ 08543-5300 URL: http://charles.karney.info Tel: +1 609 734 2312 Fax: +1 609 734 2662