Save PackageEntries into the index so the compressed data can be extracted.
This commit is contained in:
@@ -42,6 +42,8 @@ namespace OpenRA.FileFormats
|
|||||||
return new MixFile(filename, order++);
|
return new MixFile(filename, order++);
|
||||||
else if (filename.EndsWith(".zip"))
|
else if (filename.EndsWith(".zip"))
|
||||||
return new CompressedPackage(filename, order++);
|
return new CompressedPackage(filename, order++);
|
||||||
|
else if (filename.EndsWith(".Z"))
|
||||||
|
return new InstallShieldPackage(filename, order++);
|
||||||
else
|
else
|
||||||
return new Folder(filename, order++);
|
return new Folder(filename, order++);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,9 +17,9 @@ namespace OpenRA.FileFormats
|
|||||||
{
|
{
|
||||||
public class InstallShieldPackage : IFolder
|
public class InstallShieldPackage : IFolder
|
||||||
{
|
{
|
||||||
readonly Dictionary<uint, PackageEntry> index;
|
readonly Dictionary<uint, PackageEntry> index = new Dictionary<uint, PackageEntry>();
|
||||||
readonly long dataStart;
|
|
||||||
readonly Stream s;
|
readonly Stream s;
|
||||||
|
readonly long dataStart = 255;
|
||||||
int priority;
|
int priority;
|
||||||
|
|
||||||
public InstallShieldPackage(string filename, int priority)
|
public InstallShieldPackage(string filename, int priority)
|
||||||
@@ -39,15 +39,13 @@ namespace OpenRA.FileFormats
|
|||||||
var ArchiveSize = reader.ReadUInt32();
|
var ArchiveSize = reader.ReadUInt32();
|
||||||
reader.ReadBytes(19);
|
reader.ReadBytes(19);
|
||||||
var TOCAddress = reader.ReadInt32();
|
var TOCAddress = reader.ReadInt32();
|
||||||
|
reader.ReadBytes(4);
|
||||||
Console.WriteLine("SETUP.Z:");
|
var DirCount = reader.ReadUInt16();
|
||||||
Console.WriteLine("FileCount: {0}", FileCount);
|
|
||||||
Console.WriteLine("Archive Size: {0}", ArchiveSize);
|
|
||||||
|
|
||||||
// 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);
|
||||||
while (s.Position < s.Length)
|
for (var i = 0; i < DirCount; i++)
|
||||||
ParseDirectory(TOCreader);
|
ParseDirectory(TOCreader);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,12 +60,12 @@ 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);
|
||||||
|
|
||||||
Console.WriteLine("Directory `{0}': {1}", DirName, FileCount);
|
|
||||||
// Parse files
|
// Parse files
|
||||||
for (var i = 0; i < FileCount; i++)
|
for (var i = 0; i < FileCount; i++)
|
||||||
ParseFile(reader);
|
ParseFile(reader);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint AccumulatedData = 0;
|
||||||
void ParseFile(BinaryReader reader)
|
void ParseFile(BinaryReader reader)
|
||||||
{
|
{
|
||||||
reader.ReadBytes(7);
|
reader.ReadBytes(7);
|
||||||
@@ -78,10 +76,12 @@ namespace OpenRA.FileFormats
|
|||||||
var NameLength = reader.ReadByte();
|
var NameLength = reader.ReadByte();
|
||||||
var FileName = new String(reader.ReadChars(NameLength));
|
var FileName = new String(reader.ReadChars(NameLength));
|
||||||
|
|
||||||
|
var hash = PackageEntry.HashFilename(FileName);
|
||||||
|
index.Add(hash, new PackageEntry(hash,AccumulatedData, CompressedSize));
|
||||||
|
AccumulatedData += CompressedSize;
|
||||||
|
|
||||||
// Skip to the end of the chunk
|
// Skip to the end of the chunk
|
||||||
reader.ReadBytes(ChunkSize - NameLength - 30);
|
reader.ReadBytes(ChunkSize - NameLength - 30);
|
||||||
|
|
||||||
Console.WriteLine("\t{0}: {1}", FileName, CompressedSize);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Stream GetContent(uint hash)
|
public Stream GetContent(uint hash)
|
||||||
@@ -114,7 +114,7 @@ namespace OpenRA.FileFormats
|
|||||||
|
|
||||||
public int Priority
|
public int Priority
|
||||||
{
|
{
|
||||||
get { return 1000 + priority; }
|
get { return 2000 + priority; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user