mirror of
https://github.com/ZDoom/qzdoom-gpl.git
synced 2024-11-16 01:02:03 +00:00
-Fixes in new resource file code: Added file length checks and set lump count to 1 for single lump files.
SVN r1558 (trunk)
This commit is contained in:
parent
1ea8777572
commit
2e90519c13
7 changed files with 61 additions and 42 deletions
|
@ -334,14 +334,17 @@ FResourceFile *Check7Z(const char *filename, FileReader *file)
|
||||||
{
|
{
|
||||||
char head[k7zSignatureSize];
|
char head[k7zSignatureSize];
|
||||||
|
|
||||||
file->Seek(0, SEEK_SET);
|
if (file->GetLength() >= k7zSignatureSize)
|
||||||
file->Read(&head, k7zSignatureSize);
|
|
||||||
file->Seek(0, SEEK_SET);
|
|
||||||
if (!memcmp(head, k7zSignature, k7zSignatureSize))
|
|
||||||
{
|
{
|
||||||
FResourceFile *rf = new F7ZFile(filename, file);
|
file->Seek(0, SEEK_SET);
|
||||||
if (rf->Open()) return rf;
|
file->Read(&head, k7zSignatureSize);
|
||||||
delete rf;
|
file->Seek(0, SEEK_SET);
|
||||||
|
if (!memcmp(head, k7zSignature, k7zSignatureSize))
|
||||||
|
{
|
||||||
|
FResourceFile *rf = new F7ZFile(filename, file);
|
||||||
|
if (rf->Open()) return rf;
|
||||||
|
delete rf;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -138,14 +138,17 @@ FResourceFile *CheckGRP(const char *filename, FileReader *file)
|
||||||
{
|
{
|
||||||
char head[12];
|
char head[12];
|
||||||
|
|
||||||
file->Seek(0, SEEK_SET);
|
if (file->GetLength() >= 12)
|
||||||
file->Read(&head, 12);
|
|
||||||
file->Seek(0, SEEK_SET);
|
|
||||||
if (!memcmp(head, "KenSilverman", 12))
|
|
||||||
{
|
{
|
||||||
FResourceFile *rf = new FGrpFile(filename, file);
|
file->Seek(0, SEEK_SET);
|
||||||
if (rf->Open()) return rf;
|
file->Read(&head, 12);
|
||||||
delete rf;
|
file->Seek(0, SEEK_SET);
|
||||||
|
if (!memcmp(head, "KenSilverman", 12))
|
||||||
|
{
|
||||||
|
FResourceFile *rf = new FGrpFile(filename, file);
|
||||||
|
if (rf->Open()) return rf;
|
||||||
|
delete rf;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,6 +80,7 @@ bool FLumpFile::Open()
|
||||||
Lumps->Namespace = ns_global;
|
Lumps->Namespace = ns_global;
|
||||||
Lumps->Flags = 0;
|
Lumps->Flags = 0;
|
||||||
Lumps->FullName = NULL;
|
Lumps->FullName = NULL;
|
||||||
|
NumLumps = 1;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -130,14 +130,17 @@ FResourceFile *CheckPak(const char *filename, FileReader *file)
|
||||||
{
|
{
|
||||||
char head[4];
|
char head[4];
|
||||||
|
|
||||||
file->Seek(0, SEEK_SET);
|
if (file->GetLength() >= 12)
|
||||||
file->Read(&head, 4);
|
|
||||||
file->Seek(0, SEEK_SET);
|
|
||||||
if (!memcmp(head, "PACK", 4))
|
|
||||||
{
|
{
|
||||||
FResourceFile *rf = new FPakFile(filename, file);
|
file->Seek(0, SEEK_SET);
|
||||||
if (rf->Open()) return rf;
|
file->Read(&head, 4);
|
||||||
delete rf;
|
file->Seek(0, SEEK_SET);
|
||||||
|
if (!memcmp(head, "PACK", 4))
|
||||||
|
{
|
||||||
|
FResourceFile *rf = new FPakFile(filename, file);
|
||||||
|
if (rf->Open()) return rf;
|
||||||
|
delete rf;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -235,14 +235,17 @@ FResourceFile *CheckRFF(const char *filename, FileReader *file)
|
||||||
{
|
{
|
||||||
char head[4];
|
char head[4];
|
||||||
|
|
||||||
file->Seek(0, SEEK_SET);
|
if (file->GetLength() >= 16)
|
||||||
file->Read(&head, 4);
|
|
||||||
file->Seek(0, SEEK_SET);
|
|
||||||
if (!memcmp(head, "RFF\x1a", 4))
|
|
||||||
{
|
{
|
||||||
FResourceFile *rf = new FRFFFile(filename, file);
|
file->Seek(0, SEEK_SET);
|
||||||
if (rf->Open()) return rf;
|
file->Read(&head, 4);
|
||||||
delete rf;
|
file->Seek(0, SEEK_SET);
|
||||||
|
if (!memcmp(head, "RFF\x1a", 4))
|
||||||
|
{
|
||||||
|
FResourceFile *rf = new FRFFFile(filename, file);
|
||||||
|
if (rf->Open()) return rf;
|
||||||
|
delete rf;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -328,14 +328,17 @@ FResourceFile *CheckWad(const char *filename, FileReader *file)
|
||||||
{
|
{
|
||||||
char head[4];
|
char head[4];
|
||||||
|
|
||||||
file->Seek(0, SEEK_SET);
|
if (file->GetLength() >= 12)
|
||||||
file->Read(&head, 4);
|
|
||||||
file->Seek(0, SEEK_SET);
|
|
||||||
if (!memcmp(head, "IWAD", 4) || !memcmp(head, "PWAD", 4))
|
|
||||||
{
|
{
|
||||||
FResourceFile *rf = new FWadFile(filename, file);
|
file->Seek(0, SEEK_SET);
|
||||||
if (rf->Open()) return rf;
|
file->Read(&head, 4);
|
||||||
delete rf;
|
file->Seek(0, SEEK_SET);
|
||||||
|
if (!memcmp(head, "IWAD", 4) || !memcmp(head, "PWAD", 4))
|
||||||
|
{
|
||||||
|
FResourceFile *rf = new FWadFile(filename, file);
|
||||||
|
if (rf->Open()) return rf;
|
||||||
|
delete rf;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -391,14 +391,17 @@ FResourceFile *CheckZip(const char *filename, FileReader *file)
|
||||||
{
|
{
|
||||||
char head[4];
|
char head[4];
|
||||||
|
|
||||||
file->Seek(0, SEEK_SET);
|
if (file->GetLength() >= sizeof(FZipLocalFileHeader))
|
||||||
file->Read(&head, 4);
|
|
||||||
file->Seek(0, SEEK_SET);
|
|
||||||
if (!memcmp(head, "PK\x3\x4", 4))
|
|
||||||
{
|
{
|
||||||
FResourceFile *rf = new FZipFile(filename, file);
|
file->Seek(0, SEEK_SET);
|
||||||
if (rf->Open()) return rf;
|
file->Read(&head, 4);
|
||||||
delete rf;
|
file->Seek(0, SEEK_SET);
|
||||||
|
if (!memcmp(head, "PK\x3\x4", 4))
|
||||||
|
{
|
||||||
|
FResourceFile *rf = new FZipFile(filename, file);
|
||||||
|
if (rf->Open()) return rf;
|
||||||
|
delete rf;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue