[Boost-bugs] [Boost C++ Libraries] #1061: boost::filesystem::basic_recursive_directory_iterator fails on empty directories.

Subject: [Boost-bugs] [Boost C++ Libraries] #1061: boost::filesystem::basic_recursive_directory_iterator fails on empty directories.
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2007-06-18 14:01:58


#1061: boost::filesystem::basic_recursive_directory_iterator fails on empty
directories.
----------------------------------+-----------------------------------------
 Reporter: jrowe_at_[hidden] | Type: Bugs
   Status: new | Milestone: To Be Determined
Component: filesystem | Version: release 1.34.0
 Severity: Problem | Keywords: recursive_directory_iterator empty directory
----------------------------------+-----------------------------------------
 See the following code
 (http://lists.boost.org/Archives/boost/2006/10/111230.php):

 {{{
 int main(int argc, char *argv[])
 {
      fs::path p("c:\\empty_folder"); // a empty folder
      fs::recursive_directory_iterator iter(p);
      if (iter != fs::recursive_directory_iterator())
          iter->status(); // <== cause a assertion failure
      return 0;
 }
 }}}

 It might be able to be fixed by modifying convenience.hpp in the following
 way (only informally tested for an empty top-level directory):

 {{{
     // constructors
     template<class Path>
     basic_recursive_directory_iterator<Path>::
       basic_recursive_directory_iterator( const Path & dir_path )
       : m_imp( new detail::recur_dir_itr_imp<Path> )
     {
       m_imp->m_stack.push( basic_directory_iterator<Path>( dir_path ) );
       if (m_imp->m_stack.top () == basic_directory_iterator<Path> ())
       {
           m_imp.reset ();
       }
     }

     template<class Path>
     basic_recursive_directory_iterator<Path>::
       basic_recursive_directory_iterator( const Path & dir_path,
 system_error_type & ec )
       : m_imp( new detail::recur_dir_itr_imp<Path> )
     {
       m_imp->m_stack.push( basic_directory_iterator<Path>( dir_path,
 std::nothrow ) );
       if (m_imp->m_stack.top () == basic_directory_iterator<Path> ())
       {
           m_imp.reset ();
       }
       m_imp->m_no_throw = true;
     }
 }}}

 I haven't tested this fix with any significant rigor. I am just reporting
 the bug so it can be tracked, and suggesting the code where the problem
 is.

--
Ticket URL: <http://svn.boost.org/trac/boost/ticket/1061>
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:49:55 UTC