33absl::Status
Match(std::string_view pattern, std::vector<std::string>* result,
36 const auto search_dir = fs::path(
SV_ABSL_TO_STD(pattern)).parent_path();
37 const auto filename = fs::path(
SV_ABSL_TO_STD(pattern)).filename().string();
38 std::string regexp_filename =
39 absl::StrReplaceAll(filename, {{
".",
"\\."}, {
"*",
".*"}, {
"?",
"."}});
40 std::regex regexp_pattern(regexp_filename);
41 std::error_code error;
43 const fs::directory_iterator path_end;
44 for (
auto path = fs::directory_iterator(search_dir, error);
45 !error && path != path_end; path.increment(error)) {
46 if (!fs::is_regular_file(path->path())) {
49 if (std::regex_match(path->path().filename().string(), regexp_pattern)) {
50 result->push_back(path->path().string());
54 return absl::InvalidArgumentError(error.message());
57 std::sort(result->begin(), result->end());
58 return absl::OkStatus();
59 }
catch (
const std::exception& e) {
60 return absl::InvalidArgumentError(e.what());