OSDN Git Service

C++11のauto, nullptrを導入。
[tpi/lychee.git] / src / plugin / 7zArc / 7zArc.cpp
index 029c5b8..79b0adf 100644 (file)
@@ -205,7 +205,7 @@ STDMETHODIMP CArchiveOpenCallback::GetStream(const wchar_t * szName, IInStream *
        {\r
                return S_FALSE;\r
        }\r
-       * inStream = NULL;\r
+       * inStream = nullptr;\r
        wxString szFileName = this->piInfo.fiInfo.fnFileName.GetPathWithSep() + szName;\r
        if (! this->fiInfo.Find(szFileName.c_str()) || fiInfo.IsDir())\r
        {\r
@@ -213,7 +213,7 @@ STDMETHODIMP CArchiveOpenCallback::GetStream(const wchar_t * szName, IInStream *
                return S_FALSE;\r
        }\r
 \r
-       CInFileStream * inFile = new CInFileStream;\r
+       auto inFile = new CInFileStream;\r
        CMyComPtr<IInStream> inStreamTemp = inFile;\r
        if (! inFile->Open(szFileName.c_str()))\r
        {\r
@@ -235,7 +235,7 @@ STDMETHODIMP CArchiveOpenCallback::CryptoGetTextPassword(BSTR * sz)
        this->piInfo.eMessage           = TPI_MESSAGE_ASK;\r
        this->piInfo.eStatus            = TPI_PARAM_PASSWORD;\r
        return\r
-               (g_prProc != NULL && g_prProc(TPI_NOTIFY_COMMON, & this->piInfo) == TPI_CALLBACK_CONTINUE) ? ::StringToBstr(this->piInfo.szParam.c_str(), sz) :\r
+               (g_prProc != nullptr && g_prProc(TPI_NOTIFY_COMMON, & this->piInfo) == TPI_CALLBACK_CONTINUE) ? ::StringToBstr(this->piInfo.szParam.c_str(), sz) :\r
                E_ABORT;\r
 }\r
 \r
@@ -279,7 +279,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() || ! this->piInfo.fnDestination.IsOk() || g_prProc(TPI_NOTIFY_COMMON, & this->piInfo) == TPI_CALLBACK_CONTINUE)\r
+       if (g_prProc == nullptr || 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
@@ -301,7 +301,7 @@ STDMETHODIMP CArchiveExtractCallback::GetStream(unsigned int nIndex, ISequential
        {\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
+               if (g_prProc != nullptr && g_prProc(TPI_NOTIFY_COMMON, & this->piInfo) != TPI_CALLBACK_CONTINUE)\r
                {\r
                        this->nErrorCode = TPI_ERROR_D_SKIPPED;\r
                        return E_ABORT;\r
@@ -323,7 +323,7 @@ STDMETHODIMP CArchiveExtractCallback::GetStream(unsigned int nIndex, ISequential
        }\r
 \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
+       if (g_prProc != nullptr && g_prProc(TPI_NOTIFY_COMMON, & this->piInfo) != TPI_CALLBACK_CONTINUE)\r
        {\r
                this->nErrorCode = TPI_ERROR_D_SKIPPED;\r
                return E_ABORT;\r
@@ -336,7 +336,7 @@ STDMETHODIMP CArchiveExtractCallback::GetStream(unsigned int nIndex, ISequential
        // ファイルの基本情報を取得。\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
+       if (g_prProc != nullptr && g_prProc(TPI_NOTIFY_COMMON, & this->piInfo) != TPI_CALLBACK_CONTINUE)\r
        {\r
                this->nErrorCode = TPI_ERROR_D_SKIPPED;\r
                return E_ABORT;\r
@@ -390,7 +390,7 @@ STDMETHODIMP CArchiveExtractCallback::SetOperationResult(int nResult)
        }\r
 \r
        // 時刻を記録。\r
-       if (_outFileStream != NULL)\r
+       if (_outFileStream != nullptr)\r
        {\r
                FILETIME ftAccess, ftCreate, ftModify;\r
                NWindows::NTime::UnixTimeToFileTime(this->piInfo.fiInfo.tmAccess.GetTicks(), ftAccess);\r
@@ -421,7 +421,7 @@ STDMETHODIMP CArchiveExtractCallback::CryptoGetTextPassword(BSTR * szPassword)
                this->piInfo.eStatus            = TPI_PARAM_PASSWORD;\r
                // 次のファイル名が取得できないので、とりあえず空にしておく。\r
                this->piInfo.fiInfo.fnFileName.Clear();\r
-               return (g_prProc != NULL && g_prProc(TPI_NOTIFY_COMMON, & this->piInfo) == TPI_CALLBACK_CONTINUE) ? ::StringToBstr(this->piInfo.szParam.c_str(), szPassword) : E_ABORT;\r
+               return (g_prProc != nullptr && g_prProc(TPI_NOTIFY_COMMON, & this->piInfo) == TPI_CALLBACK_CONTINUE) ? ::StringToBstr(this->piInfo.szParam.c_str(), szPassword) : E_ABORT;\r
        }\r
        else\r
        {\r
@@ -464,7 +464,7 @@ STDMETHODIMP CArchiveUpdateCallback::SetCompleted(const wxULongLong_t * nProcess
 {\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 == nullptr || this->piInfo.fiInfo.szStoredName.IsEmpty() || g_prProc(TPI_NOTIFY_COMMON, & this->piInfo) == TPI_CALLBACK_CONTINUE)\r
        {\r
                return S_OK;\r
        }\r
@@ -477,15 +477,15 @@ STDMETHODIMP CArchiveUpdateCallback::SetCompleted(const wxULongLong_t * nProcess
 \r
 STDMETHODIMP CArchiveUpdateCallback::GetUpdateItemInfo(unsigned int /* index */, int *newData, int *newProperties, unsigned int *indexInArchive)\r
 {\r
-       if (newData != NULL)\r
+       if (newData != nullptr)\r
        {\r
                * newData = 1;\r
        }\r
-       if (newProperties != NULL)\r
+       if (newProperties != nullptr)\r
        {\r
                * newProperties = 1;\r
        }\r
-       if (indexInArchive != NULL)\r
+       if (indexInArchive != nullptr)\r
        {\r
                * indexInArchive = (unsigned) -1;\r
        }\r
@@ -525,7 +525,7 @@ STDMETHODIMP CArchiveUpdateCallback::GetStream(unsigned int nIndex, ISequentialI
        if (this->nCurrentPos > 0)\r
        {\r
                this->piInfo.eStatus            = TPI_STATUS_ENDPROCESS;\r
-               if (g_prProc != NULL && g_prProc(TPI_NOTIFY_COMMON, & this->piInfo) != TPI_CALLBACK_CONTINUE)\r
+               if (g_prProc != nullptr && g_prProc(TPI_NOTIFY_COMMON, & this->piInfo) != TPI_CALLBACK_CONTINUE)\r
                {\r
                        this->nErrorCode = TPI_ERROR_D_SKIPPED;\r
                        return E_ABORT;\r
@@ -551,7 +551,7 @@ STDMETHODIMP CArchiveUpdateCallback::GetStream(unsigned int nIndex, ISequentialI
        this->piInfo.fnDestination          = wxFileName(this->piInfo.fiInfo.szStoredName);\r
 \r
        // コールバック関数に送信。\r
-       if (g_prProc != NULL && g_prProc(TPI_NOTIFY_COMMON, & this->piInfo) != TPI_CALLBACK_CONTINUE)\r
+       if (g_prProc != nullptr && g_prProc(TPI_NOTIFY_COMMON, & this->piInfo) != TPI_CALLBACK_CONTINUE)\r
        {\r
                this->nErrorCode = TPI_ERROR_D_SKIPPED;\r
                return E_ABORT;\r
@@ -562,7 +562,7 @@ STDMETHODIMP CArchiveUpdateCallback::GetStream(unsigned int nIndex, ISequentialI
                return S_OK;\r
        }\r
 \r
-       CInFileStream * inStreamSpec = new CInFileStream;\r
+       auto inStreamSpec = new CInFileStream;\r
        CMyComPtr<ISequentialInStream> inStreamLoc(inStreamSpec);\r
        if (! inStreamSpec->Open(this->piInfo.fiInfo.fnFileName.GetFullPath().c_str()))\r
        {\r
@@ -593,7 +593,7 @@ STDMETHODIMP CArchiveUpdateCallback::GetVolumeSize(unsigned int, wxULongLong_t *
 \r
 STDMETHODIMP CArchiveUpdateCallback::GetVolumeStream(unsigned int nIndex, ISequentialOutStream ** volumeStream)\r
 {\r
-       COutFileStream * streamSpec = new COutFileStream;\r
+       auto streamSpec = new COutFileStream;\r
        CMyComPtr<ISequentialOutStream> streamLoc(streamSpec);\r
        if (! streamSpec->Create(this->piInfo.fiInfo.fnFileName.GetFullPath() + wxString::Format(wxT(".%03d"), nIndex + 1), false))\r
        {\r
@@ -625,7 +625,7 @@ int __stdcall GetPluginInformation
        void * _pPtr\r
 )\r
 {\r
-       if (_pPtr == NULL)\r
+       if (_pPtr == nullptr)\r
        {\r
                return TPI_ERROR_D_PARAMETER;\r
        }\r
@@ -662,7 +662,7 @@ int __stdcall GetFormatInformation(TPI_FORMATINFO * _fiInfo, bool _bFirst)
        {\r
                xmlLibrary = myGetNextLib(xmlLibrary);\r
        }\r
-       if (xmlLibrary == NULL)\r
+       if (xmlLibrary == nullptr)\r
        {\r
                // データの終端に達した場合。\r
                return TPI_ERROR_S_ENDOFDATA;\r
@@ -709,7 +709,7 @@ int __stdcall LoadPlugin
                // xml解析開始。\r
                wxXmlDocument xmlDoc(myMakeXMLName(wxT("7zArc")));\r
                wxXmlNode * xmlLibrary = myGetFirstLib(& xmlDoc, _nTypeId);\r
-               if (xmlLibrary == NULL)\r
+               if (xmlLibrary == nullptr)\r
                {\r
                        // xml文法エラー。\r
                        return TPI_ERROR_UNDEFINED;\r
@@ -719,7 +719,7 @@ int __stdcall LoadPlugin
        }\r
 \r
        // コールバック関数を設定。\r
-       if (_prProc != NULL)\r
+       if (_prProc != nullptr)\r
        {\r
                g_prProc = * _prProc;\r
        }\r
@@ -758,7 +758,7 @@ int __stdcall OpenArchive
 \r
        // 対応するライブラリを調査。\r
        // 無限ループに陥らないよう上限を設定。\r
-       for (g_LibInfo.nLibIndex = 0; g_LibInfo.nLibIndex < 300 && xmlLibrary != NULL; g_LibInfo.nLibIndex++)\r
+       for (g_LibInfo.nLibIndex = 0; g_LibInfo.nLibIndex < 300 && xmlLibrary != nullptr; g_LibInfo.nLibIndex++)\r
        {\r
                // ライブラリをロード。\r
                const GUID guid = {0x23170F69, 0x40C1, 0x278A, {0x10, 0x00, 0x00, 0x01, 0x10, (unsigned char) myGetAttributeInt(xmlLibrary, wxT("name"), 0, 16), 0x00, 0x00}};\r
@@ -770,7 +770,7 @@ int __stdcall OpenArchive
                g_LibInfo.node = * xmlLibrary;\r
 \r
                // 書庫を開く。\r
-               CInFileStream * fileSpec = new CInFileStream;\r
+               auto fileSpec = new CInFileStream;\r
                CMyComPtr<IInStream> file = fileSpec;\r
                if (! fileSpec->Open(_szArcName.c_str()))\r
                {\r
@@ -782,7 +782,7 @@ int __stdcall OpenArchive
                MakeFormatInfo(xmlLibrary, wxT("7zArc"), & fiInfo, g_LibInfo.nLibIndex);\r
 \r
                // 書庫に対応しているかチェック。\r
-               CArchiveOpenCallback * openCallbackSpec = new CArchiveOpenCallback;\r
+               auto openCallbackSpec = new CArchiveOpenCallback;\r
                CMyComPtr<IArchiveOpenCallback> openCallback(openCallbackSpec);\r
                // SFXを完全に検出するには全体をロードする必要がある。\r
                wxULongLong_t nMax = fiInfo.fSFX ? 262114 : 1024;\r
@@ -794,7 +794,7 @@ int __stdcall OpenArchive
 */\r
                if (hArc->Open(file, & nMax, openCallback) == S_OK)\r
                {\r
-                       if (_nFileCount != NULL)\r
+                       if (_nFileCount != nullptr)\r
                        {\r
                                unsigned int n;\r
                                hArc->GetNumberOfItems(& n);\r
@@ -922,7 +922,7 @@ int __stdcall Command
                        while (GetFileInformation(_hArchive, & fiInfo) == TPI_ERROR_SUCCESS);\r
                }\r
 \r
-               CArchiveExtractCallback * extractCallbackSpec = new CArchiveExtractCallback((IInArchive *) _hArchive, _swInfo);\r
+               auto extractCallbackSpec = new CArchiveExtractCallback((IInArchive *) _hArchive, _swInfo);\r
                extractCallbackSpec->fnArchive = fnArchive;\r
                CMyComPtr<IArchiveExtractCallback> extractCallback(extractCallbackSpec);\r
                ((IInArchive *) _hArchive)->Extract(& nIndexes.Front(), nIndexes.Size(), _eCommand == TPI_COMMAND_TEST, extractCallback);\r
@@ -946,7 +946,7 @@ int __stdcall Command
                        fiItems.Add(fi);\r
                }\r
 \r
-               COutFileStream * outFileStreamSpec = new COutFileStream;\r
+               auto outFileStreamSpec = new COutFileStream;\r
                CMyComPtr<IOutStream> outFileStream = outFileStreamSpec;\r
                IOutArchive * hArc;\r
                if (_eCommand == TPI_COMMAND_CREATE)\r
@@ -1026,7 +1026,7 @@ int __stdcall Command
                }\r
 \r
                // 更新処理を実行。\r
-               CArchiveUpdateCallback * updateCallbackSpec = new CArchiveUpdateCallback(_swInfo, & fiItems);\r
+               auto updateCallbackSpec = new CArchiveUpdateCallback(_swInfo, & fiItems);\r
                CMyComPtr<IArchiveUpdateCallback2> updateCallback(updateCallbackSpec);\r
                hArc->UpdateItems(outFileStream, fiItems.Size(), updateCallback);\r
                nErrorCode = updateCallbackSpec->nErrorCode;\r