Exemple #1
0
        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;
            }
        }