static void process_generic_tree(ChunkBuilder chb, String basedir) { foreach (string subdir in Directory.GetDirectories(basedir)) { var subdirname = Path.GetFileName(subdir); Console.WriteLine(subdirname); if (subdirname.StartsWith("jg2") || subdirname == "base") { subdirname += ".pp"; foreach (var f in Directory.GetFiles(subdir)) { uint size = (uint)new System.IO.FileInfo(f).Length; var plain = Path.GetFileName(f); chb.AddChunkFile(new ChunkFile(new DirEntry(Path.GetFileName(f), f), subdirname, size)); } } else { foreach (var file in Directory.GetFiles(subdir, "*.*", SearchOption.AllDirectories)) { var fn = file.Substring(subdir.Length + 1).Replace("\\", "/"); var fi = new System.IO.FileInfo(file); if ((fi.Attributes & FileAttributes.Directory) == FileAttributes.Directory) { continue; } uint size = (uint)fi.Length; chb.AddChunkFile(new ChunkFile(new DirEntry(fn, file), subdirname, size)); } } } }
static void process_unpacked_tree(ChunkBuilder chb, IEnumerable <string> dirs, Regex r) { foreach (var dd in dirs) { Console.WriteLine("Scan " + dd); foreach (string dirn in Directory.GetDirectories(dd)) { var pdirn = Path.GetFileName(dirn); Console.WriteLine("Opening " + pdirn); if (!pdirn.StartsWith("jg2")) { continue; } pdirn += ".pp"; foreach (var f in Directory.GetFiles(dirn)) { uint size = (uint)new System.IO.FileInfo(f).Length; var plain = Path.GetFileName(f); if (r.Match(plain).Success) { chb.AddChunkFile(new ChunkFile(new DirEntry(Path.GetFileName(f), f), pdirn, size)); } } } } }
static void process_pp_files(ChunkBuilder chb, IEnumerable <string> dirs, Regex r) { foreach (var dd in dirs) { foreach (string fn in Directory.GetFiles(dd, "*.pp")) { Console.Write("Opening " + fn); if (fn.EndsWith("base.pp")) { continue; } ppParser pp = new ppParser(fn); int nmatch = 0; foreach (ppSubfile file in pp.Subfiles) { //Console.WriteLine(ext); if (r.Match(file.Name).Success) { chb.AddChunkFile(new ChunkFile(file, Path.GetFileName(file.ppPath), file.size)); nmatch++; } } Console.WriteLine("..." + nmatch + " files matched"); //if (nfm-- == 0) break; } } }
static void process_textures(ChunkBuilder chb, String bdir, Regex r) { foreach (var f in Directory.GetFiles(bdir, "*.*", SearchOption.AllDirectories)) { var fn = f.Substring(bdir.Length + 1).Replace("\\", "/"); var fi = new System.IO.FileInfo(f); if ((fi.Attributes & FileAttributes.Directory) == FileAttributes.Directory) { continue; } uint size = (uint)fi.Length; if (r.Match(fn).Success) { chb.AddChunkFile(new ChunkFile(new DirEntry(fn, f), "texture", size)); } } }