MCPcopy Create free account
hub / github.com/BeneficialCode/WinArk / LoadFromFile

Method LoadFromFile

WinArk/Settings.cpp:65–100  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

63}
64
65bool Settings::LoadFromFile(PCWSTR path) {
66 if (path == nullptr)
67 path = _path.c_str();
68
69 ATLASSERT(path);
70 if (path == nullptr)
71 return false;
72 else
73 _path = path;
74
75 IniFile file(path);
76 if (!file.IsValid())
77 return false;
78
79 PCWSTR section = L"General";
80 for (auto& [name, setting] : _settings) {
81 switch (setting.Type) {
82 case SettingType::String:
83 setting.SetString(file.ReadString(section, name.c_str()));
84 break;
85
86 case SettingType::Int32:
87 setting.Set<int>(file.ReadInt(section, name.c_str()));
88 break;
89
90 default:
91 unsigned size;
92 auto data = file.ReadBinary(section, name.c_str(), size);
93 if (data && size > 0)
94 setting.Set(data.get(), size);
95 break;
96 }
97 }
98
99 return true;
100}
101
102bool Settings::SaveToFile(PCWSTR path) const {
103 if (path == nullptr)

Callers

nothing calls this directly

Calls 6

SetStringMethod · 0.80
ReadStringMethod · 0.80
ReadIntMethod · 0.80
ReadBinaryMethod · 0.80
IsValidMethod · 0.45
SetMethod · 0.45

Tested by

no test coverage detected