示例#1
0
// prepares the file catalogue and searches for given text
void Executive::PrepareCatalogue()
{
	bool IsRecursive = false;
	DataStore ds;
	FileManager Fm(path_, ds);
	Fm.addAllPatterns(Patterns_);
	Arguments::iterator argIter = std::find(Options_.begin(), Options_.end(), "/s");
	if (argIter != Options_.end())
	{
		IsRecursive = true;
	}
	Fm.search(IsRecursive);

	Display dp;
	dp.DisplayCatalogue(ds);

	argIter = std::find(Options_.begin(), Options_.end(), "/d");
	if (argIter != Options_.end())
	{
		dp.DisplayDuplicates(ds);
	}

	argIter = std::find(Options_.begin(), Options_.end(), "/f");
	if (argIter != Options_.end())
	{
		Fm.TextSearch(ds, searchText);
		dp.DisplaySearchFiles(ds, searchText);
	}

	DoSearch(Fm, ds, dp);
}
示例#2
0
// searches for given text and patterns on the catalogue
void Executive::DoSearch(FileManager& Fm, DataStore& ds, Display& dp)
{
	std::string searchString, filePatterns;
	while (1)
	{
		std::cout << "Enter Search String: ";
		std::getline(std::cin, searchString);

		std::cout << "Enter File Patterns: ";
		std::getline(std::cin, filePatterns);

		Fm.addAllPatterns(make_sentence(filePatterns));

		Fm.PatternTextSearch(ds, searchString);
		dp.DisplaySearchFiles(ds, searchString);
	}
}