コード例 #1
0
int main(int argc, char* argv[]) {
	string a = Directory::getCurrentDirectory();
	cout << a;
	FileManager fileManager;
	vector<string> files = fileManager.getFiles(a, "*.h");
	for (int i = 0; i < files.size(); i++)
		cout << endl << files[i];
	return 0;
}
コード例 #2
0
int main(int argc, char* argv[])
{
	//collecting tokens from files, named on the command line
	if (argc < 2)
	{
		std::cout<< "\n  please enter name of file to process on command line\n\n";
		return 1;
	}
	FileManager fileManager;
	std::vector<std::string> patterns = { "*.h" , "*.cpp" };
	std::vector<std::string> files = fileManager.getFiles("..//", patterns);
	for (int i = 1; i<argc; ++i)
	{
		std::string fileSpec = FileSystem::Path::getFullFileSpec(argv[i]);
		std::string msg = "Processing file" + fileSpec;		
		ConfigParseToConsole configure;
		Parser* pParser = configure.Build();
		MetricAnalyzer *test = new MetricAnalyzer;
		try		{
			if (pParser)			{
				if (!configure.Attach(argv[i]))
				{
					std::cout << "\n  could not open file " << fileSpec << std::endl;
					continue;
				}
			}
			else
			{
				std::cout << "\n\n  Parser not built\n\n";
				return 1;
			}
			while (pParser->next())
			{
				pParser->parse();

			}
			std::cout << "\n";
			configure.printTree();
			test->setRoot(configure.getRoot());
			test->getComplexity(test->getRoot());
			test->getComplexity(test->getRoot());
		}
		catch (std::exception& ex)
		{
			std::cout << "\n\n    " << ex.what() << "\n\n";
		}
	}
}
コード例 #3
0
//Get filepaths for a particular version
vector<string> Repository::getFilesinVersion(string version) {
	vector<sPtr> versionVector = _packagesInfo->element("Version").select();
	string resultDirectory;
	for (auto eachVersion : versionVector) {
		string versionName = eachVersion->getAttrib("Name");
		if (versionName == version) {
			resultDirectory = eachVersion->getAttrib("Directory");
			break;
		}
	}

	vector<string> files;
	if (resultDirectory != ""&&resultDirectory != " ") {
		FileManager fileManager;
		vector<string> patterns = { "*.h", "*.cpp" };
		files = fileManager.getFiles(resultDirectory, patterns);
	}
	return files;
}
コード例 #4
0
//Return filepaths for files in package
vector<string> Repository::getPathsforFilesinPackage(string dirctry, bool recursion) {
	string resultDirectory;
	sPtr resultVersion = getLatestPackageVersion(dirctry);
	if (resultVersion) {
		resultDirectory = resultVersion->getAttrib("Directory");
	}
	vector<string> files;
	cout << "\nChecking files in directory:" << resultDirectory;
	if (resultDirectory != ""&&resultDirectory != " ") {
		FileManager fileManager;
		vector<string> patterns = { "*.h", "*.cpp" };
		files = fileManager.getFiles(resultDirectory, patterns);
	}
	if (recursion) {
		vector<string> dependentFiles = getDependentFiles(resultDirectory);
		if (dependentFiles.size() > 0) {
			files.insert(files.end(), dependentFiles.begin(), dependentFiles.end());
		}
	}
	return files;
}