RosettaCodeData/Task/Walk-a-directory-Recursively/C++/walk-a-directory-recursively-1.cpp

20 lines
461 B
C++
Raw Permalink Normal View History

2013-04-11 01:07:29 -07:00
#include "boost/filesystem.hpp"
#include "boost/regex.hpp"
#include <iostream>
using namespace boost::filesystem;
int main()
{
path current_dir("."); //
boost::regex pattern("a.*"); // list all files starting with a
for (recursive_directory_iterator iter(current_dir), end;
iter != end;
++iter)
{
2015-02-20 00:35:01 -05:00
std::string name = iter->path().filename().string();
2013-04-11 01:07:29 -07:00
if (regex_match(name, pattern))
std::cout << iter->path() << "\n";
}
}