Fix up ZLib a little more and remove more configuration into CMakeLists

This commit is contained in:
Jettford
2024-12-05 19:45:21 +00:00
parent 6c8bb743af
commit 6eea3f3662
4 changed files with 30 additions and 34 deletions

View File

@@ -1,6 +1,6 @@
#include "ZCompression.h"
#include "zlib.h"
#include "zlib-ng.h"
namespace ZCompression {
int32_t GetMaxCompressedLength(int32_t nLenSrc) {
@@ -9,41 +9,41 @@ namespace ZCompression {
}
int32_t Compress(const uint8_t* abSrc, int32_t nLenSrc, uint8_t* abDst, int32_t nLenDst) {
z_stream zInfo = { 0 };
zng_stream zInfo = { 0 };
zInfo.total_in = zInfo.avail_in = nLenSrc;
zInfo.total_out = zInfo.avail_out = nLenDst;
zInfo.next_in = const_cast<Bytef*>(abSrc);
zInfo.next_out = abDst;
int nErr, nRet = -1;
nErr = deflateInit(&zInfo, Z_DEFAULT_COMPRESSION); // zlib function
nErr = zng_deflateInit(&zInfo, Z_DEFAULT_COMPRESSION); // zlib function
if (nErr == Z_OK) {
nErr = deflate(&zInfo, Z_FINISH); // zlib function
nErr = zng_deflate(&zInfo, Z_FINISH); // zlib function
if (nErr == Z_STREAM_END) {
nRet = zInfo.total_out;
}
}
deflateEnd(&zInfo); // zlib function
zng_deflateEnd(&zInfo); // zlib function
return(nRet);
}
int32_t Decompress(const uint8_t* abSrc, int32_t nLenSrc, uint8_t* abDst, int32_t nLenDst, int32_t& nErr) {
// Get the size of the decompressed data
z_stream zInfo = { 0 };
zng_stream zInfo = { 0 };
zInfo.total_in = zInfo.avail_in = nLenSrc;
zInfo.total_out = zInfo.avail_out = nLenDst;
zInfo.next_in = const_cast<Bytef*>(abSrc);
zInfo.next_out = abDst;
int nRet = -1;
nErr = inflateInit(&zInfo); // zlib function
nErr = zng_inflateInit(&zInfo); // zlib function
if (nErr == Z_OK) {
nErr = inflate(&zInfo, Z_FINISH); // zlib function
nErr = zng_inflate(&zInfo, Z_FINISH); // zlib function
if (nErr == Z_STREAM_END) {
nRet = zInfo.total_out;
}
}
inflateEnd(&zInfo); // zlib function
zng_inflateEnd(&zInfo); // zlib function
return(nRet);
}
}

View File

@@ -4,8 +4,6 @@
#include "Game.h"
#include "Logger.h"
#include "zlib.h"
AssetManager::AssetManager(const std::filesystem::path& path) {
if (!std::filesystem::is_directory(path)) {
throw std::runtime_error("Attempted to load asset bundle (" + path.string() + ") however it is not a valid directory.");