From 8eadc834ed3e8439836f7dc87390a56a1164ec11 Mon Sep 17 00:00:00 2001 From: Jared Adams Date: Fri, 13 Aug 2010 14:45:52 -0600 Subject: 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 --- src/utils/xml.cpp | 25 +++---------------------- 1 file changed, 3 insertions(+), 22 deletions(-) (limited to 'src/utils/xml.cpp') 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 #include -#include -#include - 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) -- cgit v1.2.3-70-g09d2