| 100 | } |
| 101 | |
| 102 | bool 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 | |
| 130 | bool Settings::Load(PCWSTR path) { |
| 131 | WCHAR fullpath[MAX_PATH]; |
nothing calls this directly
no test coverage detected