Line data Source code
1 : /*! 2 : * \file esys/repo/manifest/loaderesysrepo_manifest.cpp 3 : * \brief 4 : * 5 : * \cond 6 : * __legal_b__ 7 : * 8 : * Copyright (c) 2020-2021 Michel Gillet 9 : * Distributed under the MIT License. 10 : * (See accompanying file LICENSE.txt or 11 : * copy at https://opensource.org/licenses/MIT) 12 : * 13 : * __legal_e__ 14 : * \endcond 15 : * 16 : */ 17 : 18 : #include "esys/repo/esysrepo_prec.h" 19 : #include "esys/repo/manifest/loaderesysrepo.h" 20 : #include "esys/repo/manifest/file.h" 21 : 22 : #include <boost/filesystem.hpp> 23 : 24 : namespace esys::repo::manifest 25 : { 26 : 27 16 : LoaderESysRepo::LoaderESysRepo() 28 16 : : LoaderBase() 29 : { 30 16 : } 31 : 32 16 : LoaderESysRepo::~LoaderESysRepo() = default; 33 : 34 16 : Result LoaderESysRepo::run() 35 : { 36 32 : if (get_config_folder() == nullptr) return ESYSREPO_RESULT(ResultCode::INTERNAL_ERROR); 37 48 : if (get_config_folder()->get_config() == nullptr) return ESYSREPO_RESULT(ResultCode::INTERNAL_ERROR); 38 48 : if (get_config_folder()->get_config()->get_manifest_type() != manifest::Type::ESYSREPO_MANIFEST) 39 0 : return ESYSREPO_RESULT(ResultCode::INTERNAL_ERROR); 40 48 : if (get_config_folder()->get_config()->get_manifest_path().empty()) 41 0 : return ESYSREPO_RESULT(ResultCode::INTERNAL_ERROR); 42 : 43 16 : boost::filesystem::path path; 44 16 : manifest::File loader; 45 : 46 32 : path = get_config_folder()->get_path(); 47 32 : path /= get_config_folder()->get_config()->get_manifest_path(); 48 48 : path = boost::filesystem::absolute(path).make_preferred(); 49 : 50 32 : if (get_manifest() == nullptr) set_manifest(std::make_shared<Manifest>()); 51 : 52 16 : loader.set_data(get_manifest()); 53 32 : loader.set_parse_mode(get_config_folder()->get_config()->get_parse_mode()); 54 : 55 32 : boost::filesystem::path rel_path = boost::filesystem::relative(path); 56 : 57 16 : Result result = loader.read(path.string()); 58 16 : if (result.error()) 59 0 : error("Couldn't load ESysRepo manifest : " + rel_path.string()); 60 : else 61 32 : debug(0, "Loaded ESysRepo manifest : " + rel_path.string()); 62 : 63 32 : return ESYSREPO_RESULT(result); 64 32 : } 65 : 66 : } // namespace esys::repo::manifest