summaryrefslogtreecommitdiff
path: root/src
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
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')
-rw-r--r--src/configuration.cpp15
-rw-r--r--src/configuration.h2
-rw-r--r--src/log.cpp3
-rw-r--r--src/main.cpp7
4 files changed, 18 insertions, 9 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)
diff --git a/src/configuration.h b/src/configuration.h
index e6959ee5..719ee711 100644
--- a/src/configuration.h
+++ b/src/configuration.h
@@ -58,7 +58,7 @@ class Configuration {
* \brief Writes the current settings back to an ini-file.
* \param filename Full path to INI file (~/.manaworld/tmw.ini)
*/
- bool write();
+ void write();
/**
* \brief Sets an option using a string value.
diff --git a/src/log.cpp b/src/log.cpp
index df7b4fd5..d71c55d6 100644
--- a/src/log.cpp
+++ b/src/log.cpp
@@ -33,7 +33,8 @@ Logger::Logger(const std::string &logFilename)
if (!logFile.is_open())
{
- std::cout << "Warning: error while opening log file.\n";
+ std::cout << "Warning: error while opening " << logFilename <<
+ " for writing.\n";
}
}
diff --git a/src/main.cpp b/src/main.cpp
index 16a97e61..ce45b460 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -170,10 +170,9 @@ void init_engine()
// If we can't read it, it doesn't exist !
if (tmwFile == NULL) {
// We reopen the file in write mode and we create it
- printf("No file : %s\n, Creating Default Options...\n", configPath);
tmwFile = fopen(configPath, "wt");
if (tmwFile == NULL) {
- printf("Can't create %s file. Using Defaults.\n", configPath);
+ printf("Can't create %s. Using Defaults.\n", configPath);
}
else {
fclose(tmwFile);
@@ -319,6 +318,10 @@ int main(int argc, char *argv[])
xmlInitParser();
LIBXML_TEST_VERSION;
+ // Redirect libxml errors to /dev/null
+ FILE *nullFile = fopen("/dev/null", "w");
+ xmlSetGenericErrorFunc(nullFile, NULL);
+
// Initialize PhysicsFS
PHYSFS_init(argv[0]);