int main(int argc, char * argv[]) { DataStore dataStore; Display display; string path; vector<string>options; vector<string>pattern; vector<string> files; Executive executive; if (argc == 1) path = "."; else { path = argv[1]; std::string pathTest = FileSystem::Path::getFullFileSpec(path); DWORD ftyp = GetFileAttributesA(pathTest.c_str()); //checks if user has provided path or not if (ftyp == INVALID_FILE_ATTRIBUTES) path = "."; } pattern = executive.processArgumentsPattern(argv, argc); options = executive.processArgumentOptions(argv, argc); if (pattern.size() == 0) pattern.push_back("*.*"); FileManager fileManager(options, pattern); fileManager.search(path, dataStore); map <string, list<DataStore::PathIter>> mapVal = dataStore.dispMap(); int number_of_directories = fileManager.number_of_dir(); int number_of_file = fileManager.number_of_files(); display.displayHandle(options, number_of_file, number_of_directories, mapVal, files, dataStore); int flag = 1; while (flag) { //options.clear(); pattern.clear(); dataStore.clear(); cin.clear(); fflush(stdin); cout << endl << "================================================================================"; cout << "================================================================================" << endl; cout << "**************User Inputs**************" << endl; cout << endl << "================================================================================"; cout << "================================================================================" << endl; cout << endl << "Please enter the text you want to search OR press enter to exit" << endl << endl; string input = ""; //cin>> input; input = cin.get(); if (input == "\n") //.empty()) { cout << "\n Exiting as no text is entered!!" << endl; break; } cout << "\n Please enter file pattern(s) in which text needs to be searched" << endl; cin.clear(); fflush(stdin); string newPattern = ""; getline(cin,newPattern); istringstream iss(newPattern); vector<string> tokens{ istream_iterator < string > {iss}, istream_iterator < string > {} }; regex r("[A-Za-z\\*]+\\.[A-Za-z\\*]+$"); for (string tok : tokens) { if (regex_match(tok, r)) pattern.push_back(tok); } if (pattern.size() == 0) pattern.push_back("*.*"); string a = "/f<" + input + ">"; //options.push_back("/d"); std::vector<string>::iterator iter = options.begin(); while (iter != options.end()) { if (*iter == a) iter = options.erase(iter); else iter++; } options.push_back(a); map<string, int> m; for (auto & i : options) m[i]++; options.clear(); for (auto & i : m) if (i.second == 1) options.push_back(i.first); FileManager fileManager(options, pattern); fileManager.search(path, dataStore); map <string, list<DataStore::PathIter>> mapVal = dataStore.dispMap(); int number_of_directories = fileManager.number_of_dir(); int number_of_file = fileManager.number_of_files(); display.displayHandle(options, number_of_file, number_of_directories, mapVal, files, dataStore); options.pop_back(); cout << "\n Press Enter to Exit and Press spacebar to Continue (Search an other text) \n"; //cin >> flag; string case_ = ""; case_ = cin.get(); if (case_ == "\n") //atoi(case_.c_str())) // "") { flag = 0; } } system("pause"); return 0; }