From b7cb944a492a091315cd1682b200fa313f89c6b0 Mon Sep 17 00:00:00 2001 From: sirakaba Date: Thu, 23 Sep 2010 03:12:59 +0000 Subject: [PATCH] =?utf8?q?=E6=9B=B8=E5=BA=AB=E3=81=AE=E5=AF=BE=E5=BF=9C?= =?utf8?q?=E6=A4=9C=E6=9F=BB=E3=82=92CheckArchive=E3=81=A8OpenArchive?= =?utf8?q?=E3=81=AE=E4=BA=8C=E6=AE=B5=E3=81=A7=E8=A1=8C=E3=81=86=E3=81=93?= =?utf8?q?=E3=81=A8=E3=81=A7=E3=80=81=E5=87=A6=E7=90=86=E3=82=92=E7=B0=A1?= =?utf8?q?=E7=95=A5=E5=8C=96=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/tpi/tpi@329 9df91469-1e22-0410-86e7-ea8537beb833 --- src/lychee/cls_filedroptarget.cpp | 6 ++-- src/lychee/frm_main.cpp | 60 +++++++++++++++++------------------- src/lychee/frm_main.h | 2 +- src/plugin/7zArc/7zArc.cpp | 20 ++---------- src/plugin/eggArc/eggArc.cpp | 7 +---- src/plugin/rarArc/rarArc.cpp | 18 ++--------- src/plugin/xpiLibrary/xpiLibrary.cpp | 5 --- 7 files changed, 39 insertions(+), 79 deletions(-) diff --git a/src/lychee/cls_filedroptarget.cpp b/src/lychee/cls_filedroptarget.cpp index e97592b..3708b94 100644 --- a/src/lychee/cls_filedroptarget.cpp +++ b/src/lychee/cls_filedroptarget.cpp @@ -45,11 +45,11 @@ bool myFileDropTarget::OnDropFiles(wxCoord, wxCoord, const wxArrayString & asFil if (asFiles.GetCount() == 1 && ::wxFileExists(asFiles[0])) { // 対応しているかどうか確認。 - long l = this->mainFrame->LoadTPI(asFiles[0]); - if (l != 0) + wxULongLong_t llFileCount = 0; + if (this->mainFrame->LoadTPI(asFiles[0], & llFileCount)) { // 書庫を開く。 - e.SetExtraLong(l); + e.SetExtraLong((long) llFileCount); this->mainFrame->fnArchive = wxFileName(asFiles[0]); this->mainFrame->OnArcOpen(e); return true; diff --git a/src/lychee/frm_main.cpp b/src/lychee/frm_main.cpp index fb6c6c8..a91f0a5 100644 --- a/src/lychee/frm_main.cpp +++ b/src/lychee/frm_main.cpp @@ -328,43 +328,40 @@ void MainFrame::OnArcOpen(wxCommandEvent& e) ProcessDialog procDlg; procDlg.Show(true); - // TPIを読み込み、最初のコールバックを送信。 + // TPIを読み込み。 TPI_PROCESSINFO piInfo; - piInfo.eMessage = TPI_MESSAGE_STATUS; - piInfo.eStatus = 0x1000; - piInfo.nProcessedSize = 0; - piInfo.fiInfo.fnFileName = this->fnArchive; - piInfo.fiInfo.nUnpackedSize = e.GetExtraLong() != 0 ? e.GetExtraLong() : this->LoadTPI(this->fnArchive.GetFullPath()); + piInfo.fiInfo.nUnpackedSize = e.GetExtraLong(); if (piInfo.fiInfo.nUnpackedSize == 0) { - procDlg.Show(false); - tpi.FreeLibrary(); - if (this->IsShown()) + // DnD以外で書庫を開く場合。 + if (! this->LoadTPI(this->fnArchive.GetFullPath(), & piInfo.fiInfo.nUnpackedSize)) { - wxBell(); - this->statusbar->SetStatusText(_("No plug-in supporting this archive was found!"), 4); - } - else - { - wxLogError(_("No plug-in supporting this archive was found!")); - this->Close(true); + procDlg.Show(false); + tpi.FreeLibrary(); + if (this->IsShown()) + { + wxBell(); + this->statusbar->SetStatusText(_("No plug-in supporting this archive was found!"), 4); + } + else + { + wxLogError(_("No plug-in supporting this archive was found!")); + this->Close(true); + } + return; } - return; } + + // 最初のコールバックを送信。 + piInfo.eMessage = TPI_MESSAGE_STATUS; + piInfo.eStatus = 0x1000; + piInfo.nProcessedSize = 0; + piInfo.fiInfo.fnFileName = this->fnArchive; procDlg.CallbackProc(TPI_NOTIFY_COMMON, & piInfo); // 配列のサイズを確保。 this->fileinfo.Alloc(piInfo.fiInfo.nUnpackedSize); - // 書庫を開く。 - if (! tpi.OpenArchive(this->fnArchive.GetFullPath())) - { - procDlg.Show(false); - tpi.FreeLibrary(); - this->ErrorCheck(tpi.nErrorCode, wxT("OpenArchive")); - return; - } - // 履歴に追加。 this->conf.WriteHistory(CONF_HISTORY_PATH, this->fnArchive.GetPath()); this->conf.WriteHistory(CONF_HISTORY_NAME, this->fnArchive.GetFullName()); @@ -1001,11 +998,10 @@ void MainFrame::OnFilter(wxCommandEvent&) // イベントハンドラ以外。 -wxULongLong_t MainFrame::LoadTPI(wxString szFileName) +bool MainFrame::LoadTPI(wxString szFileName, wxULongLong_t * llFileCount) { // TPIを読み込み。 wxDir fs(L_DIR_B_LIB); - wxULongLong_t llFileCount = 0; wxString szTPIName; if (fs.GetFirst(& szTPIName, wxT("*" TPI_EXT))) { @@ -1022,17 +1018,17 @@ wxULongLong_t MainFrame::LoadTPI(wxString szFileName) tpi.SetCallbackProc(TPICallbackProc); // 対応確認。 - if (! tpi.CheckArchive(szFileName, & llFileCount) || llFileCount == 0) + if (! tpi.CheckArchive(szFileName, llFileCount) || ! tpi.OpenArchive(szFileName)) { tpi.FreeLibrary(); - llFileCount = 0; + * llFileCount = 0; continue; } - break; + return true; } while (fs.GetNext(& szTPIName)); } - return llFileCount; + return false; } int MainFrame::ErrorCheck(int nErrorCode, wxString szAPIName) diff --git a/src/lychee/frm_main.h b/src/lychee/frm_main.h index 9a9e1d6..4b9e60e 100644 --- a/src/lychee/frm_main.h +++ b/src/lychee/frm_main.h @@ -65,7 +65,7 @@ public: void OnFilter(wxCommandEvent&); - wxULongLong_t LoadTPI(wxString); + bool LoadTPI(wxString, wxULongLong_t *); int ErrorCheck(int, wxString szAPIName = wxT("Command")); MainFrame(); diff --git a/src/plugin/7zArc/7zArc.cpp b/src/plugin/7zArc/7zArc.cpp index 6d06d46..ec9a2cb 100644 --- a/src/plugin/7zArc/7zArc.cpp +++ b/src/plugin/7zArc/7zArc.cpp @@ -795,25 +795,11 @@ int __stdcall FreePlugin int __stdcall CheckArchive ( - const wxString & _szArcName, - wxULongLong_t * _llFileCount + const wxString &, + wxULongLong_t * ) { - void * _hArchive; - int nErrorCode = OpenArchive(_szArcName, & _hArchive); - if (nErrorCode != TPI_ERROR_SUCCESS) - { - return nErrorCode; - } - - if (_llFileCount != NULL) - { - unsigned int nFileCount = 0; - ((IInArchive *) _hArchive)->GetNumberOfItems(& nFileCount); - * _llFileCount = nFileCount; - } - - return CloseArchive(_hArchive); + return TPI_ERROR_SUCCESS; } int __stdcall OpenArchive diff --git a/src/plugin/eggArc/eggArc.cpp b/src/plugin/eggArc/eggArc.cpp index da0fbdd..0e80f14 100644 --- a/src/plugin/eggArc/eggArc.cpp +++ b/src/plugin/eggArc/eggArc.cpp @@ -232,7 +232,7 @@ int __stdcall FreePlugin int __stdcall CheckArchive ( const wxString & _szArcName, - wxULongLong_t * _llFileCount + wxULongLong_t * ) { FARPROC fpProc = ::GetAPIAddress("IsValidArchive"); @@ -241,11 +241,6 @@ int __stdcall CheckArchive return TPI_ERROR_U_USE_LIBRARY; } - if (_llFileCount != NULL) - { - * _llFileCount = 1; - } - egg_type eType; return ErrorCodeConvert(((UINT (__cdecl *)(const wchar_t *, egg_type *)) fpProc)(_szArcName.wchar_str(), & eType)); } diff --git a/src/plugin/rarArc/rarArc.cpp b/src/plugin/rarArc/rarArc.cpp index 3a8f5e4..0ebfc41 100644 --- a/src/plugin/rarArc/rarArc.cpp +++ b/src/plugin/rarArc/rarArc.cpp @@ -212,23 +212,11 @@ int __stdcall FreePlugin int __stdcall CheckArchive ( - const wxString & _szArcName, - wxULongLong_t * _llFileCount + const wxString &, + wxULongLong_t * ) { - void * _hArchive; - int nErrorCode = OpenArchive(_szArcName, & _hArchive); - if (nErrorCode != TPI_ERROR_SUCCESS) - { - return nErrorCode; - } - - if (_llFileCount != NULL) - { - * _llFileCount = 1; - } - - return CloseArchive(_hArchive); + return TPI_ERROR_SUCCESS; } int __stdcall OpenArchive diff --git a/src/plugin/xpiLibrary/xpiLibrary.cpp b/src/plugin/xpiLibrary/xpiLibrary.cpp index 8ad7930..1950608 100644 --- a/src/plugin/xpiLibrary/xpiLibrary.cpp +++ b/src/plugin/xpiLibrary/xpiLibrary.cpp @@ -204,11 +204,6 @@ int __stdcall CheckArchive } hFile.Close(); - if (_llFileCount != NULL) - { - * _llFileCount = 1; - } - return TPI_ERROR_SUCCESS; } -- 2.11.0