mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-10 23:02:08 +00:00
Consolidate archive sorting into FResourceFile base class
This commit is contained in:
parent
966d0b7034
commit
efa82cf38b
6 changed files with 27 additions and 47 deletions
|
@ -253,7 +253,7 @@ void FIWadManager::ParseIWadInfo(const char *fn, const char *data, int datasize)
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
//
|
//
|
||||||
// Lool for IWAD definition lump
|
// Look for IWAD definition lump
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
|
|
|
@ -179,7 +179,7 @@ struct F7ZLump : public FResourceLump
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
//
|
//
|
||||||
// Zip file
|
// 7-zip file
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
|
@ -190,8 +190,6 @@ class F7ZFile : public FResourceFile
|
||||||
F7ZLump *Lumps;
|
F7ZLump *Lumps;
|
||||||
C7zArchive *Archive;
|
C7zArchive *Archive;
|
||||||
|
|
||||||
static int STACK_ARGS lumpcmp(const void * a, const void * b);
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
F7ZFile(const char * filename, FileReader *filer);
|
F7ZFile(const char * filename, FileReader *filer);
|
||||||
bool Open(bool quiet);
|
bool Open(bool quiet);
|
||||||
|
@ -201,15 +199,6 @@ public:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int STACK_ARGS F7ZFile::lumpcmp(const void * a, const void * b)
|
|
||||||
{
|
|
||||||
F7ZLump * rec1 = (F7ZLump *)a;
|
|
||||||
F7ZLump * rec2 = (F7ZLump *)b;
|
|
||||||
|
|
||||||
return rec1->FullName.CompareNoCase(rec2->FullName);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
//
|
//
|
||||||
// 7Z file
|
// 7Z file
|
||||||
|
@ -328,8 +317,7 @@ bool F7ZFile::Open(bool quiet)
|
||||||
|
|
||||||
if (!quiet) Printf(", %d lumps\n", NumLumps);
|
if (!quiet) Printf(", %d lumps\n", NumLumps);
|
||||||
|
|
||||||
// Entries in archives are sorted alphabetically
|
PostProcessArchive(&Lumps[0], sizeof(F7ZLump));
|
||||||
qsort(&Lumps[0], NumLumps, sizeof(F7ZLump), lumpcmp);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -86,8 +86,6 @@ class FDirectory : public FResourceFile
|
||||||
{
|
{
|
||||||
TArray<FDirectoryLump> Lumps;
|
TArray<FDirectoryLump> Lumps;
|
||||||
|
|
||||||
static int STACK_ARGS lumpcmp(const void * a, const void * b);
|
|
||||||
|
|
||||||
int AddDirectory(const char *dirpath);
|
int AddDirectory(const char *dirpath);
|
||||||
void AddEntry(const char *fullpath, int size);
|
void AddEntry(const char *fullpath, int size);
|
||||||
|
|
||||||
|
@ -122,20 +120,6 @@ FDirectory::FDirectory(const char * directory)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//==========================================================================
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//==========================================================================
|
|
||||||
|
|
||||||
int STACK_ARGS FDirectory::lumpcmp(const void * a, const void * b)
|
|
||||||
{
|
|
||||||
FDirectoryLump * rec1 = (FDirectoryLump *)a;
|
|
||||||
FDirectoryLump * rec2 = (FDirectoryLump *)b;
|
|
||||||
|
|
||||||
return rec1->FullName.CompareNoCase(rec2->FullName);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
//
|
//
|
||||||
|
@ -299,8 +283,7 @@ bool FDirectory::Open(bool quiet)
|
||||||
{
|
{
|
||||||
NumLumps = AddDirectory(Filename);
|
NumLumps = AddDirectory(Filename);
|
||||||
if (!quiet) Printf(", %d lumps\n", NumLumps);
|
if (!quiet) Printf(", %d lumps\n", NumLumps);
|
||||||
// Entries in Zips are sorted alphabetically.
|
PostProcessArchive(&Lumps[0], sizeof(FDirectoryLump));
|
||||||
qsort(&Lumps[0], NumLumps, sizeof(FDirectoryLump), lumpcmp);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -138,8 +138,6 @@ class FZipFile : public FResourceFile
|
||||||
{
|
{
|
||||||
FZipLump *Lumps;
|
FZipLump *Lumps;
|
||||||
|
|
||||||
static int STACK_ARGS lumpcmp(const void * a, const void * b);
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FZipFile(const char * filename, FileReader *file);
|
FZipFile(const char * filename, FileReader *file);
|
||||||
virtual ~FZipFile();
|
virtual ~FZipFile();
|
||||||
|
@ -148,16 +146,6 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int STACK_ARGS FZipFile::lumpcmp(const void * a, const void * b)
|
|
||||||
{
|
|
||||||
FZipLump * rec1 = (FZipLump *)a;
|
|
||||||
FZipLump * rec2 = (FZipLump *)b;
|
|
||||||
|
|
||||||
return rec1->FullName.CompareNoCase(rec2->FullName);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
//
|
//
|
||||||
// Zip file
|
// Zip file
|
||||||
|
@ -274,8 +262,7 @@ bool FZipFile::Open(bool quiet)
|
||||||
|
|
||||||
if (!quiet) Printf(", %d lumps\n", NumLumps);
|
if (!quiet) Printf(", %d lumps\n", NumLumps);
|
||||||
|
|
||||||
// Entries in Zips are sorted alphabetically.
|
PostProcessArchive(&Lumps[0], sizeof(FZipLump));
|
||||||
qsort(Lumps, NumLumps, sizeof(FZipLump), lumpcmp);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -316,6 +316,27 @@ FResourceFile::~FResourceFile()
|
||||||
delete Reader;
|
delete Reader;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int STACK_ARGS lumpcmp(const void * a, const void * b)
|
||||||
|
{
|
||||||
|
FResourceLump * rec1 = (FResourceLump *)a;
|
||||||
|
FResourceLump * rec2 = (FResourceLump *)b;
|
||||||
|
|
||||||
|
return rec1->FullName.CompareNoCase(rec2->FullName);
|
||||||
|
}
|
||||||
|
|
||||||
|
//==========================================================================
|
||||||
|
//
|
||||||
|
// FResourceFile :: PostProcessArchive
|
||||||
|
//
|
||||||
|
// Sorts files by name.
|
||||||
|
//
|
||||||
|
//==========================================================================
|
||||||
|
|
||||||
|
void FResourceFile::PostProcessArchive(void *lumps, size_t lumpsize)
|
||||||
|
{
|
||||||
|
// Entries in archives are sorted alphabetically
|
||||||
|
qsort(lumps, NumLumps, lumpsize, lumpcmp);
|
||||||
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
//
|
//
|
||||||
|
|
|
@ -76,6 +76,7 @@ public:
|
||||||
DWORD LumpCount() const { return NumLumps; }
|
DWORD LumpCount() const { return NumLumps; }
|
||||||
DWORD GetFirstLump() const { return FirstLump; }
|
DWORD GetFirstLump() const { return FirstLump; }
|
||||||
void SetFirstLump(DWORD f) { FirstLump = f; }
|
void SetFirstLump(DWORD f) { FirstLump = f; }
|
||||||
|
void PostProcessArchive(void *lumps, size_t lumpsize); // for archives that can contain directories
|
||||||
|
|
||||||
virtual void FindStrifeTeaserVoices ();
|
virtual void FindStrifeTeaserVoices ();
|
||||||
virtual bool Open(bool quiet) = 0;
|
virtual bool Open(bool quiet) = 0;
|
||||||
|
|
Loading…
Reference in a new issue