Use FResourceFile directly for the simple container types.
Instead let FResourceFile provide an interface for ad-hoc construction of a new container.
This commit is contained in:
parent
72a2e5d532
commit
6f8c3c60c4
9 changed files with 84 additions and 234 deletions
|
|
@ -36,30 +36,6 @@
|
|||
#include "resourcefile.h"
|
||||
|
||||
namespace FileSys {
|
||||
//==========================================================================
|
||||
//
|
||||
// Build GRP file
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
class FSSIFile : public FResourceFile
|
||||
{
|
||||
public:
|
||||
FSSIFile(const char * filename, FileReader &file, StringPool* sp);
|
||||
bool Open(int version, int EntryCount, LumpFilterInfo* filter);
|
||||
};
|
||||
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// Initializes a Build GRP file
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
FSSIFile::FSSIFile(const char *filename, FileReader &file, StringPool* sp)
|
||||
: FResourceFile(filename, file, sp)
|
||||
{
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
|
|
@ -68,22 +44,23 @@ FSSIFile::FSSIFile(const char *filename, FileReader &file, StringPool* sp)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
bool FSSIFile::Open(int version, int EntryCount, LumpFilterInfo*)
|
||||
static bool OpenSSI(FResourceFile* file, int version, int EntryCount, LumpFilterInfo*)
|
||||
{
|
||||
AllocateEntries(EntryCount*2);
|
||||
NumLumps = EntryCount*2;
|
||||
uint32_t NumLumps = EntryCount * 2;
|
||||
auto Entries = file->AllocateEntries(NumLumps);
|
||||
auto Reader = file->GetContainerReader();
|
||||
|
||||
|
||||
int32_t j = (version == 2 ? 267 : 254) + (EntryCount * 121);
|
||||
for (uint32_t i = 0; i < NumLumps; i+=2)
|
||||
{
|
||||
char fn[13];
|
||||
int strlength = Reader.ReadUInt8();
|
||||
int strlength = Reader->ReadUInt8();
|
||||
if (strlength > 12) strlength = 12;
|
||||
|
||||
Reader.Read(fn, 12);
|
||||
Reader->Read(fn, 12);
|
||||
fn[strlength] = 0;
|
||||
int flength = Reader.ReadInt32();
|
||||
int flength = Reader->ReadInt32();
|
||||
|
||||
Entries[i].Position = j;
|
||||
Entries[i].Length = flength;
|
||||
|
|
@ -91,7 +68,7 @@ bool FSSIFile::Open(int version, int EntryCount, LumpFilterInfo*)
|
|||
Entries[i].Namespace = ns_global;
|
||||
Entries[i].Method = METHOD_STORED;
|
||||
Entries[i].ResourceID = -1;
|
||||
Entries[i].FileName = NormalizeFileName(fn);
|
||||
Entries[i].FileName = file->NormalizeFileName(fn);
|
||||
if (strstr(fn, ".GRP")) Entries[i].Flags |= RESFF_EMBEDDED;
|
||||
|
||||
// SSI files can swap the order of the extension's characters - but there's no reliable detection for this and it can be mixed inside the same container,
|
||||
|
|
@ -103,13 +80,14 @@ bool FSSIFile::Open(int version, int EntryCount, LumpFilterInfo*)
|
|||
Entries[i + 1].Flags = 0;
|
||||
Entries[i + 1].Namespace = ns_global;
|
||||
Entries[i + 1].ResourceID = -1;
|
||||
Entries[i + 1].FileName = NormalizeFileName(fn);
|
||||
Entries[i + 1].FileName = file->NormalizeFileName(fn);
|
||||
Entries[i + 1].Method = METHOD_STORED;
|
||||
if (strstr(fn, ".GRP")) Entries[i + 1].Flags |= RESFF_EMBEDDED;
|
||||
|
||||
j += flength;
|
||||
|
||||
Reader.Seek(104, FileReader::SeekCur);
|
||||
Reader->Seek(104, FileReader::SeekCur);
|
||||
file->GenerateHash();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
@ -151,8 +129,8 @@ FResourceFile* CheckSSI(const char* filename, FileReader& file, LumpFilterInfo*
|
|||
{
|
||||
if (!skipstring(70)) return nullptr;
|
||||
}
|
||||
auto ssi = new FSSIFile(filename, file, sp);
|
||||
if (ssi->Open(version, numfiles, filter)) return ssi;
|
||||
auto ssi = new FResourceFile(filename, file, sp);
|
||||
if (OpenSSI(ssi, version, numfiles, filter)) return ssi;
|
||||
file = ssi->Destroy();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue