static void build_ext_file_list(out ext_file_list external_files) { //read in names.txt file when it exists. external_files = new ext_file_list(); if (File.Exists("names.txt")) { StreamReader reader = new StreamReader(File.OpenRead("names.txt")); List <string> known_files = new List <string>(); System.Console.Out.WriteLine("Reading \"names.txt\" at " + System.Environment.CurrentDirectory.ToString() + "."); while (reader.BaseStream.Position < reader.BaseStream.Length) { known_files.Add(reader.ReadLine()); } //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++) { byte[] byte_string = System.Text.Encoding.ASCII.GetBytes(external_files.files[i] + "\0"); external_files.hashkeys[i] = gen_hash_key_for_string(ref byte_string); } } //sorting for faster look up... Array.Sort(external_files.hashkeys, external_files.files); } }
static void build_ext_file_list(out ext_file_list external_files) { //read in names.txt file when it exists. external_files = new ext_file_list(); string names_path = Path.Combine(Application.StartupPath, @"names.txt"); if (File.Exists(names_path)) { StreamReader reader = new StreamReader(File.OpenRead(names_path)); List <string> known_files = new List <string>(); System.Console.Out.WriteLine("Reading \"names.txt\" at " + Application.StartupPath + "."); 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] = CalcHash(external_files.files[i]); } } //sorting for faster look up... Array.Sort(external_files.hashkeys, external_files.files); } }