OSDN Git Service

上書きスキップができなくなっていたのを修正。
[tpi/lychee.git] / src / plugin / 7zArc / 7zArc.cpp
index ec9a2cb..78f37b1 100644 (file)
@@ -388,7 +388,7 @@ STDMETHODIMP CArchiveExtractCallback::SetCompleted(const wxULongLong_t * nProces
 {\r
        this->piInfo.eStatus                = TPI_STATUS_INPROCESS;\r
        this->piInfo.nProcessedSize     = * nProcessed - this->nCurrentPos;\r
-       if (g_prProc == NULL || this->piInfo.fiInfo.szStoredName.IsEmpty() || g_prProc(TPI_NOTIFY_COMMON, & this->piInfo) == TPI_CALLBACK_CONTINUE)\r
+       if (g_prProc == NULL || this->piInfo.fiInfo.szStoredName.IsEmpty() || ! this->piInfo.fnDestination.IsOk() || g_prProc(TPI_NOTIFY_COMMON, & this->piInfo) == TPI_CALLBACK_CONTINUE)\r
        {\r
                return S_OK;\r
        }\r
@@ -406,10 +406,10 @@ STDMETHODIMP CArchiveExtractCallback::GetStream(unsigned int nIndex, ISequential
 \r
        // 前のファイルの処理の終了を通知。\r
        this->nCurrentPos += this->piInfo.fiInfo.nUnpackedSize;\r
-       this->piInfo.eMessage               = TPI_MESSAGE_STATUS;\r
        if (this->nCurrentPos != 0)\r
        {\r
-               this->piInfo.eStatus            = TPI_STATUS_ENDPROCESS;\r
+               this->piInfo.eMessage   = TPI_MESSAGE_STATUS;\r
+               this->piInfo.eStatus    = TPI_STATUS_ENDPROCESS;\r
                if (g_prProc != NULL && g_prProc(TPI_NOTIFY_COMMON, & this->piInfo) != TPI_CALLBACK_CONTINUE)\r
                {\r
                        this->nErrorCode = TPI_ERROR_D_SKIPPED;\r
@@ -417,8 +417,9 @@ STDMETHODIMP CArchiveExtractCallback::GetStream(unsigned int nIndex, ISequential
                }\r
        }\r
 \r
-       // ファイルの基本情報を取得。\r
-       this->piInfo.eStatus                = TPI_STATUS_BEGINPROCESS;\r
+       // ファイルを処理するか確認。\r
+       this->piInfo.eMessage   = TPI_MESSAGE_ASK;\r
+       this->piInfo.eStatus    = TPI_PARAM_DEST;\r
        GetFileInformation2(this->hArc, & this->piInfo.fiInfo, nIndex);\r
        this->piInfo.fnDestination          = wxFileName(swInfo->fnDestinationDirectory.GetFullPath() + wxFileName::GetPathSeparator() + (swInfo->fStoreDirectoryPathes ? this->piInfo.fiInfo.fnFileName.GetPath() : (wxString) wxEmptyString), this->piInfo.fiInfo.fnFileName.GetFullName());\r
        if (g_prProc != NULL && g_prProc(TPI_NOTIFY_COMMON, & this->piInfo) != TPI_CALLBACK_CONTINUE)\r
@@ -426,6 +427,19 @@ STDMETHODIMP CArchiveExtractCallback::GetStream(unsigned int nIndex, ISequential
                this->nErrorCode = TPI_ERROR_D_SKIPPED;\r
                return E_ABORT;\r
        }\r
+       if (! piInfo.fnDestination.IsOk())\r
+       {\r
+               return S_OK;\r
+       }\r
+\r
+       // ファイルの基本情報を取得。\r
+       this->piInfo.eMessage   = TPI_MESSAGE_STATUS;\r
+       this->piInfo.eStatus    = TPI_STATUS_BEGINPROCESS;\r
+       if (g_prProc != NULL && g_prProc(TPI_NOTIFY_COMMON, & this->piInfo) != TPI_CALLBACK_CONTINUE)\r
+       {\r
+               this->nErrorCode = TPI_ERROR_D_SKIPPED;\r
+               return E_ABORT;\r
+       }\r
 \r
        if (nExtractMode != NArchive::NExtract::NAskMode::kExtract)\r
        {\r
@@ -443,19 +457,10 @@ STDMETHODIMP CArchiveExtractCallback::GetStream(unsigned int nIndex, ISequential
                return S_OK;\r
        }\r
 \r
-       if (::wxFileExists(this->piInfo.fnDestination.GetFullPath()))\r
-       {\r
-               // 既にファイルが存在する場合。\r
-               if (! ::wxRemoveFile(this->piInfo.fnDestination.GetFullPath()))\r
-               {\r
-                       this->nErrorCode = TPI_ERROR_IO_FILE_DELETE;\r
-                       return E_ABORT;\r
-               }\r
-       }\r
-\r
+       // ファイルを作成。\r
        _outFileStreamSpec = new COutFileStream;\r
        CMyComPtr<ISequentialOutStream> outStreamLoc(_outFileStreamSpec);\r
-       if (! _outFileStreamSpec->Open(this->piInfo.fnDestination.GetFullPath(), CREATE_ALWAYS))\r
+       if (! _outFileStreamSpec->Open(this->piInfo.fnDestination.GetFullPath(), CREATE_NEW))\r
        {\r
                this->nErrorCode = TPI_ERROR_IO_FILE_OPEN;\r
                return E_ABORT;\r
@@ -793,19 +798,11 @@ int __stdcall FreePlugin
        return TPI_ERROR_SUCCESS;\r
 }\r
 \r
-int __stdcall CheckArchive\r
-(\r
-       const wxString &,\r
-       wxULongLong_t *\r
-)\r
-{\r
-       return TPI_ERROR_SUCCESS;\r
-}\r
-\r
 int __stdcall OpenArchive\r
 (\r
        const wxString & _szArcName,\r
-       void * * _hArchive\r
+       void * * _hArchive,\r
+       wxULongLong_t * _nFileCount\r
 )\r
 {\r
        // ***.tar.xxxは不便なので弾く。\r
@@ -848,6 +845,12 @@ int __stdcall OpenArchive
                }\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
@@ -943,7 +946,7 @@ int __stdcall Command
                                        nIndexes.Add(fiInfo.nFileId);\r
                                }\r
                        }\r
-                       while (GetFileInformation(hArc, & fiInfo, false) == TPI_ERROR_SUCCESS);\r
+                       while (GetFileInformation(hArc, & fiInfo) == TPI_ERROR_SUCCESS);\r
                }\r
 \r
                CArchiveExtractCallback * extractCallbackSpec = new CArchiveExtractCallback(hArc,_swInfo);\r