summaryrefslogtreecommitdiff
path: root/src/configuration.cpp
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2005-05-02 11:48:26 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2005-05-02 11:48:26 +0000
commit1e5ca1852e059d640a7d2c080a2d7a79d53b37e8 (patch)
tree52772570ead0b618c781d1f86dd247deba89fee8 /src/configuration.cpp
parentb8dbdb628ba7a07a785e494d0ed76ebfe9e06615 (diff)
downloadmana-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.cpp15
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)