public static TAHEntry Load(BinaryReader br, TAHFile file) { TAHEntry h = new TAHEntry(); h.Read(br, file); return(h); }
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); }
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); }
// ファイル名を取得する. private static string GetFileName(TAHEntry entry) { string filename; filename = entry.FileName; if (filename == null) { filename = "00000000" + "_" + entry.Hash.ToString("x8"); } return(filename); }
public TAHContent LoadContent(BinaryReader br, TAHEntry e) { return(new TAHContent(e, TAHUtil.ReadEntryData(br, e))); }
public TAHContent(TAHEntry e, byte[] data) { Entry = e; Data = data; }
public bool TryGetValue(uint hash, out TAHEntry e) { return(EntryMap.TryGetValue(hash, out e)); }
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)); }