2010-08-20 12:56:46 +02:00
|
|
|
#include "search.hpp"
|
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
|
2012-01-29 20:27:03 +01:00
|
|
|
void FileFinder::find(const boost::filesystem::path & dir_path, ReturnPath &ret, bool recurse)
|
2010-08-20 12:56:46 +02:00
|
|
|
{
|
2012-01-29 20:27:03 +01:00
|
|
|
if ( !boost::filesystem::exists( dir_path ) )
|
2010-08-20 12:56:46 +02:00
|
|
|
{
|
2012-01-29 20:27:03 +01:00
|
|
|
std::cout << "Path " << dir_path << " not found" << std::endl;
|
2010-08-20 12:56:46 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-01-29 20:27:03 +01:00
|
|
|
boost::filesystem::directory_iterator end_itr; // default construction yields past-the-end
|
|
|
|
for (boost::filesystem::directory_iterator itr(dir_path); itr != end_itr; ++itr)
|
2010-08-20 12:56:46 +02:00
|
|
|
{
|
2012-01-29 20:27:03 +01:00
|
|
|
if (boost::filesystem::is_directory( *itr ))
|
|
|
|
{
|
|
|
|
if (recurse)
|
|
|
|
{
|
|
|
|
find(*itr, ret);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2010-08-20 12:56:46 +02:00
|
|
|
{
|
2012-01-29 20:27:03 +01:00
|
|
|
ret.add(*itr);
|
2010-08-20 12:56:46 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|