Ejemplo n.º 1
0
 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);
     }
 }
Ejemplo n.º 2
0
 private void ReadGlobalBlockInfo(BinaryReader br)
 {
     packBlockHeaders = new List <Archive.PackBlockHeader>();
     br.BaseStream.Seek((long)header.ofsBlockTable, SeekOrigin.Begin);
     for (int b = 0; b < header.numBlocks; b++)
     {
         Archive.PackBlockHeader pbh = new Archive.PackBlockHeader();
         pbh.blockOffset = br.ReadUInt64();
         pbh.blockSize   = br.ReadUInt64();
         // find AIDX block by size //
         if (pbh.blockSize == 16)
         {
             AIDXBlockNumber = b;
         }
         packBlockHeaders.Add(pbh);
     }
 }