Does anyone had this problem ? When searching a partition with recursive_directory_iterator, when it reaches the end it crashes.
I get this in Visual Studio 2008 with boost 1.39 but also at home using MinGW with boost 1.46. I don’t think I am doing something wrong:
#include "stdafx.h"
#include <iostream>
#include <boost/filesystem.hpp>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
boost::filesystem::path musicPaths("d:\\");
for(boost::filesystem::recursive_directory_iterator it(musicPaths); it != boost::filesystem::recursive_directory_iterator(); ++it)
{
string strToFind = ".mp3";
boost::filesystem::path dummypath = it->path().filename();
string str = dummypath.string();
if(str.find(strToFind) != -1)
{
cout << str << endl;
}
}
return 0;
}
EDIT:
I see that it doesnt crash at the end but when it reaches System Volume Information
Windows does not allow you to look inside the directory “System Volume Information”.
So unleashing a recursive_directory_iterator on “System Volume Information” is a bad idea.
Edit: You may be able to solve the problem with recursive_directory_iterator::no_push(). From The Boost docs: