#1061 closed Bugs (fixed)
boost::filesystem::basic_recursive_directory_iterator fails on empty directories.
Reported by: | Owned by: | Beman Dawes | |
---|---|---|---|
Milestone: | Boost 1.35.0 | Component: | filesystem |
Version: | Boost 1.34.0 | Severity: | Problem |
Keywords: | recursive_directory_iterator empty directory | Cc: |
Description
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.
Change History (4)
comment:1 by , 15 years ago
Owner: | set to |
---|
comment:2 by , 15 years ago
Milestone: | To Be Determined → Boost 1.35.0 |
---|---|
Status: | new → assigned |
comment:3 by , 15 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Fixed. See revision 38978 on branches/filesystem.
comment:4 by , 14 years ago
cMryPa <a href="http://uemvxixwbjae.com/">uemvxixwbjae</a>, [url=http://zvxeczxjmamx.com/]zvxeczxjmamx[/url], [link=http://yqtxgbontyru.com/]yqtxgbontyru[/link], http://wiybodbmcyau.com/
I've confirm that this is a bug, and added a test case to convenience_test.cpp that detects it.
The fix is scheduled for 1.35.0.
Thanks,
--Beman