Добавил:
itan_hunt
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз:
Предмет:
Файл:lab6 / findInNames
.cpp#include "Aho_Corasick.h"
#include <iostream>
#include <string>
#include <set>
#include <queue>
#include <experimental/filesystem>
using namespace std;
using namespace std::experimental::filesystem;
int main(int argc, char const *argv[]) {
locale::global(locale(""));
if (argc > 2) {
set<wstring> patterns;
for(int i = 2; i < argc; i++) {
string buffer(argv[i]);
wstring wstringBuffer(buffer.begin(), buffer.end());
patterns.emplace(wstringBuffer);
}
Trie trie(patterns);
path myPath(argv[1]);
queue<path> myQueue;
myQueue.push(myPath);
while(!myQueue.empty()) {
myPath = myQueue.front();
myQueue.pop();
string filename = myPath.filename();
wstring wstringFilename(filename.begin(), filename.end());
if (!AhoCorasick(wstringFilename, trie).empty()) {
cout << myPath.parent_path() << "/" << myPath.filename() << endl;
}
if (is_directory(myPath)) {
for(auto& fileOrFolder: directory_iterator(myPath)) {
myQueue.push(fileOrFolder);
}
}
}
} else {
cout << L"Too few arguments. Try again." << endl;
}
return 0;
}
Соседние файлы в папке lab6