コード例 #1
0
ファイル: GenTahInfo.cs プロジェクト: xvok16/TDCGExplorer
 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;
 }
コード例 #2
0
        public static void OpenTahEditor(GenericTahInfo entry)
        {
#if false
            string tahdbpath = GetTahDbPath(entry);
            // 同じDBエントリを開いているエディタタブが存在しないかチェックする。
            foreach (TabPage tabpage in TDCGExplorer.MainFormWindow.TabControlMainView.Controls)
            {
                TAHEditor edit = tabpage.Controls[0] as TAHEditor;
                if (edit != null)
                {
                    if (edit.TahDBPath == tahdbpath)
                    {
                        MessageBox.Show("既にこのTAHを開いています。", "エラー", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        return;
                    }
                }
            }
            // 既にファイルが存在しないかチェックする.
            if (File.Exists(tahdbpath))
            {
                string path;
                using (TAHLocalDB tahdb = new TAHLocalDB())
                {
                    tahdb.Open(tahdbpath);
                    path = tahdb["source"];
                }
                if (path != entry.path)
                {
                    if (MessageBox.Show("別のTAHファイルを格納しているDBがあります。\n削除して新規作成しますか?", "DBの更新", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes)
                    {
                        // ファイルを削除する.
                        //File.Delete(tahdbpath);
                        TDCGExplorer.FileDelete(tahdbpath);
                        // 新規作成する.
                        TAHEditor editor = null;
                        try
                        {
                            editor = new TAHEditor(tahdbpath, new GenericZipsTahInfo(entry));
                            TDCGExplorer.MainFormWindow.AssignTagPageControl(editor);
                            editor.SelectAll();
                        }
                        catch (Exception)
                        {
                            if (editor != null)
                            {
                                editor.Dispose();
                            }
                        }
                    }
                }
                else
                {
                    // 既にあるファイルをオープンする.
                    TAHEditor editor = null;
                    try
                    {
                        editor = new TAHEditor(tahdbpath, null);
                        TDCGExplorer.MainFormWindow.AssignTagPageControl(editor);
                        editor.SelectAll();
                    }
                    catch (Exception)
                    {
                        if (editor != null)
                        {
                            editor.Dispose();
                        }
                    }
                }
            }
            else
            {
                // 新規に作成する.
                TAHEditor editor = null;
                try
                {
                    editor = new TAHEditor(tahdbpath, new GenericZipsTahInfo(entry));
                    TDCGExplorer.MainFormWindow.AssignTagPageControl(editor);
                    editor.SelectAll();
                }
                catch (Exception)
                {
                    if (editor != null)
                    {
                        editor.Dispose();
                    }
                }
            }
#else
            // 新規に作成する.
            TAHEditor editor = null;
            try
            {
                editor = new TAHEditor(new GenericZipsTahInfo(entry));
                TDCGExplorer.MainFormWindow.AssignTagPageControl(editor);
                editor.SelectAll();
            }
            catch (Exception)
            {
                if (editor != null)
                {
                    editor.Dispose();
                }
            }
#endif
        }
コード例 #3
0
 public static void DeleteTahEditorFile(GenericTahInfo entry)
 {
     //File.Delete(GetTahDbPath(entry));
     TDCGExplorer.FileDelete(GetTahDbPath(entry));
 }
コード例 #4
0
 public static string GetTahDbPath(GenericTahInfo entry)
 {
     return((Path.Combine(TDCGExplorer.SystemDB.tahpath, entry.shortname) + ".db").ToLower());
 }
コード例 #5
0
ファイル: TAHStream.cs プロジェクト: xvok16/TDCGExplorer
        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内のファイルが見つかりません");
        }