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

Method SaveToFile

WinArk/Settings.cpp:102–128  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

100}
101
102bool Settings::SaveToFile(PCWSTR path) const {
103 if (path == nullptr)
104 path = _path.c_str();
105
106 ATLASSERT(path);
107 if (path == nullptr)
108 return false;
109
110 IniFile file(path);
111 PCWSTR section = L"General";
112 for (auto& [name, setting] : _settings) {
113 switch (setting.Type) {
114 case SettingType::String:
115 file.WriteString(section, name.c_str(), (PCWSTR)setting.Buffer.get());
116 break;
117
118 case SettingType::Int32:
119 file.WriteInt(section, name.c_str(), *(DWORD*)setting.Buffer.get());
120 break;
121
122 default:
123 file.WriteBinary(section, name.c_str(), setting.Buffer.get(), setting.Size);
124 break;
125 }
126 }
127 return true;
128}
129
130bool Settings::Load(PCWSTR path) {
131 WCHAR fullpath[MAX_PATH];

Callers

nothing calls this directly

Calls 3

WriteIntMethod · 0.80
WriteBinaryMethod · 0.80
WriteStringMethod · 0.45

Tested by

no test coverage detected