mirror of
https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git
synced 2025-07-18 03:09:13 +00:00
Obliterate hsBool
This commit is contained in:
@ -54,12 +54,12 @@ public:
|
||||
virtual ~plCompress() {}
|
||||
|
||||
// return true if successful
|
||||
virtual hsBool Uncompress(uint8_t* bufOut, uint32_t* bufLenOut, const uint8_t* bufIn, uint32_t bufLenIn) = 0;
|
||||
virtual hsBool Compress(uint8_t* bufOut, uint32_t* bufLenOut, const uint8_t* bufIn, uint32_t bufLenIn) = 0;
|
||||
virtual bool Uncompress(uint8_t* bufOut, uint32_t* bufLenOut, const uint8_t* bufIn, uint32_t bufLenIn) = 0;
|
||||
virtual bool Compress(uint8_t* bufOut, uint32_t* bufLenOut, const uint8_t* bufIn, uint32_t bufLenIn) = 0;
|
||||
|
||||
// in place versions
|
||||
virtual hsBool Uncompress(uint8_t** bufIn, uint32_t* bufLenIn, uint32_t maxBufLenOut, int offset=0) = 0;
|
||||
virtual hsBool Compress(uint8_t** bufIn, uint32_t* bufLenIn, int offset=0) = 0;
|
||||
virtual bool Uncompress(uint8_t** bufIn, uint32_t* bufLenIn, uint32_t maxBufLenOut, int offset=0) = 0;
|
||||
virtual bool Compress(uint8_t** bufIn, uint32_t* bufLenIn, int offset=0) = 0;
|
||||
};
|
||||
|
||||
|
||||
|
@ -44,7 +44,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
#include "hsMemory.h"
|
||||
#include "hsStream.h"
|
||||
|
||||
hsBool plZlibCompress::Uncompress(uint8_t* bufOut, uint32_t* bufLenOut, const uint8_t* bufIn, uint32_t bufLenIn)
|
||||
bool plZlibCompress::Uncompress(uint8_t* bufOut, uint32_t* bufLenOut, const uint8_t* bufIn, uint32_t bufLenIn)
|
||||
{
|
||||
unsigned long buflen_out = *bufLenOut;
|
||||
bool result = (uncompress(bufOut, &buflen_out, bufIn, bufLenIn) == Z_OK);
|
||||
@ -52,7 +52,7 @@ hsBool plZlibCompress::Uncompress(uint8_t* bufOut, uint32_t* bufLenOut, const ui
|
||||
return result;
|
||||
}
|
||||
|
||||
hsBool plZlibCompress::Compress(uint8_t* bufOut, uint32_t* bufLenOut, const uint8_t* bufIn, uint32_t bufLenIn)
|
||||
bool plZlibCompress::Compress(uint8_t* bufOut, uint32_t* bufLenOut, const uint8_t* bufIn, uint32_t bufLenIn)
|
||||
{
|
||||
// according to compress doc, the bufOut buffer should be at least .1% larger than source buffer, plus 12 bytes.
|
||||
hsAssert(*bufLenOut>=(int)(bufLenIn*1.1+12), "bufOut compress buffer is not large enough");
|
||||
@ -65,7 +65,7 @@ hsBool plZlibCompress::Compress(uint8_t* bufOut, uint32_t* bufLenOut, const uint
|
||||
//
|
||||
// copy bufOut to bufIn, set bufLenIn=bufLenOut
|
||||
//
|
||||
hsBool plZlibCompress::ICopyBuffers(uint8_t** bufIn, uint32_t* bufLenIn, char* bufOut, uint32_t bufLenOut, int offset, bool ok)
|
||||
bool plZlibCompress::ICopyBuffers(uint8_t** bufIn, uint32_t* bufLenIn, char* bufOut, uint32_t bufLenOut, int offset, bool ok)
|
||||
{
|
||||
if (ok)
|
||||
{
|
||||
@ -87,7 +87,7 @@ hsBool plZlibCompress::ICopyBuffers(uint8_t** bufIn, uint32_t* bufLenIn, char* b
|
||||
// In place version
|
||||
// offset is how much to skip over when compressing
|
||||
//
|
||||
hsBool plZlibCompress::Compress(uint8_t** bufIn, uint32_t* bufLenIn, int offset)
|
||||
bool plZlibCompress::Compress(uint8_t** bufIn, uint32_t* bufLenIn, int offset)
|
||||
{
|
||||
uint32_t adjBufLenIn = *bufLenIn - offset;
|
||||
uint8_t* adjBufIn = *bufIn + offset;
|
||||
@ -104,7 +104,7 @@ hsBool plZlibCompress::Compress(uint8_t** bufIn, uint32_t* bufLenIn, int offset)
|
||||
//
|
||||
// In place version
|
||||
//
|
||||
hsBool plZlibCompress::Uncompress(uint8_t** bufIn, uint32_t* bufLenIn, uint32_t bufLenOut, int offset)
|
||||
bool plZlibCompress::Uncompress(uint8_t** bufIn, uint32_t* bufLenIn, uint32_t bufLenOut, int offset)
|
||||
{
|
||||
uint32_t adjBufLenIn = *bufLenIn - offset;
|
||||
uint8_t* adjBufIn = *bufIn + offset;
|
||||
@ -120,11 +120,11 @@ hsBool plZlibCompress::Uncompress(uint8_t** bufIn, uint32_t* bufLenIn, uint32_t
|
||||
#define kGzBufferSize 64 * 1024
|
||||
#if 1
|
||||
|
||||
hsBool plZlibCompress::UncompressFile( const char *compressedPath, const char *destPath )
|
||||
bool plZlibCompress::UncompressFile( const char *compressedPath, const char *destPath )
|
||||
{
|
||||
gzFile inFile;
|
||||
FILE *outFile;
|
||||
hsBool worked = false;
|
||||
bool worked = false;
|
||||
int length, err;
|
||||
|
||||
uint8_t buffer[ kGzBufferSize ];
|
||||
@ -162,11 +162,11 @@ hsBool plZlibCompress::UncompressFile( const char *compressedPath, const char *
|
||||
}
|
||||
|
||||
|
||||
hsBool plZlibCompress::CompressFile( const char *uncompressedPath, const char *destPath )
|
||||
bool plZlibCompress::CompressFile( const char *uncompressedPath, const char *destPath )
|
||||
{
|
||||
FILE *inFile;
|
||||
gzFile outFile;
|
||||
hsBool worked = false;
|
||||
bool worked = false;
|
||||
int length, err;
|
||||
|
||||
uint8_t buffer[ kGzBufferSize ];
|
||||
@ -207,10 +207,10 @@ hsBool plZlibCompress::CompressFile( const char *uncompressedPath, const char *
|
||||
|
||||
//// file <-> stream ///////////////////////////////////////////////////////
|
||||
|
||||
hsBool plZlibCompress::UncompressToStream( const char * filename, hsStream * s )
|
||||
bool plZlibCompress::UncompressToStream( const char * filename, hsStream * s )
|
||||
{
|
||||
gzFile inFile;
|
||||
hsBool worked = false;
|
||||
bool worked = false;
|
||||
int length, err;
|
||||
|
||||
uint8_t buffer[ kGzBufferSize ];
|
||||
@ -242,10 +242,10 @@ hsBool plZlibCompress::UncompressToStream( const char * filename, hsStream * s
|
||||
}
|
||||
|
||||
|
||||
hsBool plZlibCompress::CompressToFile( hsStream * s, const char * filename )
|
||||
bool plZlibCompress::CompressToFile( hsStream * s, const char * filename )
|
||||
{
|
||||
gzFile outFile;
|
||||
hsBool worked = false;
|
||||
bool worked = false;
|
||||
int length, err;
|
||||
|
||||
uint8_t buffer[ kGzBufferSize ];
|
||||
|
@ -49,22 +49,22 @@ class hsStream;
|
||||
class plZlibCompress : public plCompress
|
||||
{
|
||||
protected:
|
||||
hsBool ICopyBuffers(uint8_t** bufIn, uint32_t* bufLenIn, char* bufOut, uint32_t bufLenOut, int offset, bool ok );
|
||||
bool ICopyBuffers(uint8_t** bufIn, uint32_t* bufLenIn, char* bufOut, uint32_t bufLenOut, int offset, bool ok );
|
||||
public:
|
||||
hsBool Uncompress(uint8_t* bufOut, uint32_t* bufLenOut, const uint8_t* bufIn, uint32_t bufLenIn);
|
||||
hsBool Compress(uint8_t* bufOut, uint32_t* bufLenOut, const uint8_t* bufIn, uint32_t bufLenIn);
|
||||
bool Uncompress(uint8_t* bufOut, uint32_t* bufLenOut, const uint8_t* bufIn, uint32_t bufLenIn);
|
||||
bool Compress(uint8_t* bufOut, uint32_t* bufLenOut, const uint8_t* bufIn, uint32_t bufLenIn);
|
||||
|
||||
// in place versions
|
||||
hsBool Uncompress(uint8_t** bufIn, uint32_t* bufLenIn, uint32_t maxBufLenOut, int offset=0);
|
||||
hsBool Compress(uint8_t** bufIn, uint32_t* bufLenIn, int offset=0);
|
||||
bool Uncompress(uint8_t** bufIn, uint32_t* bufLenIn, uint32_t maxBufLenOut, int offset=0);
|
||||
bool Compress(uint8_t** bufIn, uint32_t* bufLenIn, int offset=0);
|
||||
|
||||
// .gz versions
|
||||
static hsBool UncompressFile( const char *compressedPath, const char *destPath );
|
||||
static hsBool CompressFile( const char *uncompressedPath, const char *destPath );
|
||||
static bool UncompressFile( const char *compressedPath, const char *destPath );
|
||||
static bool CompressFile( const char *uncompressedPath, const char *destPath );
|
||||
|
||||
// file <-> stream
|
||||
static hsBool UncompressToStream( const char * filename, hsStream * s );
|
||||
static hsBool CompressToFile( hsStream * s, const char * filename );
|
||||
static bool UncompressToStream( const char * filename, hsStream * s );
|
||||
static bool CompressToFile( hsStream * s, const char * filename );
|
||||
};
|
||||
|
||||
#endif // plZlibCompress_h
|
||||
|
@ -61,17 +61,17 @@ plZlibStream::~plZlibStream()
|
||||
hsAssert(!fOutput && !fZStream, "plZlibStream not closed");
|
||||
}
|
||||
|
||||
hsBool plZlibStream::Open(const char* filename, const char* mode)
|
||||
bool plZlibStream::Open(const char* filename, const char* mode)
|
||||
{
|
||||
wchar_t* wFilename = hsStringToWString(filename);
|
||||
wchar_t* wMode = hsStringToWString(mode);
|
||||
hsBool ret = Open(wFilename, wMode);
|
||||
bool ret = Open(wFilename, wMode);
|
||||
delete [] wFilename;
|
||||
delete [] wMode;
|
||||
return ret;
|
||||
}
|
||||
|
||||
hsBool plZlibStream::Open(const wchar_t* filename, const wchar_t* mode)
|
||||
bool plZlibStream::Open(const wchar_t* filename, const wchar_t* mode)
|
||||
{
|
||||
fFilename = filename;
|
||||
fMode = mode;
|
||||
@ -80,7 +80,7 @@ hsBool plZlibStream::Open(const wchar_t* filename, const wchar_t* mode)
|
||||
return fOutput->Open(filename, L"wb");
|
||||
}
|
||||
|
||||
hsBool plZlibStream::Close()
|
||||
bool plZlibStream::Close()
|
||||
{
|
||||
if (fOutput)
|
||||
{
|
||||
@ -277,7 +277,7 @@ int plZlibStream::IValidateGzHeader(uint32_t byteCount, const void* buffer)
|
||||
return clipBuffer;
|
||||
}
|
||||
|
||||
hsBool plZlibStream::AtEnd()
|
||||
bool plZlibStream::AtEnd()
|
||||
{
|
||||
hsAssert(0, "AtEnd not supported");
|
||||
return true;
|
||||
|
@ -68,10 +68,10 @@ public:
|
||||
plZlibStream();
|
||||
virtual ~plZlibStream();
|
||||
|
||||
virtual hsBool Open(const char* filename, const char* mode);
|
||||
virtual hsBool Open(const wchar_t* filename, const wchar_t* mode);
|
||||
virtual hsBool Close();
|
||||
virtual uint32_t Write(uint32_t byteCount, const void* buffer);
|
||||
virtual bool Open(const char* filename, const char* mode);
|
||||
virtual bool Open(const wchar_t* filename, const wchar_t* mode);
|
||||
virtual bool Close();
|
||||
virtual uint32_t Write(uint32_t byteCount, const void* buffer);
|
||||
|
||||
// Since most functions don't check the return value from Write, you can
|
||||
// call this after you've passed in all your data to determine if it
|
||||
@ -79,12 +79,12 @@ public:
|
||||
bool DecompressedOk() { return fDecompressedOk; }
|
||||
|
||||
// You can't use these
|
||||
virtual hsBool AtEnd();
|
||||
virtual uint32_t Read(uint32_t byteCount, void* buffer);
|
||||
virtual void Skip(uint32_t deltaByteCount);
|
||||
virtual void Rewind();
|
||||
virtual void FastFwd();
|
||||
virtual uint32_t GetEOF();
|
||||
virtual bool AtEnd();
|
||||
virtual uint32_t Read(uint32_t byteCount, void* buffer);
|
||||
virtual void Skip(uint32_t deltaByteCount);
|
||||
virtual void Rewind();
|
||||
virtual void FastFwd();
|
||||
virtual uint32_t GetEOF();
|
||||
};
|
||||
|
||||
#endif // plZlibStream_h_inc
|
Reference in New Issue
Block a user