summaryrefslogtreecommitdiff
path: root/src/utils/xml.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils/xml.cpp')
-rw-r--r--src/utils/xml.cpp35
1 files changed, 32 insertions, 3 deletions
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 <iostream>
+#include <fstream>
+
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);