internal void Write(ChunksManifest manifest) { this.Write(manifest.Chunks.Count); this.Write(manifest.Patches.Count); this.Write(manifest.Identifiers.Count); foreach (var chunk in manifest.Chunks) { this.Write(chunk.Archive); this.Write(chunk.DirectoryId); this.Write(chunk.BaseUnknown); this.Write(chunk.BasePosition); this.Write(chunk.BaseLength); this.Write(chunk.BaseZeros); } foreach (var patch in manifest.Patches) { this.Write(patch.PatchIdentifier); this.Write(patch.PatchStart); this.Write(patch.PatchLength); this.Write(patch.PatchZeros); this.Write(patch.PatchZeros2); } foreach (var id in manifest.Identifiers) { this.Write(id.Id); this.Write(id.PatchStart); } }
internal ChunksManifest ReadManifest() { UInt32 numberOfChunks = this.ReadUInt32(); UInt32 numberOfPatches = this.ReadUInt32(); UInt32 numberOfIds = this.ReadUInt32(); var chunks = new List <Chunk>(); var patches = new List <Patch>(); var identifiers = new List <Identifier>(); for (int i = 0; i < numberOfChunks; i++) { var chunk = new Chunk(); chunk.Archive = this.ReadByte(); chunk.DirectoryId = this.ReadByte(); chunk.BaseUnknown = this.ReadUInt16(); chunk.BasePosition = this.ReadUInt32(); chunk.BaseLength = this.ReadUInt32(); chunk.BaseZeros = this.ReadUInt32(); chunks.Add(chunk); } for (int i = 0; i < numberOfPatches; i++) { var patch = new Patch(); patch.PatchIdentifier = this.ReadUInt32(); patch.PatchStart = this.ReadUInt32(); patch.PatchLength = this.ReadUInt32(); patch.PatchZeros = this.ReadUInt32(); patch.PatchZeros2 = this.ReadUInt32(); patches.Add(patch); } for (int i = 0; i < numberOfIds; i++) { var identifier = new Identifier(); identifier.Id = this.ReadBytes(16); identifier.PatchStart = this.ReadUInt32(); identifiers.Add(identifier); } ChunksManifest manifest = new ChunksManifest() { Chunks = chunks, Patches = patches, Identifiers = identifiers }; return(manifest); }
public void LoadFileStructure() { using (ManifestBinaryReader manifestReader = new ManifestBinaryReader(File.Open(ResolveManifestCasFile(), FileMode.Open))) { chunkDescriptors = manifestReader.ReadChunkDescriptors().ToList(); manifest = manifestReader.ReadManifest(); } foreach (string dir in DataDirs) { using (CatalogueBinaryReader catReader = new CatalogueBinaryReader(File.Open(BaseDirectory + dir + @"\cas.cat", FileMode.Open))) { catalogues.Add(catReader.ReadCatalogue((byte)0x01)); } } }