[core] Regex refactoring

Signed-off-by: x7z4w <x7z4w@noreply.codeberg.org>
This commit is contained in:
x7z4w
2025-11-03 21:16:16 +00:00
parent a62f6c0ef6
commit 0a3a4ebd9a
17 changed files with 134 additions and 83 deletions

View File

@@ -8,7 +8,8 @@
#include <algorithm>
#include <cstring>
#include <memory>
#include <regex>
#include <boost/regex.hpp>
#include <dirent.h>
#include <sys/stat.h>
@@ -143,15 +144,13 @@ void EnumerateFiles(std::string const & directory, std::function<void(char const
fn(entry->d_name);
}
void EnumerateFilesByRegExp(std::string const & directory, std::string const & regexp, std::vector<std::string> & res)
void EnumerateFilesByRegExp(std::string const & directory, boost::regex const & regexp, std::vector<std::string> & res)
{
std::regex exp(regexp);
EnumerateFiles(directory, [&](char const * entry)
{
std::string const name(entry);
if (std::regex_search(name.begin(), name.end(), exp))
if (boost::regex_search(name.begin(), name.end(), regexp))
res.push_back(name);
});
}
} // namespace pl