diff options
Diffstat (limited to 'src/configuration.cpp')
-rw-r--r-- | src/configuration.cpp | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/src/configuration.cpp b/src/configuration.cpp index 1310d642..d8b11034 100644 --- a/src/configuration.cpp +++ b/src/configuration.cpp @@ -137,33 +137,30 @@ void ConfigurationObject::initFromXML(xmlNodePtr parent_node) } } -void Configuration::init(const std::string &filename) +void Configuration::init(const std::string &filename, bool useResManager) { - mConfigPath = filename; + XML::Document doc(filename, useResManager); - // Do not attempt to read config from non-existant file - FILE *testFile = fopen(filename.c_str(), "r"); - if (!testFile) - return; + if (useResManager) + mConfigPath = "PhysFS://" + filename; else - fclose(testFile); - - xmlDocPtr doc = xmlReadFile(filename.c_str(), NULL, 0); + mConfigPath = filename; - if (!doc) return; + if (!doc.rootNode()) + { + logger->log("Couldn't open configuration file: %s", filename.c_str()); + return; + } - xmlNodePtr rootNode = xmlDocGetRootElement(doc); + xmlNodePtr rootNode = doc.rootNode(); if (!rootNode || !xmlStrEqual(rootNode->name, BAD_CAST "configuration")) { logger->log("Warning: No configuration file (%s)", filename.c_str()); - xmlFreeDoc(doc); return; } initFromXML(rootNode); - - xmlFreeDoc(doc); } void ConfigurationObject::writeToXML(xmlTextWriterPtr writer) |