summaryrefslogtreecommitdiff
path: root/src/utils/xml.cpp
diff options
context:
space:
mode:
authorJared Adams <jaxad0127@gmail.com>2010-08-13 14:45:52 -0600
committerJared Adams <jaxad0127@gmail.com>2010-08-13 18:43:16 -0600
commit8eadc834ed3e8439836f7dc87390a56a1164ec11 (patch)
tree36cf9915914517b137d488a40d1f61265867723d /src/utils/xml.cpp
parent6d315d0e61f419636021476582a49ab0b1f1b5e9 (diff)
downloadMana-8eadc834ed3e8439836f7dc87390a56a1164ec11.tar.gz
Mana-8eadc834ed3e8439836f7dc87390a56a1164ec11.tar.bz2
Mana-8eadc834ed3e8439836f7dc87390a56a1164ec11.tar.xz
Mana-8eadc834ed3e8439836f7dc87390a56a1164ec11.zip
Simplify handling of compressed files
ResourceManager will now check for ".gz" and act appropriately (unless told not to). Compression handling functions are now in new utils/zlib files, along with a function to load a file from drive, uncompressing it if it ends in ".gz". Reviewed-by: Freeyorp
Diffstat (limited to 'src/utils/xml.cpp')
-rw-r--r--src/utils/xml.cpp25
1 files changed, 3 insertions, 22 deletions
diff --git a/src/utils/xml.cpp b/src/utils/xml.cpp
index 8d444fab..9835f88c 100644
--- a/src/utils/xml.cpp
+++ b/src/utils/xml.cpp
@@ -25,12 +25,11 @@
#include "resources/resourcemanager.h"
+#include "utils/zlib.h"
+
#include <libxml/parser.h>
#include <libxml/xmlerror.h>
-#include <fstream>
-#include <iostream>
-
namespace XML
{
static void xmlLogger(void *ctx, xmlErrorPtr error);
@@ -58,25 +57,7 @@ namespace XML
}
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 = (char*) malloc(size);
-
- file.read(data, size);
- file.close();
- }
- else
- {
- logger->log("Error loading XML file %s", filename.c_str());
- }
+ data = (char *) loadCompressedFile(filename, size);
}
if (data)