Esempio n. 1
0
RCType
startTraceGen(int argc, char *argv[])
{
	RCType rc = RC_OK;
	Path *dir = NULL;

	if (RC_OK == help(argc, argv)) {
		return RC_OK;
	}

	J9TDFOptions options;
	TraceGen tracegen;
	ArgParser argParser;

	rc = argParser.parseOptions(argc, argv, &options);
	if (RC_OK != rc) {
		FileUtils::printError("Failed to parse command line options\n");
		goto failed;
	}

	if (options.force) {
		printf("tracegen -force option is enabled. All files will be regenerated.\n");
	}

	dir = options.rootDirectory;
	while (NULL != dir) {
		/* Recursively visit all directories under dirName, processing TDF files */
		if (RC_OK != FileUtils::visitDirectory(&options, dir->path, TDF_FILE_EXT, &tracegen, TraceGen::generateCallBack)) {
			FileUtils::printError("Failed to generate trace files\n");
			goto failed;
		}
		dir = dir->next;
	}
	tracegen.tearDown();
	argParser.freeOptions(&options);
	return rc;
failed:
	tracegen.tearDown();
	argParser.freeOptions(&options);
	return RC_FAILED;
}