Esempio n. 1
0
std::unique_ptr<Project> JsonImporter::ImportProject(FileManager& fileManager, const filesystem::path& projectFile)
{
    auto json = internal::ParseJsonFile(fileManager.GetFileSystem(), projectFile);

    if (internal::IsValidProject(json))
    {
        auto project = std::make_unique<Project>();

        project->SetName(json["project"]);
        project->SetFile(projectFile);

        for (auto& config : json["configs"])
        {
            project->AddConfiguration(internal::ImportConfig(config));
        }

        for (auto& filePath : json["files"])
        {
            project->AddFile(fileManager.GetOrCreateFile(filePath));
        }

        return project;
    }

    return nullptr;
}
Esempio n. 2
0
    void File::ReadDependencies(FileManager& fileManager, const filesystem::path& file)
    {
        auto dependencyFile = fileManager.GetOrCreateFile(file);
        auto dependencyFileStream = fileManager.GetFileSystem().OpenStream(file);

        if (dependencyFileStream)
        {
            std::string line;
            std::getline(*dependencyFileStream, line, ':');

            while (std::getline(*dependencyFileStream, line, '\\'))
            {
                AddDependency(fileManager.GetOrCreateFile(internal::Trim(line)));
            }
        }
    }