- read snapshots from zip.
This commit is contained in:
parent
f93e4813d1
commit
5dfc396bb9
12 changed files with 90 additions and 76 deletions
|
|
@ -306,17 +306,12 @@ FZipFile::~FZipFile()
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
FCompressedBuffer FZipFile::GetRawLump(int lumpnum)
|
||||
FCompressedBuffer FZipLump::GetRawData()
|
||||
{
|
||||
if ((unsigned)lumpnum >= NumLumps)
|
||||
{
|
||||
return{ 0,0,0,0,0,nullptr };
|
||||
}
|
||||
FZipLump *lmp = &Lumps[lumpnum];
|
||||
|
||||
FCompressedBuffer cbuf = { (unsigned)lmp->LumpSize, (unsigned)lmp->CompressedSize, lmp->Method, lmp->GPFlags, lmp->CRC32, new char[lmp->CompressedSize] };
|
||||
Reader->Seek(lmp->Position, SEEK_SET);
|
||||
Reader->Read(cbuf.mBuffer, lmp->CompressedSize);
|
||||
FCompressedBuffer cbuf = { (unsigned)LumpSize, (unsigned)CompressedSize, Method, GPFlags, CRC32, new char[CompressedSize] };
|
||||
if (Flags & LUMPFZIP_NEEDFILESTART) SetLumpAddress();
|
||||
Owner->Reader->Seek(Position, SEEK_SET);
|
||||
Owner->Reader->Read(cbuf.mBuffer, CompressedSize);
|
||||
return cbuf;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,28 +3,6 @@
|
|||
|
||||
#include "resourcefile.h"
|
||||
|
||||
// This holds a compresed Zip entry with all needed info to decompress it.
|
||||
struct FCompressedBuffer
|
||||
{
|
||||
unsigned mSize;
|
||||
unsigned mCompressedSize;
|
||||
int mMethod;
|
||||
int mZipFlags;
|
||||
unsigned mCRC32;
|
||||
char *mBuffer;
|
||||
|
||||
bool Decompress(char *destbuffer);
|
||||
void Clean()
|
||||
{
|
||||
mSize = mCompressedSize = 0;
|
||||
if (mBuffer != nullptr)
|
||||
{
|
||||
delete[] mBuffer;
|
||||
mBuffer = nullptr;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
LUMPFZIP_NEEDFILESTART = 128
|
||||
|
|
@ -50,6 +28,7 @@ struct FZipLump : public FResourceLump
|
|||
private:
|
||||
void SetLumpAddress();
|
||||
virtual int GetFileOffset();
|
||||
FCompressedBuffer GetRawData();
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -68,7 +47,6 @@ public:
|
|||
virtual ~FZipFile();
|
||||
bool Open(bool quiet);
|
||||
virtual FResourceLump *GetLump(int no) { return ((unsigned)no < NumLumps)? &Lumps[no] : NULL; }
|
||||
FCompressedBuffer GetRawLump(int lumpnum);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@
|
|||
#include "doomerrors.h"
|
||||
#include "gi.h"
|
||||
#include "doomstat.h"
|
||||
#include "w_zip.h"
|
||||
|
||||
|
||||
//==========================================================================
|
||||
|
|
@ -191,6 +192,23 @@ void FResourceLump::CheckEmbedded()
|
|||
}
|
||||
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// this is just for completeness. For non-Zips only an uncompressed lump can
|
||||
// be returned.
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
FCompressedBuffer FResourceLump::GetRawData()
|
||||
{
|
||||
FCompressedBuffer cbuf = { (unsigned)LumpSize, (unsigned)LumpSize, METHOD_STORED, 0, 0, new char[LumpSize] };
|
||||
memcpy(cbuf.mBuffer, CacheLump(), LumpSize);
|
||||
cbuf.mCRC32 = crc32(0, (BYTE*)cbuf.mBuffer, LumpSize);
|
||||
ReleaseCache();
|
||||
return cbuf;
|
||||
}
|
||||
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// Returns the owner's FileReader if it can be used to access this lump
|
||||
|
|
|
|||
|
|
@ -8,6 +8,28 @@
|
|||
class FResourceFile;
|
||||
class FTexture;
|
||||
|
||||
// This holds a compresed Zip entry with all needed info to decompress it.
|
||||
struct FCompressedBuffer
|
||||
{
|
||||
unsigned mSize;
|
||||
unsigned mCompressedSize;
|
||||
int mMethod;
|
||||
int mZipFlags;
|
||||
unsigned mCRC32;
|
||||
char *mBuffer;
|
||||
|
||||
bool Decompress(char *destbuffer);
|
||||
void Clean()
|
||||
{
|
||||
mSize = mCompressedSize = 0;
|
||||
if (mBuffer != nullptr)
|
||||
{
|
||||
delete[] mBuffer;
|
||||
mBuffer = nullptr;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
struct FResourceLump
|
||||
{
|
||||
friend class FResourceFile;
|
||||
|
|
@ -46,6 +68,7 @@ struct FResourceLump
|
|||
virtual int GetIndexNum() const { return 0; }
|
||||
void LumpNameSetup(FString iname);
|
||||
void CheckEmbedded();
|
||||
virtual FCompressedBuffer GetRawData();
|
||||
|
||||
void *CacheLump();
|
||||
int ReleaseCache();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue