public static byte[] GetFileBytes(string path) { if (fileList.ContainsKey(path)) { Archive.FileEntry fileEntry = fileList[path]; uint compression = fileEntry.flags;// 3: zlib compressed, 5: lzma compressed byte[] data; byte[] byteHash = fileEntry.hash; string hash = ToHex(byteHash); if (ArchiveFile.aarcEntries.ContainsKey(hash)) { Archive.AARCEntry aarcEntry = ArchiveFile.aarcEntries[hash]; Archive.PackBlockHeader packBlockHeader = ArchiveFile.packBlockHeaders[(int)aarcEntry.blockIndex]; string filePath = Path.GetDirectoryName(installLocation) + "\\Patch\\" + dataSource + ".archive"; using (FileStream fs = File.OpenRead(filePath)) { using (BinaryReader br = new BinaryReader(fs)) { br.BaseStream.Seek((long)packBlockHeader.blockOffset, SeekOrigin.Begin); data = br.ReadBytes((int)packBlockHeader.blockSize); } } //Console.Log((int)fileEntry.uncompressedSize + " " + fileEntry.uncompressedSize); if (compression == 3) { return(DecompressZlib(data, (int)fileEntry.uncompressedSize)); } else if (compression == 5) { return(DecompressLzma(data, (int)fileEntry.uncompressedSize)); } else { return(data); } } else { Console.Log("Missing AARC Entry : " + hash, Console.LogType.Error); return(null); } } else { Console.Log("Missing File : " + path, Console.LogType.Error); return(null); } }
private void ReadAARCEntries(BinaryReader br) { br.BaseStream.Seek((long)packBlockHeaders[(int)aarc.ofsAarcEntries].blockOffset, SeekOrigin.Begin); aarcEntries = new Dictionary <string, Archive.AARCEntry>(); //br.BaseStream.Seek(aarc.ofsAarcEntries, SeekOrigin.Begin); for (int a = 0; a < aarc.numAarcEntries; a++) { Archive.AARCEntry aarcEntry = new Archive.AARCEntry(); aarcEntry.blockIndex = br.ReadUInt32(); aarcEntry.shaHash = br.ReadBytes(20); aarcEntry.uncompressedSize = br.ReadUInt64(); string hash = DataManager.ToHex(aarcEntry.shaHash); if (!aarcEntries.ContainsKey(hash)) { aarcEntries.Add(hash, aarcEntry); } } }