MCPcopy Create free account
hub / github.com/AlexandreRouma/SDRPlusPlus / load

Method load

core/src/config.cpp:19–46  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17}
18
19void ConfigManager::load(json def, bool lock) {
20 if (lock) { mtx.lock(); }
21 if (path == "") {
22 spdlog::error("Config manager tried to load file with no path specified");
23 return;
24 }
25 if (!std::filesystem::exists(path)) {
26 spdlog::warn("Config file '{0}' does not exist, creating it", path);
27 conf = def;
28 save(false);
29 }
30 if (!std::filesystem::is_regular_file(path)) {
31 spdlog::error("Config file '{0}' isn't a file", path);
32 return;
33 }
34
35 try {
36 std::ifstream file(path.c_str());
37 file >> conf;
38 file.close();
39 }
40 catch (std::exception e) {
41 spdlog::error("Config file '{0}' is corrupted, resetting it", path);
42 conf = def;
43 save(false);
44 }
45 if (lock) { mtx.unlock(); }
46}
47
48void ConfigManager::save(bool lock) {
49 if (lock) { mtx.lock(); }

Callers 15

_INIT_Function · 0.45
_INIT_Function · 0.45
_INIT_Function · 0.45
_INIT_Function · 0.45
_INIT_Function · 0.45
_INIT_Function · 0.45
_INIT_Function · 0.45
_INIT_Function · 0.45
_INIT_Function · 0.45
_INIT_Function · 0.45
_INIT_Function · 0.45
_INIT_Function · 0.45

Calls 7

saveFunction · 0.85
lockMethod · 0.80
unlockMethod · 0.80
errorFunction · 0.50
warnFunction · 0.50
c_strMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected