OSDN Git Service

Command()に書庫のハンドルを渡せるよう変更。TPI_INFO_HANDLE_ON_COMMANDを追加。
authorsirakaba <sirakaba@9df91469-1e22-0410-86e7-ea8537beb833>
Sun, 15 Jan 2012 10:42:21 +0000 (10:42 +0000)
committersirakaba <sirakaba@9df91469-1e22-0410-86e7-ea8537beb833>
Sun, 15 Jan 2012 10:42:21 +0000 (10:42 +0000)
git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/tpi/tpi@588 9df91469-1e22-0410-86e7-ea8537beb833

12 files changed:
src/common/handle/TPIHandle.cpp
src/common/handle/TPIHandle.h
src/common/header/plugin.h
src/common/library/library.cpp
src/common/library/library.h
src/plugin/7zArc/7zArc.cpp
src/plugin/calLibrary/calLibrary.cpp
src/plugin/cuiWrapper/cuiWrapper.cpp
src/plugin/eggArc/eggArc.cpp
src/plugin/rarArc/rarArc.cpp
src/plugin/spiLibrary/spiLibrary.cpp
src/plugin/xpiLibrary/xpiLibrary.cpp

index e761cf5..f64ca06 100644 (file)
@@ -43,9 +43,8 @@
 //    Class (TPIHandle)\r
 //******************************************************************************\r
 \r
-TPIHandle::TPIHandle(void)\r
+TPIHandle::TPIHandle(void) : nErrorCode(TPI_ERROR_SUCCESS), bHandleOnCommand(1), archive(NULL)\r
 {\r
-       this->nErrorCode = TPI_ERROR_SUCCESS;\r
 }\r
 \r
 TPIHandle::~TPIHandle(void)\r
@@ -67,7 +66,12 @@ bool TPIHandle::InitLibrary(const wxString & _szLibName, const wxString & _szArc
        }\r
 \r
        GetAPIAddress("LoadPlugin", p);\r
-       this->nErrorCode = ((int (__stdcall *)(const wxString &, TPI_PROC, wxULongLong_t)) p)(_szArcName, _prProc, _llTypeId);\r
+       int nErrorCode = ((int (__stdcall *)(const wxString &, TPI_PROC, wxULongLong_t)) p)(_szArcName, _prProc, _llTypeId);\r
+       if (! this->GetPluginInformation(TPI_INFO_HANDLE_ON_COMMAND, 0, & this->bHandleOnCommand))\r
+       {\r
+               this->bHandleOnCommand = 1;\r
+       }\r
+       this->nErrorCode = nErrorCode;\r
        return this->nErrorCode == TPI_ERROR_SUCCESS;\r
 }\r
 \r
@@ -139,9 +143,14 @@ bool TPIHandle::OpenArchive(const wxString & _szArcName, wxULongLong_t * _llFile
 \r
 bool TPIHandle::CloseArchive(void)\r
 {\r
+       if (this->archive == NULL)\r
+       {\r
+               return false;\r
+       }\r
        this->nErrorCode = TPI_ERROR_SUCCESS;\r
        GetAPIAddress("CloseArchive", p);\r
        this->nErrorCode = ((int (__stdcall *)(void *)) p)(this->archive);\r
+       this->archive = NULL;\r
        return this->nErrorCode == TPI_ERROR_SUCCESS;\r
 }\r
 \r
@@ -235,10 +244,10 @@ bool TPIHandle::GetArchiveInformation(TPI_ARCHIVEINFO * _aiInfo)
        return this->nErrorCode == TPI_ERROR_SUCCESS;\r
 }\r
 \r
-bool TPIHandle::Command(wxULongLong_t _eCommand, TPI_SWITCHES * _swInfo, const wxString & _szArcName, const wxArrayString & _szFiles)\r
+bool TPIHandle::Command(wxULongLong_t _eCommand, TPI_SWITCHES * _swInfo, const wxArrayString & _szFiles)\r
 {\r
        this->nErrorCode = TPI_ERROR_SUCCESS;\r
        GetAPIAddress("Command", p);\r
-       this->nErrorCode = ((int (__stdcall *)(wxULongLong_t, TPI_SWITCHES *, const wxString &, const wxArrayString &)) p)(_eCommand, _swInfo, _szArcName, _szFiles);\r
+       this->nErrorCode = ((int (__stdcall *)(wxULongLong_t, TPI_SWITCHES *, void *, const wxArrayString &)) p)(_eCommand, _swInfo, this->archive, _szFiles);\r
        return this->nErrorCode == TPI_ERROR_SUCCESS;\r
 }\r
index 5ecda73..23b6186 100644 (file)
@@ -45,9 +45,10 @@ class TPIHandle
                bool GetFileInformation(TPI_FILEINFO * _fiInfo, bool _bFirst = false);\r
                bool GetArchiveInformation(TPI_ARCHIVEINFO * _aiInfo);\r
 \r
-               bool Command(wxULongLong_t _eCommand, TPI_SWITCHES * _swInfo, const wxString & _szArcName, const wxArrayString & _szFiles);\r
+               bool Command(wxULongLong_t _eCommand, TPI_SWITCHES * _swInfo, const wxArrayString & _szFiles);\r
 \r
                int nErrorCode;\r
+               int bHandleOnCommand;\r
 \r
        private:\r
                wxDynamicLibrary lib;\r
index 54a7795..8f51119 100644 (file)
 #define TPI_INFO_VERSION_MAJOR      0x0001  /**< プラグインのメジャーバージョン */\r
 #define TPI_INFO_VERSION_MINOR      0x0002  /**< プラグインのマイナーバージョン */\r
 #define TPI_INFO_VERSION_API        0x0003  /**< プラグインが対応するAPIのバージョン */\r
+#define TPI_INFO_HANDLE_ON_COMMAND  0x1001  /**< Command()でハンドルを用いるなら1 */\r
 /** @} c_info */\r
 \r
 /**\r
@@ -345,6 +346,7 @@ typedef struct _TPI_tagSWITCHES
        wxString        szPassword;             /**< パスワード */\r
        wxString        szKeyFile;              /**< キーファイル */\r
        wxString        szComment;              /**< コメント */\r
+       wxString        szArcName;              /**< 書庫名(必須) */\r
        void *          pCustomSwitches;        /**< 任意の情報を格納 */\r
 }      TPI_SWITCHES;\r
 \r
@@ -491,7 +493,7 @@ int __stdcall GetArchiveInformation
 /** 各種の書庫操作を行う。\r
  * @param  _eCommand    書庫操作の種類を表すコマンドコード。\r
  * @param  _swInfo      書庫操作に必要な情報を格納した構造体へのポインタ。\r
- * @param  _szArcName   操作する対象となる書庫名\r
+ * @param  _hArchive    操作する対象となる書庫ハンドル。書庫を作成するときはNULL\r
  * @param  _szFiles     対象ファイル名のリスト。\r
  * @return エラーコード。\r
  * @sa c_command\r
@@ -500,7 +502,7 @@ int __stdcall Command
 (\r
        wxULongLong_t _eCommand,\r
        TPI_SWITCHES * _swInfo,\r
-       const wxString & _szArcName,\r
+       void * _hArchive,\r
        const wxArrayString & _szFiles\r
 );\r
 \r
index b94d62e..9df1164 100644 (file)
@@ -64,7 +64,7 @@ wxString ProcessBool(bool b, const wxString & szCommandLine, size_t * nPos, cons
        return szCommandLineSend;\r
 }\r
 \r
-wxString MakeCommandLineSend(const wxString & szCommandLine, const wxString & szArcName, TPI_SWITCHES * swInfo, const wxArrayString & asFiles, const wxString & szResponceFileName)\r
+wxString MakeCommandLineSend(const wxString & szCommandLine, TPI_SWITCHES * swInfo, const wxArrayString & asFiles, const wxString & szResponceFileName)\r
 {\r
        // コマンドライン変数を差し替え。\r
        wxString szCommandLineSend;\r
@@ -89,7 +89,7 @@ wxString MakeCommandLineSend(const wxString & szCommandLine, const wxString & sz
                                // 4: 圧縮レベル\r
                                // 5: リカバリーレコード\r
                                // 6: コメント\r
-                               case wxT('0'): szCommandLineSend += szArcName; break;\r
+                               case wxT('0'): szCommandLineSend += swInfo->szArcName; break;\r
                                case wxT('1'): szCommandLineSend += swInfo->fnDestinationDirectory.GetPathWithSep(); break;\r
                                case wxT('2'): szCommandLineSend += szResponceFileName; break;\r
                                case wxT('3'):\r
index d5f51e9..7060a85 100644 (file)
@@ -30,7 +30,7 @@
 //    Functions\r
 //******************************************************************************\r
 \r
-wxString MakeCommandLineSend(const wxString & szCommandLine, const wxString & szArcName, TPI_SWITCHES * swInfo = NULL, const wxArrayString & asFiles = wxArrayString(), const wxString & szResponceFileName = wxEmptyString);\r
+wxString MakeCommandLineSend(const wxString & szCommandLine, TPI_SWITCHES * swInfo = NULL, const wxArrayString & asFiles = wxArrayString(), const wxString & szResponceFileName = wxEmptyString);\r
 wxString MakeResponceFile(const wxArrayString & asFiles, bool bQuote, bool bUnicode = false);\r
 wxString MB2String(const char * sz);\r
 wxString UTF82String(const char * sz);\r
index 0669579..5e42e01 100644 (file)
@@ -154,7 +154,7 @@ public:
        STDMETHOD(SetSubArchiveName)(const wchar_t * szName);\r
        STDMETHOD(CryptoGetTextPassword)(BSTR *password);\r
        int nErrorCode;\r
-       wxString szSubArchiveName, szPassword;\r
+       wxString szSubArchiveName;\r
        NWindows::NFile::NFind::CFileInfo fiInfo;\r
 \r
 private:\r
@@ -234,7 +234,6 @@ STDMETHODIMP CArchiveOpenCallback::CryptoGetTextPassword(BSTR * sz)
        this->piInfo.eMessage           = TPI_MESSAGE_ASK;\r
        this->piInfo.eStatus            = TPI_PARAM_PASSWORD;\r
        return\r
-               (! this->szPassword.IsEmpty()) ? ::StringToBstr(this->szPassword.c_str(), sz) :\r
                (g_prProc != NULL && g_prProc(TPI_NOTIFY_COMMON, & this->piInfo) == TPI_CALLBACK_CONTINUE) ? ::StringToBstr(this->piInfo.szParam.c_str(), sz) :\r
                E_ABORT;\r
 }\r
@@ -610,78 +609,6 @@ STDMETHODIMP CArchiveUpdateCallback::CryptoGetTextPassword2(int * nPasswordIsDef
 }\r
 \r
 //******************************************************************************\r
-//    Inside Functions\r
-//******************************************************************************\r
-\r
-int OpenArchive2(const wxString & _szArcName, void * * _hArchive, wxULongLong_t * _nFileCount, const wxString _szPassword = wxEmptyString)\r
-{\r
-       // ***.tar.xxxは不便なので弾く。\r
-       wxString s = _szArcName.BeforeLast(wxT('.'));\r
-       if (s.Find(wxT('.')) != wxNOT_FOUND && s.AfterLast(wxT('.')) == wxT("tar"))\r
-       {\r
-               return TPI_ERROR_IO_ARC_OPEN;\r
-       }\r
-\r
-       // xml解析開始。\r
-       IInArchive * hArc;\r
-       wxXmlDocument xmlDoc(myMakeXMLName(wxT("7zArc")));\r
-       wxXmlNode * xmlLibrary = myGetFirstLib(& xmlDoc);\r
-\r
-       // 対応するライブラリを調査。\r
-       // 無限ループに陥らないよう上限を設定。\r
-       for (g_LibInfo.nLibIndex = 0; g_LibInfo.nLibIndex < 300 && xmlLibrary != NULL; g_LibInfo.nLibIndex++)\r
-       {\r
-               // ライブラリをロード。\r
-               const GUID guid = {0x23170F69, 0x40C1, 0x278A, {0x10, 0x00, 0x00, 0x01, 0x10, myGetAttributeInt(xmlLibrary, wxT("name"), 0, 16), 0x00, 0x00}};\r
-               if (((unsigned int (__stdcall *)(const GUID *, const GUID *, void * *)) g_LibInfo.fpProc)(& guid, & IID_IInArchive, (void **) & hArc) != S_OK)\r
-               {\r
-                       xmlLibrary = myGetNextLib(xmlLibrary);\r
-                       continue;\r
-               }\r
-               g_LibInfo.node = * xmlLibrary;\r
-\r
-               // 書庫を開く。\r
-               CInFileStream * fileSpec = new CInFileStream;\r
-               CMyComPtr<IInStream> file = fileSpec;\r
-               if (! fileSpec->Open(_szArcName.c_str()))\r
-               {\r
-                       return TPI_ERROR_IO_ARC_OPEN;\r
-               }\r
-\r
-               // 形式の情報を取得。\r
-               TPI_FORMATINFO fiInfo;\r
-               MakeFormatInfo(xmlLibrary, wxT("7zArc"), & fiInfo, g_LibInfo.nLibIndex);\r
-\r
-               // 書庫に対応しているかチェック。\r
-               CArchiveOpenCallback * openCallbackSpec = new CArchiveOpenCallback;\r
-               openCallbackSpec->szPassword = _szPassword;\r
-               CMyComPtr<IArchiveOpenCallback> openCallback(openCallbackSpec);\r
-               // SFXを完全に検出するには全体をロードする必要がある。\r
-               wxULongLong_t nMax = fiInfo.fSFX ? 262114 : 1024;\r
-/*\r
-               if (fiInfo.fSFX)\r
-               {\r
-                       fileSpec->GetSize(& nMax);\r
-               }\r
-*/\r
-               if (hArc->Open(file, & nMax, openCallback) == S_OK)\r
-               {\r
-                       if (_nFileCount != NULL)\r
-                       {\r
-                               unsigned int n;\r
-                               hArc->GetNumberOfItems(& n);\r
-                               * _nFileCount = n;\r
-                       }\r
-                       * _hArchive = hArc;\r
-                       return TPI_ERROR_SUCCESS;\r
-               }\r
-               xmlLibrary = myGetNextLib(xmlLibrary);\r
-       }\r
-\r
-       return TPI_ERROR_IO_ARC_OPEN;\r
-}\r
-\r
-//******************************************************************************\r
 //    Functions\r
 //******************************************************************************\r
 \r
@@ -710,6 +637,9 @@ int __stdcall GetPluginInformation
        case TPI_INFO_VERSION_API:\r
                * (int *) _pPtr = 2;\r
                break;\r
+       case TPI_INFO_HANDLE_ON_COMMAND:\r
+               * (int *) _pPtr = 1;\r
+               break;\r
        default:\r
                return TPI_ERROR_D_UNSUPPORTED;\r
        }\r
@@ -807,7 +737,69 @@ int __stdcall OpenArchive
        wxULongLong_t * _nFileCount\r
 )\r
 {\r
-       return OpenArchive2(_szArcName, _hArchive, _nFileCount);\r
+       // ***.tar.xxxは不便なので弾く。\r
+       wxString s = _szArcName.BeforeLast(wxT('.'));\r
+       if (s.Find(wxT('.')) != wxNOT_FOUND && s.AfterLast(wxT('.')) == wxT("tar"))\r
+       {\r
+               return TPI_ERROR_IO_ARC_OPEN;\r
+       }\r
+\r
+       // xml解析開始。\r
+       IInArchive * hArc;\r
+       wxXmlDocument xmlDoc(myMakeXMLName(wxT("7zArc")));\r
+       wxXmlNode * xmlLibrary = myGetFirstLib(& xmlDoc);\r
+\r
+       // 対応するライブラリを調査。\r
+       // 無限ループに陥らないよう上限を設定。\r
+       for (g_LibInfo.nLibIndex = 0; g_LibInfo.nLibIndex < 300 && xmlLibrary != NULL; g_LibInfo.nLibIndex++)\r
+       {\r
+               // ライブラリをロード。\r
+               const GUID guid = {0x23170F69, 0x40C1, 0x278A, {0x10, 0x00, 0x00, 0x01, 0x10, myGetAttributeInt(xmlLibrary, wxT("name"), 0, 16), 0x00, 0x00}};\r
+               if (((unsigned int (__stdcall *)(const GUID *, const GUID *, void * *)) g_LibInfo.fpProc)(& guid, & IID_IInArchive, (void **) & hArc) != S_OK)\r
+               {\r
+                       xmlLibrary = myGetNextLib(xmlLibrary);\r
+                       continue;\r
+               }\r
+               g_LibInfo.node = * xmlLibrary;\r
+\r
+               // 書庫を開く。\r
+               CInFileStream * fileSpec = new CInFileStream;\r
+               CMyComPtr<IInStream> file = fileSpec;\r
+               if (! fileSpec->Open(_szArcName.c_str()))\r
+               {\r
+                       return TPI_ERROR_IO_ARC_OPEN;\r
+               }\r
+\r
+               // 形式の情報を取得。\r
+               TPI_FORMATINFO fiInfo;\r
+               MakeFormatInfo(xmlLibrary, wxT("7zArc"), & fiInfo, g_LibInfo.nLibIndex);\r
+\r
+               // 書庫に対応しているかチェック。\r
+               CArchiveOpenCallback * openCallbackSpec = new CArchiveOpenCallback;\r
+               CMyComPtr<IArchiveOpenCallback> openCallback(openCallbackSpec);\r
+               // SFXを完全に検出するには全体をロードする必要がある。\r
+               wxULongLong_t nMax = fiInfo.fSFX ? 262114 : 1024;\r
+/*\r
+               if (fiInfo.fSFX)\r
+               {\r
+                       fileSpec->GetSize(& nMax);\r
+               }\r
+*/\r
+               if (hArc->Open(file, & nMax, openCallback) == S_OK)\r
+               {\r
+                       if (_nFileCount != NULL)\r
+                       {\r
+                               unsigned int n;\r
+                               hArc->GetNumberOfItems(& n);\r
+                               * _nFileCount = n;\r
+                       }\r
+                       * _hArchive = hArc;\r
+                       return TPI_ERROR_SUCCESS;\r
+               }\r
+               xmlLibrary = myGetNextLib(xmlLibrary);\r
+       }\r
+\r
+       return TPI_ERROR_IO_ARC_OPEN;\r
 }\r
 \r
 int __stdcall CloseArchive\r
@@ -815,7 +807,7 @@ int __stdcall CloseArchive
        void * _hArchive\r
 )\r
 {\r
-    IInArchive * hArc = (IInArchive *) _hArchive;\r
+       IInArchive * hArc = (IInArchive *) _hArchive;\r
        hArc->Close();\r
        hArc->Release();\r
        return TPI_ERROR_SUCCESS;\r
@@ -888,7 +880,7 @@ int __stdcall Command
 (\r
        wxULongLong_t _eCommand,\r
        TPI_SWITCHES * _swInfo,\r
-       const wxString & _szArcName,\r
+       void * _hArchive,\r
        const wxArrayString & _szFiles\r
 )\r
 {\r
@@ -899,19 +891,11 @@ int __stdcall Command
        case TPI_COMMAND_EXTRACT:\r
        case TPI_COMMAND_TEST:\r
        {\r
-               // 開きなおす。\r
-               IInArchive * hArc;\r
-               nErrorCode = OpenArchive2(_szArcName, (void **) & hArc, NULL, _swInfo->szPassword);\r
-               if (nErrorCode != TPI_ERROR_SUCCESS)\r
-               {\r
-                       return nErrorCode;\r
-               }\r
-\r
                // ファイル名からインデックスを取得。\r
                TPI_FILEINFO fiInfo;\r
                CRecordVector<unsigned int> nIndexes;\r
-               wxFileName fnArchive = wxFileName(_szArcName);\r
-               if (GetFileInformation(hArc, & fiInfo, true) == TPI_ERROR_SUCCESS)\r
+               wxFileName fnArchive = wxFileName(_swInfo->szArcName);\r
+               if (GetFileInformation(_hArchive, & fiInfo, true) == TPI_ERROR_SUCCESS)\r
                {\r
                        do\r
                        {\r
@@ -928,15 +912,14 @@ int __stdcall Command
                                        nIndexes.Add(fiInfo.nFileId);\r
                                }\r
                        }\r
-                       while (GetFileInformation(hArc, & fiInfo) == TPI_ERROR_SUCCESS);\r
+                       while (GetFileInformation(_hArchive, & fiInfo) == TPI_ERROR_SUCCESS);\r
                }\r
 \r
-               CArchiveExtractCallback * extractCallbackSpec = new CArchiveExtractCallback(hArc,_swInfo);\r
+               CArchiveExtractCallback * extractCallbackSpec = new CArchiveExtractCallback((IInArchive *) _hArchive, _swInfo);\r
                extractCallbackSpec->fnArchive = fnArchive;\r
                CMyComPtr<IArchiveExtractCallback> extractCallback(extractCallbackSpec);\r
-               hArc->Extract(& nIndexes.Front(), nIndexes.Size(), _eCommand == TPI_COMMAND_TEST, extractCallback);\r
+               ((IInArchive *) _hArchive)->Extract(& nIndexes.Front(), nIndexes.Size(), _eCommand == TPI_COMMAND_TEST, extractCallback);\r
                nErrorCode = extractCallbackSpec->nErrorCode;\r
-               CloseArchive(hArc);\r
                break;\r
        }\r
        case TPI_COMMAND_CREATE:\r
@@ -959,7 +942,7 @@ int __stdcall Command
                // 書庫を作成。\r
                COutFileStream * outFileStreamSpec = new COutFileStream;\r
                CMyComPtr<IOutStream> outFileStream = outFileStreamSpec;\r
-               if (! outFileStreamSpec->Create(_szArcName.c_str(), false))\r
+               if (! outFileStreamSpec->Create(_swInfo->szArcName.c_str(), false))\r
                {\r
                        return TPI_ERROR_IO_ARC_OPEN;\r
                }\r
index 673698b..1d5f68c 100644 (file)
@@ -555,6 +555,9 @@ int __stdcall GetPluginInformation
        case TPI_INFO_VERSION_API:\r
                * (int *) _pPtr = 2;\r
                break;\r
+       case TPI_INFO_HANDLE_ON_COMMAND:\r
+               * (int *) _pPtr = 0;\r
+               break;\r
        default:\r
                return TPI_ERROR_D_UNSUPPORTED;\r
        }\r
@@ -905,7 +908,7 @@ int __stdcall Command
 (\r
        wxULongLong_t _eCommand,\r
        TPI_SWITCHES * _swInfo,\r
-       const wxString & _szArcName,\r
+       void *,// _hArchive,\r
        const wxArrayString & _szFiles\r
 )\r
 {\r
@@ -951,7 +954,7 @@ int __stdcall Command
                szResponceFileName = g_LibInfo.fRunning ?\r
                        MakeResponceFile(_szFiles, myGetAttributeBool(& g_LibInfo.node,    wxT("quote-resp"), true), g_LibInfo.fUnicode) :\r
                        MakeResponceFile(_szFiles, myGetAttributeBool(& g_LibInfoAlt.node, wxT("quote-resp"), true), g_LibInfoAlt.fUnicode),\r
-               szCommandLineSend  = MakeCommandLineSend(szCommandLine, _szArcName, _swInfo, _szFiles, szResponceFileName);\r
+               szCommandLineSend  = MakeCommandLineSend(szCommandLine, _swInfo, _szFiles, szResponceFileName);\r
 \r
        // コマンドライン実行。\r
        int nErrorCode;\r
index 7d1afd2..2ab763d 100644 (file)
@@ -182,6 +182,9 @@ int __stdcall GetPluginInformation
        case TPI_INFO_VERSION_API:\r
                * (int *) _pPtr = 2;\r
                break;\r
+       case TPI_INFO_HANDLE_ON_COMMAND:\r
+               * (int *) _pPtr = 0;\r
+               break;\r
        default:\r
                return TPI_ERROR_D_UNSUPPORTED;\r
        }\r
@@ -297,7 +300,9 @@ int __stdcall OpenArchive
 )\r
 {\r
        wxString szOutput;\r
-       if (myExecute(g_LibInfo.szExeFile + wxT(" ") + MakeCommandLineSend(g_LibInfo.node.GetAttribute(wxT("list"), wxEmptyString), _szArcName), & szOutput, wxEmptyString, g_LibInfo.szExeFile.MakeLower().EndsWith(wxT(".exe"))) != TPI_ERROR_SUCCESS)\r
+       TPI_SWITCHES swInfo;\r
+       swInfo.szArcName = _szArcName;\r
+       if (myExecute(g_LibInfo.szExeFile + wxT(" ") + MakeCommandLineSend(g_LibInfo.node.GetAttribute(wxT("list"), wxEmptyString), & swInfo), & szOutput, wxEmptyString, g_LibInfo.szExeFile.MakeLower().EndsWith(wxT(".exe"))) != TPI_ERROR_SUCCESS)\r
        {\r
                return TPI_ERROR_U_USE_LIBRARY;\r
        }\r
@@ -419,7 +424,7 @@ int __stdcall Command
 (\r
        wxULongLong_t _eCommand,\r
        TPI_SWITCHES * _swInfo,\r
-       const wxString & _szArcName,\r
+       void *,// _hArchive,\r
        const wxArrayString & _szFiles\r
 )\r
 {\r
@@ -460,7 +465,7 @@ int __stdcall Command
        // コマンドライン・レスポンスファイル作成。\r
        wxString\r
                szResponceFileName = MakeResponceFile(_szFiles, myGetAttributeBool(& g_LibInfo.node, wxT("quote-resp"), true)),\r
-               szCommandLineSend  = MakeCommandLineSend(szCommandLine, _szArcName, _swInfo, _szFiles, szResponceFileName);\r
+               szCommandLineSend  = MakeCommandLineSend(szCommandLine, _swInfo, _szFiles, szResponceFileName);\r
 \r
        // コマンドライン実行。\r
        wxString szOutput;\r
index 3830937..b4bbaf0 100644 (file)
@@ -233,6 +233,9 @@ int __stdcall GetPluginInformation
        case TPI_INFO_VERSION_API:\r
                * (int *) _pPtr = 2;\r
                break;\r
+       case TPI_INFO_HANDLE_ON_COMMAND:\r
+               * (int *) _pPtr = 1;\r
+               break;\r
        default:\r
                return TPI_ERROR_D_UNSUPPORTED;\r
        }\r
@@ -421,7 +424,7 @@ int __stdcall Command
 (\r
        wxULongLong_t _eCommand,\r
        TPI_SWITCHES * _swInfo,\r
-       const wxString & _szArcName,\r
+       void * _hArchive,\r
        const wxArrayString & _szFiles\r
 )\r
 {\r
@@ -430,32 +433,12 @@ int __stdcall Command
                return TPI_ERROR_U_USE_LIBRARY;\r
        }\r
 \r
-       // 開きなおす。\r
-       void * hArc;\r
-       int nErrorCode = OpenArchive(_szArcName, & hArc);\r
-       if (nErrorCode != TPI_ERROR_SUCCESS)\r
-       {\r
-               return nErrorCode;\r
-       }\r
-\r
        // グローバル変数にポインタを保存。\r
        g_swInfo = _swInfo;\r
        g_asFiles = & _szFiles;\r
 \r
        FARPROC fpProc = _eCommand == TPI_COMMAND_EXTRACT ? ::GetAPIAddress("Extract") : ::GetAPIAddress("Test");\r
-       if (fpProc == NULL)\r
-       {\r
-               CloseArchive(hArc);\r
-               return TPI_ERROR_U_USE_LIBRARY;\r
-       }\r
-       nErrorCode = ErrorCodeConvert(((UINT (__cdecl *)(void *)) fpProc)(hArc));\r
-       if (nErrorCode != TPI_ERROR_SUCCESS)\r
-       {\r
-               CloseArchive(hArc);\r
-               return nErrorCode;\r
-       }\r
-\r
-       return CloseArchive(hArc);\r
+       return fpProc == NULL ? TPI_ERROR_U_USE_LIBRARY : ErrorCodeConvert(((UINT (__cdecl *)(void *)) fpProc)(_hArchive));\r
 }\r
 \r
 #ifdef __cplusplus\r
index 74421f0..937d99a 100644 (file)
@@ -38,7 +38,6 @@ wxDynamicLibrary g_hLib;
 TPI_PROC g_prProc;\r
 char g_szComment[64001];\r
 RAROpenArchiveDataEx g_oaInfo;\r
-RARHeaderDataEx * g_hdInfo;\r
 \r
 //******************************************************************************\r
 //    Callback Wrapper\r
@@ -156,6 +155,9 @@ int __stdcall GetPluginInformation
        case TPI_INFO_VERSION_API:\r
                * (int *) _pPtr = 2;\r
                break;\r
+       case TPI_INFO_HANDLE_ON_COMMAND:\r
+               * (int *) _pPtr = 0;\r
+               break;\r
        default:\r
                return TPI_ERROR_D_UNSUPPORTED;\r
        }\r
@@ -341,7 +343,7 @@ int __stdcall Command
 (\r
        wxULongLong_t _eCommand,\r
        TPI_SWITCHES * _swInfo,\r
-       const wxString & _szArcName,\r
+       void *,// _hArchive,\r
        const wxArrayString & _szFiles\r
 )\r
 {\r
@@ -364,7 +366,7 @@ int __stdcall Command
        TPI_PROCESSINFO piInfo;\r
        piInfo.eMessage = TPI_MESSAGE_STATUS;\r
        piInfo.eStatus  = TPI_STATUS_OPENARCHIVE;\r
-       piInfo.fiInfo.fnFileName = wxFileName(_szArcName);\r
+       piInfo.fiInfo.fnFileName = wxFileName(_swInfo->szArcName);\r
        if (g_prProc != NULL && g_prProc(TPI_NOTIFY_COMMON, & piInfo) != TPI_CALLBACK_CONTINUE)\r
        {\r
                return TPI_ERROR_D_SKIPPED;\r
@@ -372,9 +374,9 @@ int __stdcall Command
        RAROpenArchiveDataEx oaInfo;\r
        memset(& oaInfo, 0, sizeof(oaInfo));\r
        oaInfo.ArcName    = NULL;\r
-//     oaInfo.ArcNameW   = _szArcName.wchar_str();\r
-       oaInfo.ArcNameW   = (wchar_t *) malloc((_szArcName.Len() + 1) * sizeof(wchar_t));\r
-       wcscpy(oaInfo.ArcNameW, _szArcName.wchar_str());\r
+//     oaInfo.ArcNameW   = _swInfo->szArcName.wchar_str();\r
+       oaInfo.ArcNameW   = (wchar_t *) malloc((_swInfo->szArcName.Len() + 1) * sizeof(wchar_t));\r
+       wcscpy(oaInfo.ArcNameW, _swInfo->szArcName.wchar_str());\r
        oaInfo.OpenMode   = RAR_OM_EXTRACT;\r
        oaInfo.CmtBufSize = 0;\r
        oaInfo.Callback   = CallbackProc;\r
@@ -406,7 +408,6 @@ int __stdcall Command
        }\r
 \r
        RARHeaderDataEx hdInfo;\r
-       g_hdInfo = & hdInfo;\r
        while (nErrorCode == TPI_ERROR_SUCCESS && ErrorCodeConvert(((int (__stdcall *)(void *, RARHeaderDataEx *)) pR)(hArc, & hdInfo)) == TPI_ERROR_SUCCESS)\r
        {\r
                piInfo.fiInfo.fnFileName     = wxFileName(WC2String(hdInfo.FileNameW));\r
index 0bc6f5a..e1c245f 100644 (file)
@@ -102,6 +102,9 @@ int __stdcall GetPluginInformation
        case TPI_INFO_VERSION_API:\r
                * (int *) _pPtr = 2;\r
                break;\r
+       case TPI_INFO_HANDLE_ON_COMMAND:\r
+               * (int *) _pPtr = 1;\r
+               break;\r
        default:\r
                return TPI_ERROR_D_PARAMETER;\r
        }\r
@@ -305,7 +308,7 @@ int __stdcall Command
 (\r
        wxULongLong_t _eCommand,\r
        TPI_SWITCHES * _swInfo,\r
-       const wxString & _szArcName,\r
+       void * _hArchive,\r
        const wxArrayString & _szFiles\r
 )\r
 {\r
@@ -321,16 +324,8 @@ int __stdcall Command
                return TPI_ERROR_U_USE_LIBRARY;\r
        }\r
 \r
-       // 書庫ハンドルを取得。\r
-       void * hArchive;\r
-       int nErrorCode = OpenArchive(_szArcName, & hArchive);\r
-       if (nErrorCode != TPI_ERROR_SUCCESS)\r
-       {\r
-               return nErrorCode;\r
-       }\r
-\r
        // コールバックを送信。\r
-       wxFileName _fnArcName(_szArcName);\r
+       wxFileName _fnArcName(_swInfo->szArcName);\r
        TPI_PROCESSINFO piInfo;\r
        piInfo.eMessage = TPI_MESSAGE_STATUS;\r
        piInfo.eStatus  = TPI_STATUS_OPENARCHIVE;\r
@@ -342,7 +337,7 @@ int __stdcall Command
 \r
        // 処理実行。\r
        piInfo.eStatus = TPI_STATUS_INPROCESS;\r
-       nErrorCode = GetFileInformation(hArchive, & piInfo.fiInfo, true);\r
+       int nErrorCode = GetFileInformation(_hArchive, & piInfo.fiInfo, true);\r
        if (nErrorCode == TPI_ERROR_SUCCESS)\r
        {\r
                do\r
@@ -386,7 +381,7 @@ int __stdcall Command
 \r
                        // ファイル出力には対応してないのでメモリ出力で代行。\r
                        HLOCAL hMemory = NULL;\r
-                       nErrorCode = ErrorCodeConvert(((int (PASCAL *)(const char *, long, char *, unsigned int, FARPROC, long)) fpProc)(_szArcName.ToUTF8(), (long) piInfo.fiInfo.pCustomInfo, (char *) & hMemory, 0x0100, (FARPROC) CallbackProc, (long) & piInfo));\r
+                       nErrorCode = ErrorCodeConvert(((int (PASCAL *)(const char *, long, char *, unsigned int, FARPROC, long)) fpProc)(_swInfo->szArcName.ToUTF8(), (long) piInfo.fiInfo.pCustomInfo, (char *) & hMemory, 0x0100, (FARPROC) CallbackProc, (long) & piInfo));\r
                        if (nErrorCode == TPI_ERROR_SUCCESS && hMemory == NULL)\r
                        {\r
                                nErrorCode = TPI_ERROR_UNDEFINED;\r
@@ -423,14 +418,13 @@ int __stdcall Command
                                break;\r
                        }\r
                }\r
-               while ((nErrorCode = GetFileInformation(hArchive, & piInfo.fiInfo, false)) != TPI_ERROR_S_ENDOFDATA);\r
+               while ((nErrorCode = GetFileInformation(_hArchive, & piInfo.fiInfo, false)) != TPI_ERROR_S_ENDOFDATA);\r
                if (nErrorCode == TPI_ERROR_S_ENDOFDATA)\r
                {\r
                        // 終端に達した場合。\r
                        nErrorCode = TPI_ERROR_SUCCESS;\r
                }\r
        }\r
-       CloseArchive(hArchive);\r
 \r
        return nErrorCode;\r
 }\r
index 8d5846f..aeefab9 100644 (file)
@@ -107,6 +107,9 @@ int __stdcall GetPluginInformation
        case TPI_INFO_VERSION_API:\r
                * (int *) _pPtr = 2;\r
                break;\r
+       case TPI_INFO_HANDLE_ON_COMMAND:\r
+               * (int *) _pPtr = 0;\r
+               break;\r
        default:\r
                return TPI_ERROR_D_PARAMETER;\r
        }\r
@@ -352,7 +355,7 @@ int __stdcall Command
 (\r
        wxULongLong_t _eCommand,\r
        TPI_SWITCHES * _swInfo,\r
-       const wxString & _szArcName,\r
+       void *,// _hArchive,\r
        const wxArrayString & _asFiles\r
 )\r
 {\r
@@ -368,14 +371,14 @@ int __stdcall Command
                return TPI_ERROR_U_USE_LIBRARY;\r
        }\r
        PictureInfo picInfo;\r
-       int nErrorCode = ErrorCodeConvert(((int (PASCAL *)(const char *, long, unsigned int, PictureInfo *)) fpProc)(_szArcName.ToUTF8(), 0, 0, & picInfo));\r
+       int nErrorCode = ErrorCodeConvert(((int (PASCAL *)(const char *, long, unsigned int, PictureInfo *)) fpProc)(_swInfo->szArcName.ToUTF8(), 0, 0, & picInfo));\r
        if (nErrorCode != TPI_ERROR_SUCCESS)\r
        {\r
                return nErrorCode;\r
        }\r
 \r
        // コールバックを送信。\r
-       wxFileName _fnArcName(_szArcName);\r
+       wxFileName _fnArcName(_swInfo->szArcName);\r
        TPI_PROCESSINFO piInfo;\r
        piInfo.eMessage = TPI_MESSAGE_STATUS;\r
        piInfo.eStatus  = TPI_STATUS_OPENARCHIVE;\r
@@ -392,7 +395,7 @@ int __stdcall Command
        {\r
                return TPI_ERROR_U_USE_LIBRARY;\r
        }\r
-       nErrorCode = ErrorCodeConvert(((int (PASCAL *)(const char *, long, unsigned int, HANDLE *, HANDLE *, FARPROC, long)) fpProc)(_szArcName.ToUTF8(), 0, 0, & hInfo, & hMemory, (FARPROC) CallbackProc, (long) & piInfo));\r
+       nErrorCode = ErrorCodeConvert(((int (PASCAL *)(const char *, long, unsigned int, HANDLE *, HANDLE *, FARPROC, long)) fpProc)(_swInfo->szArcName.ToUTF8(), 0, 0, & hInfo, & hMemory, (FARPROC) CallbackProc, (long) & piInfo));\r
        if (nErrorCode == TPI_ERROR_SUCCESS && (hMemory == NULL || hInfo == NULL))\r
        {\r
                return TPI_ERROR_UNDEFINED;\r