So, I wrote a small program to try Boost Filesystem. My program will record how many files are in the current path, and then the file names. Here is my program:
#include <iostream>
#include <boost/filesystem.hpp>
using namespace boost::filesystem;
int main(){
directory_iterator start = directory_iterator(current_path());
directory_iterator di = start;
int count;
for (count = 0; di != directory_iterator(); ++di, ++count);
std::cout << std::endl << "total number of files: " << count << std::endl;
di = start;
for (; di != directory_iterator(); ++di){
std::cout << *di << std::endl;
}
return 0;
}
existing files - program.exe, .ilk and .pdb
However, I get the following result (the entire path is omitted for brevity):
$ program.exe
total files: 3 [..] / program.pdb
The statement failed: m_imp-> m_handle! = 0 && "internal program error", file c: \ program files \ boost \ boost_1_44 \ boost \ filesystem \ v2 \ operations.hpp line 1001
If I create a new directory_iterator, it works fine:
di = start;
// .. becomes ..
di = directory_iterator(current_path());
, directory_iterators, , , .
:
startiterator, ?