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 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); } }