/****************************************************************************** Copyright (C) 2019-2020 by Dillon Pentz This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . ******************************************************************************/ #include "importers.hpp" #include using namespace std; using namespace json11; vector> importers; void ImportersInit() { importers.clear(); importers.push_back(make_unique()); importers.push_back(make_unique()); importers.push_back(make_unique()); importers.push_back(make_unique()); } int ImportSCFromProg(const string &path, string &name, const string &program, Json &res) { if (!os_file_exists(path.c_str())) { return IMPORTER_FILE_NOT_FOUND; } for (size_t i = 0; i < importers.size(); i++) { if (program == importers[i]->Prog()) { return importers[i]->ImportScenes(path, name, res); } } return IMPORTER_UNKNOWN_ERROR; } int ImportSC(const string &path, std::string &name, Json &res) { if (!os_file_exists(path.c_str())) { return IMPORTER_FILE_NOT_FOUND; } string prog = DetectProgram(path); if (prog == "Null") { return IMPORTER_FILE_NOT_RECOGNISED; } return ImportSCFromProg(path, name, prog, res); } string DetectProgram(const string &path) { if (!os_file_exists(path.c_str())) { return "Null"; } for (size_t i = 0; i < importers.size(); i++) { if (importers[i]->Check(path)) { return importers[i]->Prog(); } } return "Null"; } string GetSCName(const string &path, const string &prog) { for (size_t i = 0; i < importers.size(); i++) { if (importers[i]->Prog() == prog) { return importers[i]->Name(path); } } return "Null"; } OBSImporterFiles ImportersFindFiles() { OBSImporterFiles f; for (size_t i = 0; i < importers.size(); i++) { OBSImporterFiles f2 = importers[i]->FindFiles(); if (f2.size() != 0) { f.insert(f.end(), f2.begin(), f2.end()); } } return f; }