| 159 | constexpr auto app_name = L"SpellCheck"; |
| 160 | |
| 161 | void 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 | |
| 187 | void Settings::load() { |
| 188 | if (m_ini_filepath.empty()) |
no test coverage detected