Wildmeshing Toolkit
import_cache.cpp
Go to the documentation of this file.
1 #include "import_cache.hpp"
2 
4 #include <wmtk/utils/Logger.hpp>
5 
6 #include "ImportCacheOptions.hpp"
7 
8 namespace wmtk::components {
9 
10 void import_cache(const utils::Paths& paths, const nlohmann::json& j, io::Cache& cache)
11 {
12  using namespace internal;
13 
14  ImportCacheOptions options = j.get<ImportCacheOptions>();
15 
16  std::string import_location =
17  wmtk::utils::resolve_path(options.folder.string(), paths.root_path);
18 
19  if (!std::filesystem::exists(import_location)) {
20  log_and_throw_error("Cannot import cache, folder {} does not exist", import_location);
21  }
22 
23  if (!cache.import_cache(import_location)) {
24  log_and_throw_error("Could not import cache from {}", import_location);
25  }
26 }
27 } // namespace wmtk::components
bool import_cache(const std::filesystem::path &import_location)
Import a cache from the given location.
Definition: Cache.cpp:263
fs::path resolve_path(const fs::path &root, const fs::path &path)
void import_cache(const utils::Paths &paths, const nlohmann::json &j, io::Cache &cache)
void log_and_throw_error(const std::string &msg)
Definition: Logger.cpp:101
nlohmann::json json
Definition: input.cpp:9