From abde0f51b3062c158fb52e9dfff23d21d3be03d1 Mon Sep 17 00:00:00 2001 From: Yohann Ferreira Date: Sun, 11 Jul 2010 20:05:44 +0200 Subject: Made the different hard-coded paths and files be now taken from the data/paths.xml configuration file. Also added default gui theme path in branding and default wallpaper path and file searched respectively in the branding and paths.xml files. Hard-coded values are still used as fallbacks. Resolves: Manasource Mantis #148. Reviewed-by: jaxad0127. --- src/configuration.cpp | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) (limited to 'src/configuration.cpp') diff --git a/src/configuration.cpp b/src/configuration.cpp index 1310d642..cd31fed7 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) + if (!doc.rootNode()) + { + logger->log("Couldn't open configuration file: %s", filename.c_str()); return; - else - fclose(testFile); - - xmlDocPtr doc = xmlReadFile(filename.c_str(), NULL, 0); + } - if (!doc) return; + if (useResManager) + mConfigPath = "PhysFS://" + filename; + else + mConfigPath = filename; - 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) -- cgit v1.2.3-70-g09d2