Put input files into a std::vector<filesystem::path>.

We need that for supporting recursive directory search later.

#
# Previous commits:
#   29ae22c Make regex const.
#   8ed72af Update german translation.
#   a3b0964 Remove old comment.
#   d107ce5 Modify config file example.
This commit is contained in:
tastytea 2021-05-27 10:14:56 +02:00
parent 29ae22cc4a
commit b764f5423c
Signed by: tastytea
GPG Key ID: CFC39497F1B26E07
1 changed files with 7 additions and 2 deletions

View File

@ -78,12 +78,17 @@ int main(int argc, char *argv[])
return EXIT_SUCCESS;
}
vector<fs::path> input_files;
if (vm.count("input-file") == 0)
{
cout << "NO INPUT FILE\n";
// TODO: Read data from stdin.
return EXIT_FAILURE;
}
for (const auto &filepath : vm["input-file"].as<vector<string>>())
{
input_files.emplace_back(filepath);
}
int return_code{EXIT_SUCCESS};
@ -118,7 +123,7 @@ int main(int argc, char *argv[])
vector<std::future<int>> futurepool;
auto search_file{
[&vm, &matches_all, &opts](std::string_view filepath)
[&vm, &matches_all, &opts](fs::path filepath)
{
for (const auto &regex : vm["regexp"].as<vector<string>>())
{
@ -172,7 +177,7 @@ int main(int argc, char *argv[])
return static_cast<std::uint32_t>(std::ceil(n / 2 + n / 4));
}()};
for (const auto &filepath : vm["input-file"].as<vector<string>>())
for (const auto &filepath : input_files)
{
if (futurepool.size() >= max_threads)
{