public static void ZipsDumpDirEntries(string dir, ArcsDatabase db) { // ファイルを思わしき者は全部調べて、その中からzip,lzh,rarを抽出する. string[] zip_files = Directory.GetFiles(dir, "*.*"); foreach (string file in zip_files) { //string zipid = db.GetZipID(file.Substring(zipspath.Length + 1)); ArcsZipArcEntry zip = db.GetZip(file.Substring(zipspath.Length + 1)); if (zip != null) { DateTime datetime = File.GetLastWriteTime(file); if (zip.datetime.ToString() == datetime.ToString()) { // 該当するエントリの存在フラグを立てる. TDCGExplorer.SetToolTips("Update " + Path.GetFileName(file)); db.UpdateZipExistUp(zip.id); continue; } else { db.DeleteZip(zip.id); } } ZipsDumpTAHEntries(db, file); } string[] entries = Directory.GetDirectories(dir); foreach (string entry in entries) { // 解凍済みMODを処理する. string zipname = entry.Substring(zipspath.Length + 1); ArcsZipArcEntry zip = db.GetZip(zipname); if (zip != null) { DateTime datetime = File.GetLastWriteTime(entry); if (zip.datetime.ToString() == datetime.ToString()) { // 該当するエントリの存在フラグを立てる. TDCGExplorer.SetToolTips("Update " + Path.GetFileName(zip.path)); db.UpdateZipExistUp(zip.id); continue; } } // MOD名に一致するか調べる. char[] separetor = { '\\', '/' }; string[] sublevel = zipname.Split(separetor); string directory = sublevel[sublevel.Length - 1]; Regex regDirectAccess = new System.Text.RegularExpressions.Regex(TDCGExplorer.SystemDB.directaccess_signature); Match m = regDirectAccess.Match(directory); if (m.Success) { Regex filter = new Regex(zipcoderegexp); Match match = filter.Match(directory); if (match.Success == true) { TDCGExplorer.SetToolTips("Processing " + directory); ArcsZipArcEntry ent = new ArcsZipArcEntry(); ent.id = 0; ent.path = zipname; ent.code = match.Groups[1].ToString(); ent.exist = 1; ent.datetime = File.GetLastWriteTime(entry); ent.id = db.SetZipEntry(ent); DumpArcEntries(db, entry, new DirectAccessArchive(), ent.id); continue; } } // 通常のディレクトリスキャン. ZipsDumpDirEntries(entry, db); } }
public void Run() { TDCGExplorer.TDCGExplorer.IncBusy(); ArcsDatabase arcDB = TDCGExplorer.TDCGExplorer.ArcsDB; // TAHを列挙する. List <ArcsTahEntry> tahs = arcDB.GetTahs(); foreach (ArcsTahEntry tah in tahs) { Dictionary <string, ArcsTahEntry> tbnmap = new Dictionary <string, ArcsTahEntry>(); List <ArcsTahFilesEntry> files = arcDB.GetTahFilesPath(tah.id); foreach (ArcsTahFilesEntry file in files) { try { TDCGExplorer.TDCGExplorer.SetToolTips(TextResource.Searching + ":" + tah.shortname); if (file.path.ToLower().StartsWith("script/items/") /*|| file.path.ToLower().StartsWith("script/backgrounds/" )*/) { // TBNファイルか? if (file.path.ToLower().EndsWith(".tbn") == true) { // N765BODY_A00.TBN // 1234567890123456 string directory = Path.GetDirectoryName(file.path).ToLower().Replace('\\', '/'); string fullname = Path.GetFileNameWithoutExtension(file.path).ToLower(); string basename = fullname.Substring(0, 10); string colbase = directory + "/" + basename + "00.tbn"; // <<1.08.1 // コード毎のtbnファイル名を全て集める. if (tbnfiles.ContainsKey(colbase) == false) { tbnfiles.Add(colbase, new List <string>()); } tbnfiles[colbase].Add(file.path); // 1.08.1>> if (tbnmap.ContainsKey(colbase) == true) { continue; // 既に該当tbnの情報を見つけている. } // baseとなるtbnそのものだった場合. if (file.path.ToLower() == colbase) { tbnmap.Add(colbase, tah); continue; } // カテゴリ先頭のtbnファイルを検索する. List <ArcsTahFilesEntry> tbns = arcDB.GetTahFilesEntry(TDCGExplorer.TAHUtil.CalcHash(colbase)); if (tbns.Count == 0) { // 該当するtbnの00番が見つからない. MissingEntryInformation entry = new MissingEntryInformation(); entry.id = tah.id; entry.path = String.Copy(tah.path); entry.basetbn = String.Copy(colbase); entry.zipfiles = null; // 該当tbnを含むzipを検索する. HashSet <string> zipname = new HashSet <string>(); List <ArcsTahFilesEntry> zipfiles = arcDB.GetZipTahFilesEntries(TDCGExplorer.TAHUtil.CalcHash(colbase)); foreach (ArcsTahFilesEntry zipfile in zipfiles) { if (zipfile.path.ToLower() != colbase) { continue; // ハッシュ衝突なら無視する. } ArcsZipTahEntry ziptah = arcDB.GetZipTah(zipfile.tahid); ArcsZipArcEntry zip = arcDB.GetZip(ziptah.zipid); zipname.Add(zip.GetDisplayPath()); } // 発見したZIPの数だけ報告する.0 if (zipname.Count == 0) { control.asyncDisplayFromArcs(entry); } else { entry.zipfiles = new List <string>(); foreach (string zip in zipname) { entry.zipfiles.Add(String.Copy(zip)); } control.asyncDisplayFromArcs(entry); } } tbnmap.Add(colbase, tah); } } } // おかしなファイル名でindex違反が起きるかもしれない. catch (Exception) { } } } // TBN辞書をセットして終了 control.tbnfiles = tbnfiles; TDCGExplorer.TDCGExplorer.SetToolTips(TextResource.SearchComplete); TDCGExplorer.TDCGExplorer.DecBusy(); }
public void Run() { TDCGExplorer.TDCGExplorer.IncBusy(); ArcsDatabase arcDB = TDCGExplorer.TDCGExplorer.ArcsDB; // TAHを列挙する. List <ArcsTahEntry> tahs = arcDB.GetTahs(); foreach (ArcsTahEntry tah in tahs) { TDCGExplorer.TDCGExplorer.SetToolTips("検索中:" + tah.shortname); if (HasString(tah.path, keyword)) { FindEntryInformation entry = new FindEntryInformation(); entry.category = 0; // arcs entry.path = String.Copy(tah.path); entry.file = Path.GetFileName(tah.path); control.asyncDisplayFromArcs(entry); } } if (flagtahlevelsearch) { List <ArcsTahFilesEntry> files = arcDB.GetTahFilesPathHasString(keyword); foreach (ArcsTahFilesEntry file in files) { ArcsTahEntry tah = arcDB.GetTah(file.tahid); FindEntryInformation entry = new FindEntryInformation(); entry.category = 0; // arcs entry.path = String.Copy(tah.path); entry.file = String.Copy(file.GetDisplayPath()); control.asyncDisplayFromArcs(entry); } } if (flagzipsearch) { List <ArcsZipArcEntry> zips = arcDB.GetZips(); foreach (ArcsZipArcEntry zip in zips) { TDCGExplorer.TDCGExplorer.SetToolTips(TextResource.Searching + ":" + zip.GetDisplayPath()); if (HasString(zip.GetDisplayPath(), keyword)) { FindEntryInformation entry = new FindEntryInformation(); entry.category = 1; //zips entry.path = String.Copy(Path.GetDirectoryName(zip.path) + "\\" + zip.GetDisplayPath()); entry.file = zip.GetDisplayPath(); control.asyncDisplayFromArcs(entry); } } // LIKE文で総当たりする. List <ArcsZipTahEntry> ziptahs = arcDB.GetZipTahsHasString(keyword); foreach (ArcsZipTahEntry tah in ziptahs) { ArcsZipArcEntry subzip = arcDB.GetZip(tah.zipid); FindEntryInformation entry = new FindEntryInformation(); entry.category = 1; //zips entry.path = String.Copy(Path.GetDirectoryName(subzip.path) + "\\" + subzip.GetDisplayPath()); entry.file = tah.shortname; control.asyncDisplayFromArcs(entry); } } if (flagzipsearch && flagtahlevelsearch) { List <ArcsTahFilesEntry> files = arcDB.GetTahFilesPathHasString(keyword); foreach (ArcsTahFilesEntry file in files) { ArcsZipTahEntry tah = arcDB.GetZipTah(file.tahid); ArcsZipArcEntry zip = arcDB.GetZip(tah.zipid); FindEntryInformation entry = new FindEntryInformation(); entry.category = 1; //zips entry.path = String.Copy(zip.path + "\\" + zip.GetDisplayPath()); entry.file = String.Copy(file.GetDisplayPath()); control.asyncDisplayFromArcs(entry); } } // TBN辞書をセットして終了 TDCGExplorer.TDCGExplorer.SetToolTips(TextResource.SearchComplete); TDCGExplorer.TDCGExplorer.DecBusy(); }