[Boost-bugs] [Boost C++ Libraries] #4494: recursive_directory_iterator throws unexpectedly in the non-throw mode

Subject: [Boost-bugs] [Boost C++ Libraries] #4494: recursive_directory_iterator throws unexpectedly in the non-throw mode
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2010-07-30 06:13:15


#4494: recursive_directory_iterator throws unexpectedly in the non-throw mode
-------------------------------------+--------------------------------------
 Reporter: ttan@… | Owner: bemandawes
     Type: Feature Requests | Status: new
Milestone: Boost 1.44.0 | Component: filesystem
  Version: Boost Development Trunk | Severity: Problem
 Keywords: filesystem v3 throw |
-------------------------------------+--------------------------------------
 In boost::filesystem v3, while it’s possible to choose a no-throw version
 of recursive_directory_iterator by passing an boost::system::error_code
 object to its constructor, like this:
                                   boost::system::error_code m_ec;
                                   for ( recursive_directory_iterator
 itr(root, m_ec), end_itr; itr != end_itr; ++itr)

 However, because in the implementation of the
 recursive_directory_iterator::increment(), directory_iterator is always
 constructed with the throw version, it would cause exception throws during
 the for-loop while accessing folders like \System Volume Information on
 Windows:
     void increment()
     {
       BOOST_ASSERT(m_imp.get() && "increment of end
 recursive_directory_iterator");
       m_imp->increment(0);
       if (m_imp->m_stack.empty()) m_imp.reset(); // done, so make end
 iterator
 }

 Where m_imp is an object of recur_dir_itr_imp:
     void recur_dir_itr_imp::increment(system::error_code* ec)
     // ec == 0 means throw on error
 {
 â€¦
 }

 As it’s not possible to catch this exception within the for-loop and
 continue the loop, it greatly limits the use of
 recursive_directory_iterator.
 With a rough check, V2 does not seem to have this problem. it's preferred
 that the directory_iterator to behave the same as
 recursive_directory_iterator in this case.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/4494>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:04 UTC