Browse Source

Configuration: only try reading it when cfg file can be opened

master
Aqua-sama 4 weeks ago
parent
commit
315396cbf7
Signed by: Aqua-sama <aqua@iserlohn-fortress.net> GPG Key ID: 81A99984EABC02D1
1 changed files with 7 additions and 6 deletions
  1. +7
    -6
      src/conf.hpp.in

+ 7
- 6
src/conf.hpp.in View File

@@ -17,16 +17,17 @@

inline void init_conf(const std::string &path)
{
std::fstream fs;
fs.open(path, std::fstream::in);
assert(fs.is_open());

auto value_map = std::make_unique<Configuration, std::initializer_list<std::pair<std::string, conf_value_t>>>({
@conf_init_list@
});
value_map->read(fs);

std::fstream fs;
fs.open(path, std::fstream::in);
if(fs.is_open()) {
value_map->read(fs);
fs.close();
}

Configuration::move_global(std::move(value_map));
fs.close();
}


Loading…
Cancel
Save