Skip to content

Instantly share code, notes, and snippets.

@stryku
Created August 22, 2017 21:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stryku/5866a14233f877cc594e9147d5e30331 to your computer and use it in GitHub Desktop.
Save stryku/5866a14233f877cc594e9147d5e30331 to your computer and use it in GitHub Desktop.
bool findMatchingFiles(std::vector<std::string> &files)
{
SmallVector<char, 256> currentPath;
std::error_code ec;
llvm::sys::fs::file_status fileStatus;
llvm::sys::fs::current_path(currentPath);
for (llvm::sys::fs::recursive_directory_iterator I(currentPath, ec), E;
I != E; I.increment(ec)) {
if (ec) {
errs() << "error: error wile recursive files formatting. Error code: "
<< ec.value();
return true;
}
I->status(fileStatus);
if (fileStatus.type() == llvm::sys::fs::file_type::regular_file)
{
std::vector<Regex> regexs{ std::cbegin(FileNames), std::cend(FileNames) };
for (auto& regex : regexs) {
if (regex.match(I->path())) {
files.push_back(I->path());
}
}
}
}
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment