OSDN Git Service

書庫の対応検査をCheckArchiveとOpenArchiveの二段で行うことで、処理を簡略化。
authorsirakaba <sirakaba@9df91469-1e22-0410-86e7-ea8537beb833>
Thu, 23 Sep 2010 03:12:59 +0000 (03:12 +0000)
committersirakaba <sirakaba@9df91469-1e22-0410-86e7-ea8537beb833>
Thu, 23 Sep 2010 03:12:59 +0000 (03:12 +0000)
git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/tpi/tpi@329 9df91469-1e22-0410-86e7-ea8537beb833

src/lychee/cls_filedroptarget.cpp
src/lychee/frm_main.cpp
src/lychee/frm_main.h
src/plugin/7zArc/7zArc.cpp
src/plugin/eggArc/eggArc.cpp
src/plugin/rarArc/rarArc.cpp
src/plugin/xpiLibrary/xpiLibrary.cpp

index e97592b..3708b94 100644 (file)
@@ -45,11 +45,11 @@ bool myFileDropTarget::OnDropFiles(wxCoord, wxCoord, const wxArrayString & asFil
        if (asFiles.GetCount() == 1 && ::wxFileExists(asFiles[0]))\r
        {\r
                // 対応しているかどうか確認。\r
-               long l = this->mainFrame->LoadTPI(asFiles[0]);\r
-               if (l != 0)\r
+               wxULongLong_t llFileCount = 0;\r
+               if (this->mainFrame->LoadTPI(asFiles[0], & llFileCount))\r
                {\r
                        // 書庫を開く。\r
-                       e.SetExtraLong(l);\r
+                       e.SetExtraLong((long) llFileCount);\r
                        this->mainFrame->fnArchive = wxFileName(asFiles[0]);\r
                        this->mainFrame->OnArcOpen(e);\r
                        return true;\r
index fb6c6c8..a91f0a5 100644 (file)
@@ -328,43 +328,40 @@ void MainFrame::OnArcOpen(wxCommandEvent& e)
        ProcessDialog procDlg;\r
        procDlg.Show(true);\r
 \r
-       // TPIã\82\92読ã\81¿è¾¼ã\81¿ã\80\81æ\9c\80å\88\9dã\81®ã\82³ã\83¼ã\83«ã\83\90ã\83\83ã\82¯ã\82\92é\80\81ä¿¡ã\80\82\r
+       // TPIを読み込み。\r
        TPI_PROCESSINFO piInfo;\r
-       piInfo.eMessage = TPI_MESSAGE_STATUS;\r
-       piInfo.eStatus = 0x1000;\r
-       piInfo.nProcessedSize = 0;\r
-       piInfo.fiInfo.fnFileName = this->fnArchive;\r
-       piInfo.fiInfo.nUnpackedSize = e.GetExtraLong() != 0 ? e.GetExtraLong() : this->LoadTPI(this->fnArchive.GetFullPath());\r
+       piInfo.fiInfo.nUnpackedSize = e.GetExtraLong();\r
        if (piInfo.fiInfo.nUnpackedSize == 0)\r
        {\r
-               procDlg.Show(false);\r
-               tpi.FreeLibrary();\r
-               if (this->IsShown())\r
+               // DnD以外で書庫を開く場合。\r
+               if (! this->LoadTPI(this->fnArchive.GetFullPath(), & piInfo.fiInfo.nUnpackedSize))\r
                {\r
-                       wxBell();\r
-                       this->statusbar->SetStatusText(_("No plug-in supporting this archive was found!"), 4);\r
-               }\r
-               else\r
-               {\r
-                       wxLogError(_("No plug-in supporting this archive was found!"));\r
-                       this->Close(true);\r
+                       procDlg.Show(false);\r
+                       tpi.FreeLibrary();\r
+                       if (this->IsShown())\r
+                       {\r
+                               wxBell();\r
+                               this->statusbar->SetStatusText(_("No plug-in supporting this archive was found!"), 4);\r
+                       }\r
+                       else\r
+                       {\r
+                               wxLogError(_("No plug-in supporting this archive was found!"));\r
+                               this->Close(true);\r
+                       }\r
+                       return;\r
                }\r
-               return;\r
        }\r
+\r
+       // 最初のコールバックを送信。\r
+       piInfo.eMessage = TPI_MESSAGE_STATUS;\r
+       piInfo.eStatus = 0x1000;\r
+       piInfo.nProcessedSize = 0;\r
+       piInfo.fiInfo.fnFileName = this->fnArchive;\r
        procDlg.CallbackProc(TPI_NOTIFY_COMMON, & piInfo);\r
 \r
        // 配列のサイズを確保。\r
        this->fileinfo.Alloc(piInfo.fiInfo.nUnpackedSize);\r
 \r
-       // 書庫を開く。\r
-       if (! tpi.OpenArchive(this->fnArchive.GetFullPath()))\r
-       {\r
-               procDlg.Show(false);\r
-               tpi.FreeLibrary();\r
-               this->ErrorCheck(tpi.nErrorCode, wxT("OpenArchive"));\r
-               return;\r
-       }\r
-\r
        // 履歴に追加。\r
        this->conf.WriteHistory(CONF_HISTORY_PATH, this->fnArchive.GetPath());\r
        this->conf.WriteHistory(CONF_HISTORY_NAME, this->fnArchive.GetFullName());\r
@@ -1001,11 +998,10 @@ void MainFrame::OnFilter(wxCommandEvent&)
 \r
 // イベントハンドラ以外。\r
 \r
-wxULongLong_t MainFrame::LoadTPI(wxString szFileName)\r
+bool MainFrame::LoadTPI(wxString szFileName, wxULongLong_t * llFileCount)\r
 {\r
        // TPIを読み込み。\r
        wxDir fs(L_DIR_B_LIB);\r
-       wxULongLong_t llFileCount = 0;\r
        wxString szTPIName;\r
        if (fs.GetFirst(& szTPIName, wxT("*" TPI_EXT)))\r
        {\r
@@ -1022,17 +1018,17 @@ wxULongLong_t MainFrame::LoadTPI(wxString szFileName)
                        tpi.SetCallbackProc(TPICallbackProc);\r
 \r
                        // 対応確認。\r
-                       if (! tpi.CheckArchive(szFileName, & llFileCount) || llFileCount == 0)\r
+                       if (! tpi.CheckArchive(szFileName, llFileCount) || ! tpi.OpenArchive(szFileName))\r
                        {\r
                                tpi.FreeLibrary();\r
-                               llFileCount = 0;\r
+                               llFileCount = 0;\r
                                continue;\r
                        }\r
-                       break;\r
+                       return true;\r
                }\r
                while (fs.GetNext(& szTPIName));\r
        }\r
-       return llFileCount;\r
+       return false;\r
 }\r
 \r
 int MainFrame::ErrorCheck(int nErrorCode, wxString szAPIName)\r
index 9a9e1d6..4b9e60e 100644 (file)
@@ -65,7 +65,7 @@ public:
 \r
        void OnFilter(wxCommandEvent&);\r
 \r
-       wxULongLong_t LoadTPI(wxString);\r
+       bool LoadTPI(wxString, wxULongLong_t *);\r
        int ErrorCheck(int, wxString szAPIName = wxT("Command"));\r
 \r
        MainFrame();\r
index 6d06d46..ec9a2cb 100644 (file)
@@ -795,25 +795,11 @@ int __stdcall FreePlugin
 \r
 int __stdcall CheckArchive\r
 (\r
-       const wxString & _szArcName,\r
-       wxULongLong_t * _llFileCount\r
+       const wxString &,\r
+       wxULongLong_t *\r
 )\r
 {\r
-       void * _hArchive;\r
-       int nErrorCode = OpenArchive(_szArcName, & _hArchive);\r
-       if (nErrorCode != TPI_ERROR_SUCCESS)\r
-       {\r
-               return nErrorCode;\r
-       }\r
-\r
-       if (_llFileCount != NULL)\r
-       {\r
-               unsigned int nFileCount = 0;\r
-               ((IInArchive *) _hArchive)->GetNumberOfItems(& nFileCount);\r
-               * _llFileCount = nFileCount;\r
-       }\r
-\r
-       return CloseArchive(_hArchive);\r
+       return TPI_ERROR_SUCCESS;\r
 }\r
 \r
 int __stdcall OpenArchive\r
index da0fbdd..0e80f14 100644 (file)
@@ -232,7 +232,7 @@ int __stdcall FreePlugin
 int __stdcall CheckArchive\r
 (\r
        const wxString & _szArcName,\r
-       wxULongLong_t * _llFileCount\r
+       wxULongLong_t *\r
 )\r
 {\r
        FARPROC fpProc = ::GetAPIAddress("IsValidArchive");\r
@@ -241,11 +241,6 @@ int __stdcall CheckArchive
                return TPI_ERROR_U_USE_LIBRARY;\r
        }\r
 \r
-       if (_llFileCount != NULL)\r
-       {\r
-               * _llFileCount = 1;\r
-       }\r
-\r
        egg_type eType;\r
        return ErrorCodeConvert(((UINT (__cdecl *)(const wchar_t *, egg_type *)) fpProc)(_szArcName.wchar_str(), & eType));\r
 }\r
index 3a8f5e4..0ebfc41 100644 (file)
@@ -212,23 +212,11 @@ int __stdcall FreePlugin
 \r
 int __stdcall CheckArchive\r
 (\r
-       const wxString & _szArcName,\r
-       wxULongLong_t * _llFileCount\r
+       const wxString &,\r
+       wxULongLong_t *\r
 )\r
 {\r
-       void * _hArchive;\r
-       int nErrorCode = OpenArchive(_szArcName, & _hArchive);\r
-       if (nErrorCode != TPI_ERROR_SUCCESS)\r
-       {\r
-               return nErrorCode;\r
-       }\r
-\r
-       if (_llFileCount != NULL)\r
-       {\r
-               * _llFileCount = 1;\r
-       }\r
-\r
-       return CloseArchive(_hArchive);\r
+       return TPI_ERROR_SUCCESS;\r
 }\r
 \r
 int __stdcall OpenArchive\r
index 8ad7930..1950608 100644 (file)
@@ -204,11 +204,6 @@ int __stdcall CheckArchive
        }\r
        hFile.Close();\r
 \r
-       if (_llFileCount != NULL)\r
-       {\r
-               * _llFileCount = 1;\r
-       }\r
-\r
        return TPI_ERROR_SUCCESS;\r
 }\r
 \r