예제 #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));
 }