|
Boost : |
From: eric ehlers (eric.ehlers_at_[hidden])
Date: 2007-09-04 04:52:10
Hello,
Using boost version 1.34.1 I get an assertion failure when comparing
recursive_directory_iterator to the end iterator if the corresponding
path comprises an empty directory.
// a directory that is not empty - runs OK
//boost::filesystem::path boostPath("C:\\test_notempty");
// a directory that is empty - crashes
boost::filesystem::path boostPath("C:\\test_empty");
if (boost::filesystem::is_directory(boostPath)) {
boost::filesystem::recursive_directory_iterator end_itr;
for (boost::filesystem::recursive_directory_iterator
itr(boostPath); itr != end_itr; ++itr) {
std::cout << itr->path().string() << std::endl;
}
}
Assertion failed: m_imp.get() && "attempt to dereference end iterator", file c:\
program files\boost\boost_1_34_1\boost\filesystem\operations.hpp, line 849
This issue has been reported before:
http://lists.boost.org/Archives/boost/2006/10/111230.php
What's the workaround? I can't seem to find any way to inspect the
path or its iterator to distinguish an empty directory from a nonempty
one without crashing the program.
Thanks,
Eric
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk