- handle ZLibError

This commit is contained in:
Christoph Oelckers 2023-08-19 15:52:10 +02:00
parent 7f024debfd
commit 12c7413149

View file

@ -43,8 +43,6 @@
#include "files.h"
#include "cmdlib.h"
//==========================================================================
//
// DecompressionError
@ -87,6 +85,19 @@ void DecompressorBase::SetOwnsReader()
File = &OwnedFile;
}
//==========================================================================
//
//
//
//==========================================================================
static const char* ZLibError(int zerr)
{
static const char* const errs[6] = { "Errno", "Stream Error", "Data Error", "Memory Error", "Buffer Error", "Version Error" };
if (zerr >= 0 || zerr < -6) return "Unknown";
else return errs[-zerr - 1];
}
//==========================================================================
//
// DecompressorZ
@ -124,9 +135,9 @@ public:
if (!zip) err = inflateInit (&Stream);
else err = inflateInit2 (&Stream, -MAX_WBITS);
if (err != Z_OK)
if (err < Z_OK)
{
DecompressionError ("DecompressorZ: inflateInit failed: %s\n", M_ZLibError(err).GetChars());
DecompressionError ("DecompressorZ: inflateInit failed: %s\n", ZLibError(err));
return false;
}
return true;