I'm using the code below, adapted from this thread. I'm able to get the list of files in a folder, but I get segmentation fault at the end. Any idea why this is happening?
And is there a way to get std::string of the current file (complete path) in the for loop?
boost::filesystem::path path("my_path");
static void myfunction()
{
boost::filesystem::directory_iterator end_itr;
// path is a static variable, defined somewhere else
for(boost::filesystem::directory_iterator dir_iter(path);
dir_iter != end_itr; ++dir_iter)
if( boost::filesystem::is_regular_file(dir_iter->status()) )
{
// print
}
}