summaryrefslogtreecommitdiff
path: root/src/utils/xml.cpp
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <bjorn@lindeijer.nl>2025-02-17 09:47:51 +0100
committerThorbjørn Lindeijer <bjorn@lindeijer.nl>2025-02-17 14:53:14 +0100
commit5c12ec8153cd401a99f505e39389f8450a625eab (patch)
treedcbb4495ef1fda11b90c1463474c5c37860d9059 /src/utils/xml.cpp
parentd6b9d10defba85456939d71044132eb164a78790 (diff)
downloadmana-5c12ec8153cd401a99f505e39389f8450a625eab.tar.gz
mana-5c12ec8153cd401a99f505e39389f8450a625eab.tar.bz2
mana-5c12ec8153cd401a99f505e39389f8450a625eab.tar.xz
mana-5c12ec8153cd401a99f505e39389f8450a625eab.zip
Further ResourceManager and PhysFS cleanups
* Wrapped remaining PhysFS API calls and set PHYSFS_DEPRECATED to suppress deprecation warnings for PHYSFS_getUserDir, since no alternative is available for now. * Removed support for decompressing .gz files, since it has been unused for years and doesn't seem useful when updates are anyway served in an archive. * Use SDL_LoadFile and SDL_LoadFile_RW convenience functions (raises minimum SDL version to 2.0.10). * Removed ResourceManager::copyFile, since it was unused and will likely stay unused. * Removed ResourceManager::loadTextFile. Instead, split up the string in BrowserBox::addRows without making additional copies.
Diffstat (limited to 'src/utils/xml.cpp')
-rw-r--r--src/utils/xml.cpp24
1 files changed, 8 insertions, 16 deletions
diff --git a/src/utils/xml.cpp b/src/utils/xml.cpp
index 7ea5b9d6..c408c9c2 100644
--- a/src/utils/xml.cpp
+++ b/src/utils/xml.cpp
@@ -25,16 +25,13 @@
#include "log.h"
-#include "resources/resourcemanager.h"
-
-#include "utils/zlib.h"
+#include "utils/filesystem.h"
namespace XML
{
struct XMLContext
{
std::string file;
- bool resman;
};
#if LIBXML_VERSION >= 21200
@@ -49,7 +46,7 @@ namespace XML
logger->log("Error in XML file '%s' on line %d",
context->file.c_str(), error->line);
else
- logger->log("Error in unknown xml file on line %d",
+ logger->log("Error in unknown XML file on line %d",
error->line);
logger->log("%s", error->message);
@@ -63,32 +60,27 @@ namespace XML
{
XMLContext ctx;
ctx.file = filename;
- ctx.resman = useResman;
xmlSetStructuredErrorFunc(&ctx, xmlLogger);
- int size;
+ size_t size;
char *data = nullptr;
+
if (useResman)
- {
- ResourceManager *resman = ResourceManager::getInstance();
- data = (char*) resman->loadFile(filename, size);
- }
+ data = (char *) FS::loadFile(filename, size);
else
- {
- data = (char *) loadCompressedFile(filename, size);
- }
+ data = (char *) SDL_LoadFile(filename.c_str(), &size);
if (data)
{
mDoc = xmlParseMemory(data, size);
- free(data);
+ SDL_free(data);
if (!mDoc)
logger->log("Error parsing XML file %s", filename.c_str());
}
else
{
- logger->log("Error loading %s", filename.c_str());
+ logger->log("Error loading %s: %s", filename.c_str(), SDL_GetError());
}
xmlSetStructuredErrorFunc(nullptr, xmlLogger);