public static void ZipDumpArcEntries(ArcsDatabase db, ArcsZipArcEntry entry) { string ext = Path.GetExtension(entry.path).ToLower(); switch (ext) { case ".zip": using (IArchive arc = new ZipArchive()) { DumpArcEntries(db, Path.Combine(TDCGExplorer.SystemDB.zips_path, entry.path), arc, entry.id); } break; case ".rar": using (IArchive arc = new RarArchive()) { DumpArcEntries(db, Path.Combine(TDCGExplorer.SystemDB.zips_path, entry.path), arc, entry.id); } break; case ".lzh": using (IArchive arc = new LzhArchive()) { DumpArcEntries(db, Path.Combine(TDCGExplorer.SystemDB.zips_path, entry.path), arc, entry.id); } break; default: break; } }
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); }
// zipファイルの場合はDBを調べる. public override void DoExploreNode() { ArcsZipArcEntry zip = TDCGExplorer.ArcsDB.GetZip(zipid); string fullpath = Path.Combine(TDCGExplorer.SystemDB.zips_path, zip.path); TDCGExplorer.ExplorerSelectPath(fullpath); }
public static void ZipsDumpTAHEntries(ArcsDatabase db, string zipname) { string ext = Path.GetExtension(zipname).ToLower(); if (ext == ".zip" || ext == ".lzh" || ext == ".rar") { TDCGExplorer.SetToolTips("Processing " + Path.GetFileName(zipname)); Regex filter = new Regex(zipcoderegexp); Match match = filter.Match(Path.GetFileName(zipname)); if (match.Success) { DateTime datetime = File.GetLastWriteTime(zipname); ArcsZipArcEntry entry = new ArcsZipArcEntry(); entry.id = 0; entry.path = zipname.Substring(zipspath.Length + 1); entry.code = match.Groups[1].ToString(); entry.exist = 1; entry.datetime = datetime; entry.id = db.SetZipEntry(entry); ZipDumpArcEntries(db, entry); } else { DateTime datetime = File.GetLastWriteTime(zipname); ArcsZipArcEntry entry = new ArcsZipArcEntry(); entry.id = 0; entry.path = zipname.Substring(zipspath.Length + 1); entry.code = Path.GetFileNameWithoutExtension(zipname); entry.exist = 1; entry.datetime = datetime; entry.id = db.SetZipEntry(entry); ZipDumpArcEntries(db, entry); } } }
public void ExtractFile() { if (info.zipid != -1) { ArcsZipArcEntry zipEntry = TDCGExplorer.GetArcsDatabase().GetZip(info.zipid); string zipsource = Path.Combine(TDCGExplorer.GetSystemDatabase().zips_path, zipEntry.path); switch (Path.GetExtension(zipEntry.path.ToLower())) { case ".zip": using (IArchive arc = new ZipArchive()) { ExtractFile(arc, zipsource); } break; case ".rar": using (IArchive arc = new RarArchive()) { ExtractFile(arc, zipsource); } break; case ".lzh": using (IArchive arc = new LzhArchive()) { ExtractFile(arc, zipsource); } break; default: break; } } }
public MODRefPage(int zipid) { TDCGExplorer.TDCGExplorer.SetToolTips("Databaseに問い合わせ中..."); zipEntry = TDCGExplorer.TDCGExplorer.ArcsDB.GetZip(zipid); InitializeComponent(); MODRefPageThread workerObject = new MODRefPageThread(zipEntry, this); Thread workerThread = new Thread(workerObject.DoWorkerThread); webBrowser.DocumentText = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"" + "\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">" + "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"ja\" lang=\"ja\">" + "<head>" + " <meta http-equiv=\"content-type\" content=\"text/html;charset=Shift_JIS\" />" + " <title>3DCG mods reference</title>" + " <link href=\"" + TDCGExplorer.TDCGExplorer.SystemDB.moddb_url + "/stylesheets/application.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />" + "</head>" + "<body>" + "<div id=\"wrapper\">" + " <div id=\"top-menu\">" + " <div id=\"account\">" + " <a href=\"/rails/\">Home</a>" + " <a href=\"/rails/session/new\">Login</a>" + " </div>" + " </div>" + " <div id=\"header\">" + " <h1>3DCG mods reference</h1>" + " <div id=\"main-menu\">" + " <ul>" + " <li><a href=\"/rails/arcs\" class=\"selected\">" + TextResource.Archive + "</a></li>" + " <li><a href=\"/rails/tahs\">tah</a></li>" + " <li><a href=\"/rails/tsos\">tso</a></li>" + " <li><a href=\"/rails/tags\">" + TextResource.Tag + "</a></li>" + " </ul>" + " </div>" + " </div>" + " <div id=\"main\" class=\"nosidebar\">" + " <div id=\"content\">" + " <h2>" + " <b>Loading....</b>" + " </h2>" + " </div>" + " </div>" + "</body>" + "</html>"; workerThread.Start(); Text = zipEntry.GetDisplayPath(); }
// アノテーションを入力する. public override void DoEditAnnotation() { AnnotationEdit edit = new AnnotationEdit(); ArcsZipArcEntry zip = TDCGExplorer.ArcsDB.GetZip(zipid); Dictionary <string, string> annon = TDCGExplorer.AnnDB.annotation; edit.text = zip.GetDisplayPath(); edit.code = zip.code; edit.Owner = TDCGExplorer.MainFormWindow; // エディットがOKなら書き換える. if (edit.ShowDialog() == DialogResult.OK) { TDCGExplorer.AnnDB.SetSqlValue(zip.code, edit.text); Text = edit.text; } }
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 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) { 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(); }
public GenericTAHStream(GenericTahInfo info, ArcsTahFilesEntry tsoInfo) { // zipファイルの中か? if (info.zipid != -1) { ArcsZipArcEntry zip = TDCGExplorer.ArcsDB.GetZip(info.zipid); string zippath = Path.Combine(TDCGExplorer.SystemDB.zips_path, zip.path); switch (Path.GetExtension(zip.path).ToLower()) { case ".zip": archive = new ZipArchive(); break; case ".lzh": archive = new LzhArchive(); break; case ".rar": archive = new RarArchive(); break; default: archive = new DirectAccessArchive(); break; } TDCGExplorer.LastAccessFile = zippath; archive.Open(zippath); if (archive == null) { throw new Exception(TextResource.ArchiveIsNull); } // foreach (IArchiveEntry entry in archive) { // ディレクトリのみの場合はスキップする. if (entry.IsDirectory == true) { continue; } // マッチするファイルを見つけた. if (entry.FileName == info.path) { ms = new MemoryStream((int)entry.Size); archive.Extract(entry, ms); ms.Seek(0, SeekOrigin.Begin); tah = new TAHFile(ms); tah.LoadEntries(); if (tsoInfo == null) { return; } int tahentry = 0; foreach (TAHEntry ent in tah.EntrySet.Entries) { // 該当ファイルを見つけた. if (tahentry == tsoInfo.tahentry) { byte[] data = TAHUtil.ReadEntryData(tah.Reader, ent); // Cursor.Current = Cursors.WaitCursor; ims = new MemoryStream(data); return; } tahentry++; } } } } else { string source = Path.Combine(TDCGExplorer.SystemDB.arcs_path, info.path); tah = new TAHFile(source); tah.LoadEntries(); if (tsoInfo == null) { return; } int tahentry = 0; foreach (TAHEntry ent in tah.EntrySet.Entries) { // 該当ファイルを見つけた. if (tahentry == tsoInfo.tahentry) { byte[] data = TAHUtil.ReadEntryData(tah.Reader, ent); // ims = new MemoryStream(data); return; } tahentry++; } } throw new Exception("TAH内のファイルが見つかりません"); }
public MODRefPageThread(ArcsZipArcEntry zipentry, MODRefPage self) { zipEntry = zipentry; page = self; }