From cbc14c8a3c6614987d2331057e114d92336cbac0 Mon Sep 17 00:00:00 2001 From: Chuck Miller Date: Sat, 19 Dec 2009 04:40:42 -0500 Subject: Added support for resources.xml from update server... Also added option to download music optionally I had to edit the XML wrapper a bit, basicilly its constructor can now take a optional thrid arguement which will tell it to use a resman or open the file directly Also I added fallback support for the old resouce2.txt so servers don't have to upgrade if they do not want to --- src/utils/xml.cpp | 35 ++++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) (limited to 'src/utils/xml.cpp') diff --git a/src/utils/xml.cpp b/src/utils/xml.cpp index 7a6f75de..4d85e87f 100644 --- a/src/utils/xml.cpp +++ b/src/utils/xml.cpp @@ -25,14 +25,43 @@ #include "resources/resourcemanager.h" +#include +#include + namespace XML { - Document::Document(const std::string &filename): + Document::Document(const std::string &filename, bool useResman): mDoc(0) { int size; - ResourceManager *resman = ResourceManager::getInstance(); - char *data = (char*) resman->loadFile(filename.c_str(), size); + char *data; + if (useResman) + { + ResourceManager *resman = ResourceManager::getInstance(); + data = (char*) resman->loadFile(filename.c_str(), size); + } + else + { + std::ifstream file; + file.open(filename.c_str(), std::ios::in); + + if (file.is_open()) + { + // Get length of file + file.seekg (0, std::ios::end); + size = file.tellg(); + file.seekg(0, std::ios::beg); + + data = new char[size]; + + file.read(data, size); + file.close(); + } + else + { + logger->log("Error loading XML file %s", filename.c_str()); + } + } if (data) { mDoc = xmlParseMemory(data, size); -- cgit v1.2.3-70-g09d2