Wildmeshing Toolkit
export_cache.cpp
Go to the documentation of this file.
1 #include "export_cache.hpp"
2 
4 #include <wmtk/utils/Logger.hpp>
5 
6 #include "ExportCacheOptions.hpp"
7 
8 namespace wmtk::components {
9 
10 void export_cache(const utils::Paths& paths, const nlohmann::json& j, io::Cache& cache)
11 {
12  using namespace internal;
13 
14  ExportCacheOptions options = j.get<ExportCacheOptions>();
15 
16  std::string export_location =
17  wmtk::utils::resolve_path(options.folder.string(), paths.root_path);
18 
19  if (std::filesystem::exists(export_location)) {
20  log_and_throw_error("Cannot export cache, folder {} already exists", export_location);
21  }
22 
23  if (!cache.export_cache(export_location)) {
24  log_and_throw_error("Could not export cache from {}", export_location);
25  }
26 }
27 } // namespace wmtk::components
bool export_cache(const std::filesystem::path &export_location)
Export the cache to the given location.
Definition: Cache.cpp:232
fs::path resolve_path(const fs::path &root, const fs::path &path)
void export_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