Fixes issue #2216 InstallShield .Z package decompression

This commit is contained in:
baxtor
2013-05-26 21:51:37 +02:00
parent 93c89a6ef5
commit 629fe95ebd
2 changed files with 15 additions and 7 deletions

View File

@@ -12,6 +12,7 @@ The OpenRA developers are:
Also thanks to: Also thanks to:
* Akseli Virtanen (RAGEQUIT) * Akseli Virtanen (RAGEQUIT)
* Andrew Riedi * Andrew Riedi
* Andreas Beck (baxtor)
* Barnaby Smith (mvi) * Barnaby Smith (mvi)
* Bellator * Bellator
* Bugra Cuhadaroglu (BugraC) * Bugra Cuhadaroglu (BugraC)

View File

@@ -49,11 +49,20 @@ namespace OpenRA.FileFormats
// Parse the directory list // Parse the directory list
s.Seek(TOCAddress, SeekOrigin.Begin); s.Seek(TOCAddress, SeekOrigin.Begin);
BinaryReader TOCreader = new BinaryReader(s); BinaryReader TOCreader = new BinaryReader(s);
var fileCountInDirs = new List<uint>();
// Parse directories
for (var i = 0; i < DirCount; i++) for (var i = 0; i < DirCount; i++)
ParseDirectory(TOCreader); fileCountInDirs.Add(ParseDirectory(TOCreader));
// Parse files
foreach (var fileCount in fileCountInDirs)
for (var i = 0; i < fileCount; i++)
ParseFile(reader);
} }
void ParseDirectory(BinaryReader reader) uint ParseDirectory(BinaryReader reader)
{ {
// Parse directory header // Parse directory header
var FileCount = reader.ReadUInt16(); var FileCount = reader.ReadUInt16();
@@ -63,10 +72,7 @@ namespace OpenRA.FileFormats
// Skip to the end of the chunk // Skip to the end of the chunk
reader.ReadBytes(ChunkSize - NameLength - 6); reader.ReadBytes(ChunkSize - NameLength - 6);
return FileCount;
// Parse files
for (var i = 0; i < FileCount; i++)
ParseFile(reader);
} }
uint AccumulatedData = 0; uint AccumulatedData = 0;
@@ -81,7 +87,8 @@ namespace OpenRA.FileFormats
var FileName = new String(reader.ReadChars(NameLength)); var FileName = new String(reader.ReadChars(NameLength));
var hash = PackageEntry.HashFilename(FileName, PackageHashType.Classic); var hash = PackageEntry.HashFilename(FileName, PackageHashType.Classic);
index.Add(hash, new PackageEntry(hash, AccumulatedData, CompressedSize)); if(!index.ContainsKey(hash))
index.Add(hash, new PackageEntry(hash,AccumulatedData, CompressedSize));
filenames.Add(FileName); filenames.Add(FileName);
AccumulatedData += CompressedSize; AccumulatedData += CompressedSize;