Boost logo

Boost :

From: Beman Dawes (bdawes_at_[hidden])
Date: 2007-09-04 16:23:39


eric ehlers wrote:
> 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.

That's ticket #1061. It was fixed by revision 38978 of
branches/filesystem on August 27th. New test cases were added to the
regression test, and they detected on other bug which has also been fixed.

That branch will likely get merged into the main trunk within the next day.

Thanks,

--Beman


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk