Example #1
0
    void ZendParser::parse() {
        setupReader();

        getReader()->removeDir(outputDir);
        getReader()->createDir(outputDir);

        if (isRecurisve())
            getReader()->read(getReader()->getPath(), "/");
        else
            getReader()->read();

        vector<DirectoryReader::Item> *readerResult = reader->getResults();

        int generated = 0, processed = 0;
        vector<string> tmpOut, tmpVector;
        set<string> tmpSet;
        vector<pair<string, string>> tmpOutPairs;
        File file;

        buildFiles(file, tmpOut, processed, readerResult, tmpOutPairs, tmpVector);

        filterPreparedTypes(*typesRegistryUnfiltered, *typesRegistry);
        generatePreparedTypesGlobal(tmpVector);

        writeFiles(tmpSet, generated);

        writeTypesRegistryFile();

        cout << "\n";
        cout << "files processed : " << processed << "\n";
        cout << "types found : " << typesRegistry->size() << "\n";
        cout << "files generated : " << generated << "\n";
        cout << "\n";
        cout << "finished...";
    }
Example #2
0
bool updateProject(Output* output, const char* path)
{
	auto start = std::chrono::high_resolution_clock::now();

    output->print("Updating %s:\n", path);

	std::unique_ptr<ProjectGroup> group = parseProject(output, path);
	if (!group)
		return false;

	removeFile(replaceExtension(path, ".qgc").c_str());

	output->print("Scanning project...\r");

	std::vector<FileInfo> files = getProjectGroupFiles(output, group.get());

	output->print("Building file table...\r");

	if (!buildFiles(output, path, files))
		return false;
	
	std::string targetPath = replaceExtension(path, ".qgd");
	std::string tempPath = targetPath + "_";

	UpdateStatistics stats = {};
	unsigned int totalChunks = 0;

	{
		BuildContext* builder = buildStart(output, tempPath.c_str(), files.size());
		if (!builder)
			return false;

		UpdateFileIterator fileit = {files, 0};

		// update contents using existing database (if any)
		if (!processFile(output, builder, fileit, stats, targetPath.c_str()))
		{
			buildFinish(builder);
			return false;
		}

		// update all unprocessed files
		while (fileit)
		{
			buildAppendFile(builder, fileit->path.c_str(), fileit->timeStamp, fileit->fileSize);
			++fileit;
			stats.filesAdded++;
		}

		totalChunks = buildFinish(builder);
	}

	output->print("\n");

	auto time = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::high_resolution_clock::now() - start);

	printStatistics(output, stats, totalChunks, time.count() / 1e3);
	
	if (!renameFile(tempPath.c_str(), targetPath.c_str()))
	{
		output->error("Error saving data file %s\n", targetPath.c_str());
		return false;
	}

	return true;
}