MCPcopy Create free account
hub / github.com/CalcProgrammer1/OpenRGB / LoadSettings

Method LoadSettings

SettingsManager.cpp:53–93  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

51}
52
53void SettingsManager::LoadSettings(const filesystem::path& filename)
54{
55 /*---------------------------------------------------------*\
56 | Clear any stored settings before loading |
57 \*---------------------------------------------------------*/
58 settings_data.clear();
59
60 /*---------------------------------------------------------*\
61 | Store settings filename, so we can save to it later |
62 \*---------------------------------------------------------*/
63 settings_filename = filename;
64
65 /*---------------------------------------------------------*\
66 | Open input file in binary mode |
67 \*---------------------------------------------------------*/
68 std::ifstream settings_file(settings_filename, std::ios::in | std::ios::binary);
69
70 /*---------------------------------------------------------*\
71 | Read settings into JSON store |
72 \*---------------------------------------------------------*/
73 if(settings_file)
74 {
75 try
76 {
77 settings_file >> settings_data;
78 }
79 catch(const std::exception& e)
80 {
81 /*-------------------------------------------------*\
82 | If an exception was caught, that means the JSON |
83 | parsing failed. Clear out any data in the store |
84 | as it is corrupt. |
85 \*-------------------------------------------------*/
86 LOG_ERROR("[SettingsManager] JSON parsing failed: %s", e.what());
87
88 settings_data.clear();
89 }
90 }
91
92 settings_file.close();
93}
94
95void SettingsManager::SaveSettings()
96{

Callers 2

ResourceManagerMethod · 0.80

Calls 1

whatMethod · 0.45

Tested by

no test coverage detected