Пример #1
0
        public static TAHEntry Load(BinaryReader br, TAHFile file)
        {
            TAHEntry h = new TAHEntry();

            h.Read(br, file);
            return(h);
        }
Пример #2
0
        public void Read(BinaryReader br, TAHFile file)
        {
            Entries  = new List <TAHEntry>(file.Header.NumEntries);
            EntryMap = new Dictionary <uint, TAHEntry>();

            for (int i = 0, n = file.Header.NumEntries; i < n; ++i)
            {
                TAHEntry e = TAHEntry.Load(br, file);

                if (i != 0)
                {
                    TailEntry.Length = (int)(e.DataOffset - TailEntry.DataOffset);
                }
                //Console.WriteLine(e.ToString());
                Entries.Add(e);
                if (EntryMap.ContainsKey(e.Hash))
                {
                    //Console.WriteLine("Error: delect hashkey collision. " + e.Hash.ToString("X8") + ": " + e.DataOffset.ToString());
                    Debug.WriteLine("Error: detect hashkey collision. " + e.Hash.ToString("X8") + ": " + e.DataOffset.ToString());
                }
                else
                {
                    EntryMap.Add(e.Hash, e);
                }
            }

            TailEntry.Length = (int)(br.BaseStream.Length - TailEntry.DataOffset);
        }
Пример #3
0
        public static byte[] ReadEntryData(BinaryReader br, TAHEntry e)
        {
            br.BaseStream.Seek(e.DataOffset, SeekOrigin.Begin);
            byte[] output = new byte[br.ReadInt32()];
            byte[] input  = br.ReadBytes(e.Length - 4);

            TAHUtil.Decrypt(input, output);

            return(output);
        }
Пример #4
0
        // ファイル名を取得する.
        private static string GetFileName(TAHEntry entry)
        {
            string filename;

            filename = entry.FileName;

            if (filename == null)
            {
                filename = "00000000" + "_" + entry.Hash.ToString("x8");
            }
            return(filename);
        }
Пример #5
0
 public TAHContent LoadContent(BinaryReader br, TAHEntry e)
 {
     return(new TAHContent(e, TAHUtil.ReadEntryData(br, e)));
 }
Пример #6
0
 public TAHContent(TAHEntry e, byte[] data)
 {
     Entry = e;
     Data  = data;
 }
Пример #7
0
 public bool TryGetValue(uint hash, out TAHEntry e)
 {
     return(EntryMap.TryGetValue(hash, out e));
 }
Пример #8
0
 public static byte[] ReadRawEntryData(BinaryReader br, TAHEntry e, out uint len)
 {
     br.BaseStream.Seek(e.DataOffset, SeekOrigin.Begin);
     len = br.ReadUInt32();
     return(br.ReadBytes(e.Length - 4));
 }