diff options
| author | Carl Hetherington <cth@carlh.net> | 2018-11-28 23:30:48 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2018-11-28 23:30:48 +0000 |
| commit | 0d487c87a4f61324256e13686f19db3c5dd4d826 (patch) | |
| tree | afab96c039a3de6c99902c579c9857456baf7fe9 /src | |
| parent | 45fa2b3c94069c3449b9210b750c2b0391fa9244 (diff) | |
Write config.xml with CR/LF terminators on Windows.
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/config.cc | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/lib/config.cc b/src/lib/config.cc index 489e66db9..ddb4bf25a 100644 --- a/src/lib/config.cc +++ b/src/lib/config.cc @@ -947,11 +947,22 @@ Config::write_config () const #endif try { - doc.write_to_file_formatted(config_file().string()); + string const s = doc.write_to_string_formatted (); + boost::filesystem::path const cf = config_file (); + FILE* f = fopen_boost (cf, "w"); + if (!f) { + throw FileError (_("Could not open file for writing"), cf); + } + size_t const w = fwrite (s.c_str(), 1, s.length(), f); + if (w != s.length()) { + fclose (f); + throw FileError (_("Could not write whole file"), cf); + } + fclose (f); } catch (xmlpp::exception& e) { string s = e.what (); trim (s); - throw FileError (s, path("config.xml")); + throw FileError (s, config_file()); } } |
