mirror of
https://github.com/ZDoom/raze-gles.git
synced 2025-02-28 14:11:13 +00:00
- adapted the Zip root folder eliminator to deal with archives that do not add proper folder records to their central directory.
This commit is contained in:
parent
3864dcfc17
commit
c51c6fa524
1 changed files with 26 additions and 17 deletions
|
@ -208,8 +208,9 @@ bool FZipFile::Open(bool quiet, LumpFilterInfo* filter)
|
||||||
char *dirptr = (char*)directory;
|
char *dirptr = (char*)directory;
|
||||||
FZipLump *lump_p = Lumps;
|
FZipLump *lump_p = Lumps;
|
||||||
|
|
||||||
FString name0;
|
FString name0, name1;
|
||||||
bool foundspeciallump = false;
|
bool foundspeciallump = false;
|
||||||
|
bool foundprefix = false;
|
||||||
|
|
||||||
// Check if all files have the same prefix so that this can be stripped out.
|
// Check if all files have the same prefix so that this can be stripped out.
|
||||||
// This will only be done if there is either a MAPINFO, ZMAPINFO or GAMEINFO lump in the subdirectory, denoting a ZDoom mod.
|
// This will only be done if there is either a MAPINFO, ZMAPINFO or GAMEINFO lump in the subdirectory, denoting a ZDoom mod.
|
||||||
|
@ -234,31 +235,39 @@ bool FZipFile::Open(bool quiet, LumpFilterInfo* filter)
|
||||||
|
|
||||||
name.ToLower();
|
name.ToLower();
|
||||||
if (name.IndexOf("__macosx") == 0)
|
if (name.IndexOf("__macosx") == 0)
|
||||||
continue; // skip Apple garbage. At this stage only the root folder matters,
|
continue; // skip Apple garbage. At this stage only the root folder matters.
|
||||||
if (i == 0)
|
if (!foundprefix)
|
||||||
{
|
{
|
||||||
// check for special names, if one of these gets found this must be treated as a normal zip.
|
// check for special names, if one of these gets found this must be treated as a normal zip.
|
||||||
bool isspecial = name.IndexOf("/") < 0 || (filter && filter->reservedFolders.Find(name) < filter->reservedFolders.Size());
|
bool isspecial = name.IndexOf("/") < 0 || (filter && filter->reservedFolders.Find(name) < filter->reservedFolders.Size());
|
||||||
if (isspecial) break;
|
if (isspecial) break;
|
||||||
name0 = name.Left(name.LastIndexOf("/")+1);
|
name0 = name.Left(name.LastIndexOf("/")+1);
|
||||||
|
name1 = name.Left(name.IndexOf("/") + 1);
|
||||||
|
foundprefix = true;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
if (name.IndexOf(name0) != 0)
|
||||||
{
|
{
|
||||||
if (name.IndexOf(name0) != 0)
|
if (name1.IsNotEmpty())
|
||||||
{
|
{
|
||||||
name0 = "";
|
name0 = name1;
|
||||||
break;
|
if (name.IndexOf(name0) != 0)
|
||||||
}
|
|
||||||
else if (!foundspeciallump && filter)
|
|
||||||
{
|
|
||||||
// at least one of the more common definition lumps must be present.
|
|
||||||
for (auto &p : filter->requiredPrefixes)
|
|
||||||
{
|
{
|
||||||
if (name.IndexOf(name0 + p) == 0 || name.LastIndexOf(p) == name.Len() - strlen(p))
|
name0 = "";
|
||||||
{
|
}
|
||||||
foundspeciallump = true;
|
}
|
||||||
break;
|
if (name0.IsEmpty())
|
||||||
}
|
break;
|
||||||
|
}
|
||||||
|
if (!foundspeciallump && filter)
|
||||||
|
{
|
||||||
|
// at least one of the more common definition lumps must be present.
|
||||||
|
for (auto &p : filter->requiredPrefixes)
|
||||||
|
{
|
||||||
|
if (name.IndexOf(name0 + p) == 0 || name.LastIndexOf(p) == name.Len() - strlen(p))
|
||||||
|
{
|
||||||
|
foundspeciallump = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue