public static void ReadExternalFileList() { external_files = new ext_file_list(); if (System.IO.File.Exists("names.txt")) { System.IO.StreamReader reader = new System.IO.StreamReader(System.IO.File.OpenRead("names.txt")); List <string> known_files = new List <string>(); string line; while ((line = reader.ReadLine()) != null) { known_files.Add(line); } //map a list of hash keys to the file... external_files.files = known_files.ToArray(); if (external_files.files != null) { external_files.hashkeys = new UInt32[external_files.files.Length]; for (int i = 0; i < external_files.files.Length; i++) { external_files.hashkeys[i] = TAHUtil.CalcHash(external_files.files[i]); //Console.WriteLine(external_files.hashkeys[i].ToString("X8") + "\t" + external_files.files[i]); } } //sorting for faster look up... Array.Sort(external_files.hashkeys, external_files.files); } }
public void Read(BinaryReader br, TAHFile file) { // ディレクトリデータの読み込み Files = new List <string>(file.Header.NumEntries); int output_length = br.ReadInt32(); int input_length = (int)(file.EntrySet[0].DataOffset - br.BaseStream.Position); //- 16 - 8 * file.Header.NumEntries; byte[] input = br.ReadBytes(input_length); byte[] output = new byte[output_length]; if (output.Length == 0) { return; } // add konoa:tahdecryptorのバグ回避. if (input.Length == 0) { return; } TAHUtil.Decrypt(input, output); //TAHdecrypt.Decrypter.decrypt(ref input, (uint)input.Length, ref output, (uint)output.Length); MemoryStream ms = new MemoryStream(output); BinaryReader br2 = new BinaryReader(ms); try { string dir = ""; while (ms.Position < ms.Length) { string name = TAHUtil.ReadString(br2); if (name.Length == 0) { } else if (name.EndsWith("/")) { dir = name; //DbgPrint("Directory: " + dir); } else { name = dir + name; uint hash = TAHUtil.CalcHash(name); TAHEntry ent; //DbgPrint(hash.ToString("X").PadLeft(8, '0')); if (file.EntrySet.TryGetValue(hash, out ent)) { ent.FileName = name; //DbgPrint(": Found: " + file); } else { //DbgPrint(": Not Found: " + file); System.Diagnostics.Debug.Assert(false); } //EntryMap[hash].FileName = FileName; } Files.Add(name); } } catch (EndOfStreamException) { } }