-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
40 lines (32 loc) · 924 Bytes
/
Copy pathmain.cpp
File metadata and controls
40 lines (32 loc) · 924 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include <iostream>
#include <vector>
#include <set>
#include <unordered_set>
#include <string>
#include <sstream>
#include <algorithm>
#include <thread>
#include "constants.h"
#include "file_search.h"
#include "search_worker.h"
#include "arg_parser.h"
#include "utils.h"
int main(int argc, char* argv[]) {
std::string pattern;
std::set<std::string> extensions;
int threads;
bool show_details = false;
if (!parse_args(argc, argv, pattern, extensions, threads, show_details)) {
std::cerr << kInvalidArgsMsg;
return 1;
}
auto files = get_files_with_extensions(".", extensions);
if (show_details) {
int file_sz = files.size();
std::thread::id curr_thread = std::this_thread::get_id();
print_details(threads, curr_thread, file_sz);
}
auto results = search_files_thread_pool(files, pattern, threads, show_details);
print_output(results, show_details);
return 0;
}