MCPcopy Create free account
hub / github.com/Predelnik/DSpellCheck / save

Method save

src/plugin/Settings.cpp:161–185  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

159constexpr auto app_name = L"SpellCheck";
160
161void Settings::save(SettingsModificationStyle modification_style) {
162 if (m_ini_filepath.empty())
163 return;
164 FILE *fp;
165 auto path = std::wstring_view(m_ini_filepath);
166 path.remove_suffix(path.length() - path.rfind(L'\\'));
167 check_for_directory_existence(std::wstring(path));
168 // Cleaning settings file (or creating it)
169 if (_wfopen_s(&fp, m_ini_filepath.c_str(), L"w") != NULL) {
170 if (modification_style == SettingsModificationStyle::ignore_file_errors)
171 return;
172
173 MessageBox(nullptr,
174 wstring_printf(L"Setting file %s cannot be written. All settings will "
175 L"be lost when you close Notepad++.",
176 m_ini_filepath.c_str())
177 .c_str(),
178 L"Saving of Settings Failed", MB_OK | MB_ICONHAND);
179 return;
180 }
181 write_unicode_bom(fp);
182 fclose(fp);
183 IniWorker worker(app_name, m_ini_filepath, IniWorker::Action::save);
184 process(worker);
185}
186
187void Settings::load() {
188 if (m_ini_filepath.empty())

Callers 1

modifyMethod · 0.80

Calls 5

wstring_printfFunction · 0.85
write_unicode_bomFunction · 0.85
c_strMethod · 0.80
emptyMethod · 0.45

Tested by

no test coverage detected