| 441 | } |
| 442 | |
| 443 | command_result FilterManager::loadConfig(DFHack::color_ostream& out) noexcept |
| 444 | { |
| 445 | nextId_ = 1; |
| 446 | if (!Filesystem::isfile(configPath)) |
| 447 | return CR_OK; |
| 448 | try { |
| 449 | DEBUG(command, out) << "Load config from '" << configPath << "'" << std::endl; |
| 450 | JsonArchive archive; |
| 451 | std::ifstream ifs(configPath); |
| 452 | if (!ifs.good()) |
| 453 | throw std::runtime_error{"Failed to open configuration file for reading"}; |
| 454 | ifs >> archive; |
| 455 | load(archive); |
| 456 | } catch(std::exception& e) { |
| 457 | ERR(command, out) << "Serializing filters from '" << configPath << "' failed: " |
| 458 | << e.what() << std::endl; |
| 459 | return CR_FAILURE; |
| 460 | } |
| 461 | return CR_OK; |
| 462 | } |
| 463 | |
| 464 | command_result FilterManager::saveConfig(DFHack::color_ostream& out) const noexcept |
| 465 | { |
no test coverage detected