private string FindFromZipTahs(string filename, int id) { string retval = ""; List <ArcsTahFilesEntry> files = TDCGExplorer.TDCGExplorer.ArcsDB.GetZipTahFilesEntries(TAHUtil.CalcHash("script/" + filename + ".tbn")); if (files.Count > 0) { ArcsTahFilesEntry file = null; ArcsZipTahEntry tah = null; int pastVersion = -1; foreach (ArcsTahFilesEntry subfile in files) { ArcsZipTahEntry subtah = TDCGExplorer.TDCGExplorer.ArcsDB.GetZipTah(subfile.tahid); if (subtah.version > pastVersion) { file = subfile; tah = subtah; pastVersion = subtah.version; } } if (tah != null) { ArcsZipArcEntry zip = TDCGExplorer.TDCGExplorer.ArcsDB.GetZip(tah.zipid); if (zip != null) { retval = Path.GetDirectoryName(zip.path) + "\\" + zip.GetDisplayPath() + "\\" + tah.path; LoadTso(new GenericZipsTahInfo(tah), file, id); } } } return(retval); }
public GenericZipsTahInfo(GenericTahInfo info) { tahEntry = new ArcsZipTahEntry(); tahEntry.id = info.id; tahEntry.path = info.path; tahEntry.shortname = info.shortname; tahEntry.version = info.version; tahEntry.zipid = info.zipid; }
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(); }
private void assembleTsoData() { foreach (LoadTsoInfo tsoload in loadtsoinfo) { GenericTahInfo info = tsoload.info; ArcsTahFilesEntry file = tsoload.file; int id = tsoload.id; try { // tso名を取得する. string tsoname; using (GenericTAHStream tahstream = new GenericTAHStream(info, file)) { using (MemoryStream memorystream = new MemoryStream()) { ZipFileUtil.CopyStream(tahstream.stream, memorystream); tsoname = TDCGTbnUtil.GetTsoName(memorystream.ToArray()); } } GenericTahInfo tsoinfo = null; ArcsTahFilesEntry tso = null; if (info.zipid < 0) {// Arcsの場合 int pastVersion = -1; ArcsTahEntry tahinfo = null; List <ArcsTahFilesEntry> tsos = TDCGExplorer.TDCGExplorer.ArcsDB.GetTahFilesEntry(TAHUtil.CalcHash(tsoname)); foreach (ArcsTahFilesEntry subfile in tsos) { ArcsTahEntry subtah = TDCGExplorer.TDCGExplorer.ArcsDB.GetTah(subfile.tahid); if (subtah.version > pastVersion) { tso = subfile; tahinfo = subtah; pastVersion = subtah.version; } } tsoinfo = new GenericArcsTahInfo(tahinfo); } else {// zipの場合 int pastVersion = -1; ArcsZipTahEntry tahinfo = null; List <ArcsTahFilesEntry> tsos = TDCGExplorer.TDCGExplorer.ArcsDB.GetZipTahFilesEntries(TAHUtil.CalcHash(tsoname)); foreach (ArcsTahFilesEntry subfile in tsos) { ArcsZipTahEntry subtah = TDCGExplorer.TDCGExplorer.ArcsDB.GetZipTah(subfile.tahid); if (subtah.version > pastVersion) { tso = subfile; tahinfo = subtah; pastVersion = subtah.version; } } tsoinfo = new GenericZipsTahInfo(tahinfo); } if (tsoinfo != null && tso != null) { // TSOを読み込む using (GenericTAHStream tahstream = new GenericTAHStream(tsoinfo, tso)) { using (MemoryStream memorystream = new MemoryStream()) { ZipFileUtil.CopyStream(tahstream.stream, memorystream); PNGTsoData tsodata = new PNGTsoData(); tsodata.tsoID = (uint)id; tsodata.tsodata = memorystream.ToArray(); tsoDataList.Add(tsodata); } } } } catch (Exception) { } } }
public static void DumpArcEntries(ArcsDatabase db, string source_file, IArchive arc, int id) { try { TDCGExplorer.LastAccessFile = source_file; arc.Open(source_file); foreach (IArchiveEntry entry in arc) { // ディレクトリのみの場合はスキップする. if (entry.IsDirectory == true) { continue; } // TAHファイルなら詳細をダンプする. if (Path.GetExtension(entry.FileName) == ".tah") { using (MemoryStream ms = new MemoryStream((int)entry.Size)) { arc.Extract(entry, ms); ms.Seek(0, SeekOrigin.Begin); using (TAHFile tah = new TAHFile(ms)) { try { tah.LoadEntries(); } catch (Exception ex) { Debug.WriteLine("Error: " + ex); continue; } ArcsZipTahEntry ziptahentry = new ArcsZipTahEntry(); ziptahentry.id = 0; ziptahentry.path = entry.FileName; ziptahentry.shortname = Path.GetFileName(entry.FileName).ToLower(); ziptahentry.version = (int)tah.Header.Version; ziptahentry.zipid = id; int tahid = db.SetZipTahEntry(ziptahentry); int tahentry = 0; foreach (TAHEntry ent in tah.EntrySet.Entries) { if (ent.FileName == null) { TDCGExplorer.SetToolTips("Dump " + ent.Hash.ToString("x8") + " file"); } else { TDCGExplorer.SetToolTips("Dump " + Path.GetFileName(ent.FileName) + " file"); } ArcsTahFilesEntry fileentry = new ArcsTahFilesEntry(); fileentry.id = 0; fileentry.tahid = tahid; fileentry.tahentry = tahentry++; fileentry.path = ent.FileName; if (fileentry.path == null) { fileentry.path = ""; } //fileentry.md5sum = ""; fileentry.hash = (int)ent.Hash; fileentry.length = (int)ent.Length; db.SetZipTahFilesPath(fileentry); } } } } else { // tahファイル以外はファイル名のみ情報を格納する. ArcsZipTahEntry ziptahentry = new ArcsZipTahEntry(); ziptahentry.id = 0; ziptahentry.path = entry.FileName; ziptahentry.version = 0; ziptahentry.zipid = id; int tahid = db.SetZipTahEntry(ziptahentry); } } } catch (Exception ex) { Debug.WriteLine("Error: " + ex); return; } }
public GenericZipsTahInfo(ArcsZipTahEntry entry) { tahEntry = entry; }
public LbZipFileItem(ArcsZipTahEntry argentry) { entry = argentry; }
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(); }