mirror of
https://github.com/AquariaOSE/Aquaria.git
synced 2025-08-21 05:50:56 +00:00
Drop use of tempfiles when loading compressed files.
Also simplified .zga texture and .aqs savegame loading. Dropped support for "crunched" .sav files (those were never used), and the corresponding crunch functions. To be done: Temp files are still used when compressing files, will address this in a later commit.
This commit is contained in:
parent
321a65a9fb
commit
75e7b137d6
11 changed files with 914 additions and 227 deletions
59
BBGE/DeflateCompressor.h
Normal file
59
BBGE/DeflateCompressor.h
Normal file
|
@ -0,0 +1,59 @@
|
|||
#ifndef DEFLATE_COMPRESSOR_H
|
||||
#define DEFLATE_COMPRESSOR_H
|
||||
|
||||
#include "ByteBuffer.h"
|
||||
|
||||
// implements a raw deflate stream, not zlib wrapped, and not checksummed.
|
||||
class DeflateCompressor : public ByteBuffer
|
||||
{
|
||||
public:
|
||||
DeflateCompressor();
|
||||
DeflateCompressor(void *buf, uint32 size, Mode mode = COPY, delete_func del = NULL, uint32 extra = 0);
|
||||
virtual ~DeflateCompressor() {}
|
||||
virtual void Compress(uint8 level = 1);
|
||||
virtual void Decompress(void);
|
||||
|
||||
bool Compressed(void) const { return _iscompressed; }
|
||||
void Compressed(bool b) { _iscompressed = b; }
|
||||
uint32 RealSize(void) const { return _iscompressed ? _real_size : size(); }
|
||||
void RealSize(uint32 realsize) { _real_size = realsize; }
|
||||
void clear(void) // not required to be strictly virtual; be careful not to mess up static types!
|
||||
{
|
||||
ByteBuffer::clear();
|
||||
_real_size = 0;
|
||||
_iscompressed = false;
|
||||
}
|
||||
|
||||
protected:
|
||||
int _windowBits; // read zlib docs to know what this means
|
||||
unsigned int _real_size;
|
||||
bool _forceCompress;
|
||||
bool _iscompressed;
|
||||
|
||||
private:
|
||||
static void decompress(void *dst, uint32 *origsize, const void *src, uint32 size, int wbits);
|
||||
static void compress(void* dst, uint32 *dst_size, const void* src, uint32 src_size,
|
||||
uint8 level, int wbits);
|
||||
|
||||
int decompressBlockwise();
|
||||
};
|
||||
|
||||
// implements deflate stream, zlib wrapped
|
||||
class ZlibCompressor : public DeflateCompressor
|
||||
{
|
||||
public:
|
||||
ZlibCompressor();
|
||||
virtual ~ZlibCompressor() {}
|
||||
};
|
||||
|
||||
// the output produced by this stream contains a minimal gzip header,
|
||||
// and can be directly written to a .gz file.
|
||||
class GzipCompressor : public DeflateCompressor
|
||||
{
|
||||
public:
|
||||
GzipCompressor();
|
||||
virtual ~GzipCompressor() {}
|
||||
virtual void Decompress(void);
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue