- 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:
Christoph Oelckers 2021-07-25 12:18:53 +02:00
parent 3864dcfc17
commit c51c6fa524

View file

@ -208,8 +208,9 @@ bool FZipFile::Open(bool quiet, LumpFilterInfo* filter)
char *dirptr = (char*)directory;
FZipLump *lump_p = Lumps;
FString name0;
FString name0, name1;
bool foundspeciallump = false;
bool foundprefix = false;
// 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.
@ -234,31 +235,39 @@ bool FZipFile::Open(bool quiet, LumpFilterInfo* filter)
name.ToLower();
if (name.IndexOf("__macosx") == 0)
continue; // skip Apple garbage. At this stage only the root folder matters,
if (i == 0)
continue; // skip Apple garbage. At this stage only the root folder matters.
if (!foundprefix)
{
// 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());
if (isspecial) break;
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 = "";
break;
}
else if (!foundspeciallump && filter)
{
// at least one of the more common definition lumps must be present.
for (auto &p : filter->requiredPrefixes)
name0 = name1;
if (name.IndexOf(name0) != 0)
{
if (name.IndexOf(name0 + p) == 0 || name.LastIndexOf(p) == name.Len() - strlen(p))
{
foundspeciallump = true;
break;
}
name0 = "";
}
}
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;
}
}
}