diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2005-05-02 11:48:26 +0000 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2005-05-02 11:48:26 +0000 |
commit | 1e5ca1852e059d640a7d2c080a2d7a79d53b37e8 (patch) | |
tree | 52772570ead0b618c781d1f86dd247deba89fee8 /src/configuration.cpp | |
parent | b8dbdb628ba7a07a785e494d0ed76ebfe9e06615 (diff) | |
download | mana-1e5ca1852e059d640a7d2c080a2d7a79d53b37e8.tar.gz mana-1e5ca1852e059d640a7d2c080a2d7a79d53b37e8.tar.bz2 mana-1e5ca1852e059d640a7d2c080a2d7a79d53b37e8.tar.xz mana-1e5ca1852e059d640a7d2c080a2d7a79d53b37e8.zip |
Prettier errors when things go wrong.
Diffstat (limited to 'src/configuration.cpp')
-rw-r--r-- | src/configuration.cpp | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/configuration.cpp b/src/configuration.cpp index 8cacd065..54fe3a1d 100644 --- a/src/configuration.cpp +++ b/src/configuration.cpp @@ -85,8 +85,17 @@ void Configuration::init(const std::string &filename) xmlFreeDoc(doc); } -bool Configuration::write() +void Configuration::write() { + // Do not attempt to write to file that cannot be opened for writing + FILE *testFile = fopen(configPath.c_str(), "w"); + if (!testFile) { + return; + } + else { + fclose(testFile); + } + xmlTextWriterPtr writer = xmlNewTextWriterFilename(configPath.c_str(), 0); if (writer) @@ -112,11 +121,7 @@ bool Configuration::write() xmlTextWriterEndDocument(writer); xmlFreeTextWriter(writer); - - return true; } - - return false; } void Configuration::setValue(const std::string &key, std::string value) |