mirror of
https://github.com/ZDoom/gzdoom.git
synced 2025-03-13 22:42:07 +00:00
- handle ZLibError
This commit is contained in:
parent
7f024debfd
commit
12c7413149
1 changed files with 15 additions and 4 deletions
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue