RosettaCodeData/Task/Walk-a-directory-Recursively/C++/walk-a-directory-recursively-1.cpp
2023-07-01 13:44:08 -04:00

19 lines
461 B
C++

#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)
{
std::string name = iter->path().filename().string();
if (regex_match(name, pattern))
std::cout << iter->path() << "\n";
}
}