OSDN Git Service

TPIHandleの各関数の返し値をboolにし、エラーコードをnErrorCodeに記録するよう変更。
authorsirakaba <sirakaba@9df91469-1e22-0410-86e7-ea8537beb833>
Sat, 14 Nov 2009 04:16:28 +0000 (04:16 +0000)
committersirakaba <sirakaba@9df91469-1e22-0410-86e7-ea8537beb833>
Sat, 14 Nov 2009 04:16:28 +0000 (04:16 +0000)
git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/tpi/tpi@106 9df91469-1e22-0410-86e7-ea8537beb833

src/common/handle/TPIHandle.cpp
src/common/handle/TPIHandle.h
src/frontend/dlg_make.cpp
src/frontend/frm_main.cpp

index 4c87347..26c9a3c 100644 (file)
 #include <wx/dynlib.h>\r
 #include "TPIHandle.h"\r
 \r
+#define GetAPIAddress(name, p) \\r
+       if (! this->lib.HasSymbol(wxT(name))) \\r
+       { \\r
+               return false; \\r
+       } \\r
+       void * p = this->lib.GetSymbol(wxT(name)); \\r
+       if (! p) \\r
+       { \\r
+               return false; \\r
+       }\r
+\r
 //******************************************************************************\r
 //    Class (TPIHandle)\r
 //******************************************************************************\r
 \r
+TPIHandle::TPIHandle(void)\r
+{\r
+       this->nErrorCode = TPI_ERROR_SUCCESS;\r
+}\r
+\r
 TPIHandle::~TPIHandle(void)\r
 {\r
        this->FreeLibrary();\r
@@ -39,6 +55,7 @@ TPIHandle::~TPIHandle(void)
 \r
 bool TPIHandle::InitLibrary(const wxString & _szLibName, const wxString & _szArcName, wxULongLong _llSubOption)\r
 {\r
+       this->nErrorCode = TPI_ERROR_SUCCESS;\r
        this->lib.Load(_szLibName);\r
        if (! this->lib.IsLoaded())\r
        {\r
@@ -50,66 +67,40 @@ bool TPIHandle::InitLibrary(const wxString & _szLibName, const wxString & _szArc
                return true;\r
        }\r
 \r
-       if (! this->lib.HasSymbol(wxT("LoadPlugin")))\r
-       {\r
-               return false;\r
-       }\r
-       void * p = this->lib.GetSymbol(wxT("LoadPlugin"));\r
-       if (! p)\r
-       {\r
-               return false;\r
-       }\r
-\r
-       return ((int (__stdcall *)(const wxString &, wxULongLong)) p)(_szArcName, _llSubOption) == TPI_ERROR_SUCCESS;\r
+       GetAPIAddress("LoadPlugin", p);\r
+       this->nErrorCode = ((int (__stdcall *)(const wxString &, wxULongLong)) p)(_szArcName, _llSubOption);\r
+       return this->nErrorCode == TPI_ERROR_SUCCESS;\r
 }\r
 \r
 bool TPIHandle::FreeLibrary(void)\r
 {\r
+       this->nErrorCode = TPI_ERROR_SUCCESS;\r
        if (! this->lib.IsLoaded())\r
        {\r
                return false;\r
        }\r
 \r
-       if (! this->lib.HasSymbol(wxT("FreePlugin")))\r
-       {\r
-               return false;\r
-       }\r
-       void * p = this->lib.GetSymbol(wxT("FreePlugin"));\r
-       if (! p)\r
-       {\r
-               return false;\r
-       }\r
-       ((int (__stdcall *)(void *)) p)(NULL);\r
+       GetAPIAddress("FreePlugin", p);\r
+       this->nErrorCode = ((int (__stdcall *)(void *)) p)(NULL);\r
 \r
        this->lib.Unload();\r
-       return true;\r
+       return this->nErrorCode == TPI_ERROR_SUCCESS;\r
 }\r
 \r
-int TPIHandle::GetPluginInformation(unsigned int _uInfoId, wxULongLong _llSubOption, void * _pPtr)\r
+bool TPIHandle::GetPluginInformation(unsigned int _uInfoId, wxULongLong _llSubOption, void * _pPtr)\r
 {\r
-       if (! this->lib.HasSymbol(wxT("GetPluginInformation")))\r
-       {\r
-               return -1;\r
-       }\r
-       void * p = this->lib.GetSymbol(wxT("GetPluginInformation"));\r
-       if (! p)\r
-       {\r
-               return -1;\r
-       }\r
-\r
-       return ((int (__stdcall *)(unsigned int, wxULongLong, void *)) p)(_uInfoId, _llSubOption, _pPtr);\r
+       this->nErrorCode = TPI_ERROR_SUCCESS;\r
+       GetAPIAddress("GetPluginInformation", p);\r
+       this->nErrorCode = ((int (__stdcall *)(unsigned int, wxULongLong, void *)) p)(_uInfoId, _llSubOption, _pPtr);\r
+       return this->nErrorCode == TPI_ERROR_SUCCESS;\r
 }\r
 \r
-int TPIHandle::GetFormatInformation(TPI_FORMATINFO * _fiInfo, bool _bFirst)\r
+bool TPIHandle::GetFormatInformation(TPI_FORMATINFO * _fiInfo, bool _bFirst)\r
 {\r
-       if (! this->lib.HasSymbol(wxT("GetFormatInformation")) || ! _fiInfo)\r
-       {\r
-               return -1;\r
-       }\r
-       void * p = this->lib.GetSymbol(wxT("GetFormatInformation"));\r
-       if (! p)\r
+       this->nErrorCode = TPI_ERROR_SUCCESS;\r
+       if (! _fiInfo)\r
        {\r
-               return -1;\r
+               return false;\r
        }\r
 \r
        // Initialization.\r
@@ -132,64 +123,41 @@ int TPIHandle::GetFormatInformation(TPI_FORMATINFO * _fiInfo, bool _bFirst)
        _fiInfo->llTypeId           = 0;\r
        _fiInfo->pCustomInfo    = NULL;\r
 \r
-       return ((int (__stdcall *)(TPI_FORMATINFO *, bool)) p)(_fiInfo, _bFirst);\r
+       GetAPIAddress("GetFormatInformation", p);\r
+       this->nErrorCode = ((int (__stdcall *)(TPI_FORMATINFO *, bool)) p)(_fiInfo, _bFirst);\r
+       return this->nErrorCode == TPI_ERROR_SUCCESS;\r
 }\r
 \r
-int TPIHandle::CheckArchive(const wxString & _szArcName, int * _nFileCount)\r
+bool TPIHandle::CheckArchive(const wxString & _szArcName, int * _nFileCount)\r
 {\r
-       if (! this->lib.HasSymbol(wxT("CheckArchive")))\r
-       {\r
-               return -1;\r
-       }\r
-       void * p = this->lib.GetSymbol(wxT("CheckArchive"));\r
-       if (! p)\r
-       {\r
-               return -1;\r
-       }\r
-\r
-       return ((int (__stdcall *)(const wxString &, int *)) p)(_szArcName, _nFileCount);\r
+       this->nErrorCode = TPI_ERROR_SUCCESS;\r
+       GetAPIAddress("CheckArchive", p);\r
+       this->nErrorCode = ((int (__stdcall *)(const wxString &, int *)) p)(_szArcName, _nFileCount);\r
+       return this->nErrorCode == TPI_ERROR_SUCCESS;\r
 }\r
 \r
-int TPIHandle::OpenArchive(const wxString & _szArcName)\r
+bool TPIHandle::OpenArchive(const wxString & _szArcName)\r
 {\r
-       if (! this->lib.HasSymbol(wxT("OpenArchive")))\r
-       {\r
-               return -1;\r
-       }\r
-       void * p = this->lib.GetSymbol(wxT("OpenArchive"));\r
-       if (! p)\r
-       {\r
-               return -1;\r
-       }\r
-\r
-       return ((int (__stdcall *)(const wxString &, void * *)) p)(_szArcName, & this->archive);\r
+       this->nErrorCode = TPI_ERROR_SUCCESS;\r
+       GetAPIAddress("OpenArchive", p);\r
+       this->nErrorCode = ((int (__stdcall *)(const wxString &, void * *)) p)(_szArcName, & this->archive);\r
+       return this->nErrorCode == TPI_ERROR_SUCCESS;\r
 }\r
 \r
-int TPIHandle::CloseArchive(void)\r
+bool TPIHandle::CloseArchive(void)\r
 {\r
-       if (! this->lib.HasSymbol(wxT("CloseArchive")))\r
-       {\r
-               return -1;\r
-       }\r
-       void * p = this->lib.GetSymbol(wxT("CloseArchive"));\r
-       if (! p)\r
-       {\r
-               return -1;\r
-       }\r
-\r
-       return ((int (__stdcall *)(void *)) p)(this->archive);\r
+       this->nErrorCode = TPI_ERROR_SUCCESS;\r
+       GetAPIAddress("CloseArchive", p);\r
+       this->nErrorCode = ((int (__stdcall *)(void *)) p)(this->archive);\r
+       return this->nErrorCode == TPI_ERROR_SUCCESS;\r
 }\r
 \r
-int TPIHandle::GetFileInformation(TPI_FILEINFO * _fiInfo, bool _bFirst)\r
+bool TPIHandle::GetFileInformation(TPI_FILEINFO * _fiInfo, bool _bFirst)\r
 {\r
-       if (! this->lib.HasSymbol(wxT("GetFileInformation")) || ! _fiInfo)\r
-       {\r
-               return -1;\r
-       }\r
-       void * p = this->lib.GetSymbol(wxT("GetFileInformation"));\r
-       if (! p)\r
+       this->nErrorCode = TPI_ERROR_SUCCESS;\r
+       if (! _fiInfo)\r
        {\r
-               return -1;\r
+               return false;\r
        }\r
 \r
        // Initialization.\r
@@ -208,19 +176,17 @@ int TPIHandle::GetFileInformation(TPI_FILEINFO * _fiInfo, bool _bFirst)
        _fiInfo->llFileID       = 0;\r
        _fiInfo->pCustomInfo    = NULL;\r
 \r
-       return ((int (__stdcall *)(void *, TPI_FILEINFO *, bool)) p)(this->archive, _fiInfo, _bFirst);\r
+       GetAPIAddress("GetFileInformation", p);\r
+       this->nErrorCode = ((int (__stdcall *)(void *, TPI_FILEINFO *, bool)) p)(this->archive, _fiInfo, _bFirst);\r
+       return this->nErrorCode == TPI_ERROR_SUCCESS;\r
 }\r
 \r
-int TPIHandle::GetArchiveInformation(TPI_ARCHIVEINFO * _aiInfo)\r
+bool TPIHandle::GetArchiveInformation(TPI_ARCHIVEINFO * _aiInfo)\r
 {\r
-       if (! this->lib.HasSymbol(wxT("GetArchiveInformation")) || ! _aiInfo)\r
-       {\r
-               return -1;\r
-       }\r
-       void * p = this->lib.GetSymbol(wxT("GetArchiveInformation"));\r
-       if (! p)\r
+       this->nErrorCode = TPI_ERROR_SUCCESS;\r
+       if (! _aiInfo)\r
        {\r
-               return -1;\r
+               return false;\r
        }\r
 \r
        // Initialization.\r
@@ -263,35 +229,23 @@ int TPIHandle::GetArchiveInformation(TPI_ARCHIVEINFO * _aiInfo)
        _aiInfo->fiInfo.llTypeId           = 0;\r
        _aiInfo->fiInfo.pCustomInfo    = NULL;\r
 \r
-       return ((int (__stdcall *)(void *, TPI_ARCHIVEINFO *)) p)(this->archive, _aiInfo);\r
+       GetAPIAddress("GetArchiveInformation", p);\r
+       this->nErrorCode = ((int (__stdcall *)(void *, TPI_ARCHIVEINFO *)) p)(this->archive, _aiInfo);\r
+       return this->nErrorCode == TPI_ERROR_SUCCESS;\r
 }\r
 \r
-int TPIHandle::Command(unsigned int _uCommand, TPI_SWITCHES * _swInfo, const wxString & _szArcName, const wxArrayString & _szFiles)\r
+bool TPIHandle::Command(unsigned int _uCommand, TPI_SWITCHES * _swInfo, const wxString & _szArcName, const wxArrayString & _szFiles)\r
 {\r
-       if (! this->lib.HasSymbol(wxT("Command")))\r
-       {\r
-               return -1;\r
-       }\r
-       void * p = this->lib.GetSymbol(wxT("Command"));\r
-       if (! p)\r
-       {\r
-               return -1;\r
-       }\r
-\r
-       return ((int (__stdcall *)(unsigned int, TPI_SWITCHES *, const wxString &, const wxArrayString &)) p)(_uCommand, _swInfo, _szArcName, _szFiles);\r
+       this->nErrorCode = TPI_ERROR_SUCCESS;\r
+       GetAPIAddress("Command", p);\r
+       this->nErrorCode = ((int (__stdcall *)(unsigned int, TPI_SWITCHES *, const wxString &, const wxArrayString &)) p)(_uCommand, _swInfo, _szArcName, _szFiles);\r
+       return this->nErrorCode == TPI_ERROR_SUCCESS;\r
 }\r
 \r
-int TPIHandle::SetCallbackProc(TPI_PROC _prProc)\r
+bool TPIHandle::SetCallbackProc(TPI_PROC _prProc)\r
 {\r
-       if (! this->lib.HasSymbol(wxT("SetCallbackProc")))\r
-       {\r
-               return -1;\r
-       }\r
-       void * p = this->lib.GetSymbol(wxT("SetCallbackProc"));\r
-       if (! p)\r
-       {\r
-               return -1;\r
-       }\r
-\r
-       return ((int (__stdcall *)(TPI_PROC)) p)(_prProc);\r
+       this->nErrorCode = TPI_ERROR_SUCCESS;\r
+       GetAPIAddress("SetCallbackProc", p);\r
+       this->nErrorCode = ((int (__stdcall *)(TPI_PROC)) p)(_prProc);\r
+       return this->nErrorCode == TPI_ERROR_SUCCESS;\r
 }\r
index a52910a..51892bb 100644 (file)
 class TPIHandle
 {
        public:
+               TPIHandle(void);
                ~TPIHandle(void);
-               int GetPluginInformation(unsigned int, wxULongLong, void *);
-               int GetFormatInformation(TPI_FORMATINFO *, bool);
                bool InitLibrary(const wxString &, const wxString &, wxULongLong);
                bool FreeLibrary(void);
 
-               int CheckArchive(const wxString &, int *);
-               int OpenArchive(const wxString &);
-               int CloseArchive(void);
-               int GetFileInformation(TPI_FILEINFO *, bool);
-               int GetArchiveInformation(TPI_ARCHIVEINFO *);
+               bool GetPluginInformation(unsigned int, wxULongLong, void *);
+               bool GetFormatInformation(TPI_FORMATINFO *, bool);
 
-               int Command(unsigned int, TPI_SWITCHES *, const wxString &, const wxArrayString &);
+               bool CheckArchive(const wxString &, int *);
+               bool OpenArchive(const wxString &);
+               bool CloseArchive(void);
+               bool GetFileInformation(TPI_FILEINFO *, bool);
+               bool GetArchiveInformation(TPI_ARCHIVEINFO *);
+
+               bool Command(unsigned int, TPI_SWITCHES *, const wxString &, const wxArrayString &);
+
+               bool SetCallbackProc(TPI_PROC);
+
+               int nErrorCode;
 
-               int SetCallbackProc(TPI_PROC);
        private:
                wxDynamicLibrary lib;
                void * archive;
index dc28094..4f73511 100644 (file)
@@ -140,7 +140,7 @@ void MakeDialog::OnInit(wxInitDialogEvent&)
                {
                        // \91Î\89\9e\82·\82é\8c`\8e®\96¼\82ð\8eæ\93¾\81B
                        TPI_FORMATINFO fiInfo;
-                       if (tpi.GetFormatInformation(& fiInfo, true) == TPI_ERROR_SUCCESS)
+                       if (tpi.GetFormatInformation(& fiInfo, true))
                        {
                                do
                                {
@@ -151,7 +151,7 @@ void MakeDialog::OnInit(wxInitDialogEvent&)
                                                this->chType->Append(fiInfo.szTypeName);
                                        }
                                }
-                               while (tpi.GetFormatInformation(& fiInfo, false) == TPI_ERROR_SUCCESS);
+                               while (tpi.GetFormatInformation(& fiInfo, false));
                        }
                        tpi.FreeLibrary();
                }
index 3636ed9..639fadb 100644 (file)
@@ -308,7 +308,7 @@ void MainFrame::OnArcCreate(wxCommandEvent& e)
        }
 
        // \83R\81[\83\8b\83o\83b\83N\8aÖ\90\94\82ð\90Ý\92è\81B
-       if (tpi.SetCallbackProc(TPICallbackProc) != TPI_ERROR_SUCCESS)
+       if (! tpi.SetCallbackProc(TPICallbackProc))
        {
                ::ErrDlg(wxT("SetCallbackProc()!"), this);
        }
@@ -317,13 +317,13 @@ void MainFrame::OnArcCreate(wxCommandEvent& e)
        ProcessDialog procDlg;
        procDlg.InitDialog();
        procDlg.Show(true);
-       int nErrorCode = this->ErrorCheck(tpi.Command(TPI_COMMAND_ADD, & swInfo, this->fnArchive.GetFullPath(), mkDlg.files));
-       procDlg.Show(false);
-       tpi.FreeLibrary();
-       if (nErrorCode != TPI_ERROR_SUCCESS)
+       if (! tpi.Command(TPI_COMMAND_ADD, & swInfo, this->fnArchive.GetFullPath(), mkDlg.files))
        {
+               this->ErrorCheck(tpi.nErrorCode);
                return;
        }
+       procDlg.Show(false);
+       tpi.FreeLibrary();
 
        if (mkDlg.cbOpenAfter->IsChecked())
        {
@@ -382,7 +382,7 @@ void MainFrame::OnArcOpen(wxCommandEvent& e)
        TPICallbackProc(TPI_NOTIFY_COMMON, & piInfo);
 
        // \83R\81[\83\8b\83o\83b\83N\8aÖ\90\94\82ð\90Ý\92è\81B
-       if (tpi.SetCallbackProc(TPICallbackProc) != TPI_ERROR_SUCCESS)
+       if (! tpi.SetCallbackProc(TPICallbackProc))
        {
                ::ErrDlg(wxT("SetCallbackProc()!"), this);
        }
@@ -391,7 +391,7 @@ void MainFrame::OnArcOpen(wxCommandEvent& e)
        this->fileinfo.Alloc(piInfo.fiInfo.llUnpackedSize.ToULong());
 
        // \8f\91\8cÉ\82ð\8aJ\82­\81B
-       if (tpi.OpenArchive(this->fnArchive.GetFullPath()) != TPI_ERROR_SUCCESS)
+       if (! tpi.OpenArchive(this->fnArchive.GetFullPath()))
        {
                procDlg.Show(false);
                tpi.FreeLibrary();
@@ -413,7 +413,7 @@ void MainFrame::OnArcOpen(wxCommandEvent& e)
                idArcRoot = this->tree_ctrl->AppendItem(idRoot, wxT("-----"), 0, 1);
 
        // \83t\83@\83C\83\8b\8fî\95ñ\82ð\83\8d\81[\83h\81B
-       if (tpi.GetFileInformation(& piInfo.fiInfo, true) == TPI_ERROR_SUCCESS)
+       if (tpi.GetFileInformation(& piInfo.fiInfo, true))
        {
                piInfo.uStatus = 0x1001;
                do
@@ -468,12 +468,12 @@ void MainFrame::OnArcOpen(wxCommandEvent& e)
                        // \8fî\95ñ\82ð\95Û\91\82µ\82Ä\83J\83E\83\93\83g\83A\83b\83v\81B
                        this->fileinfo.Add(piInfo.fiInfo);
                }
-               while (tpi.GetFileInformation(& piInfo.fiInfo, false) == TPI_ERROR_SUCCESS);
+               while (tpi.GetFileInformation(& piInfo.fiInfo, false));
        }
 
        // \8f\91\8cÉ\82Ì\8fî\95ñ\82ð\8eæ\93¾\81B
        TPI_ARCHIVEINFO aiInfo;
-       if (tpi.GetArchiveInformation(& aiInfo) != TPI_ERROR_SUCCESS)
+       if (! tpi.GetArchiveInformation(& aiInfo))
        {
                procDlg.Show(false);
                tpi.FreeLibrary();
@@ -482,7 +482,7 @@ void MainFrame::OnArcOpen(wxCommandEvent& e)
        }
 
        // \8f\91\8cÉ\82ð\95Â\82\82é\81B
-       if (tpi.CloseArchive() != TPI_ERROR_SUCCESS)
+       if (! tpi.CloseArchive())
        {
                ::ErrDlg(wxT("CloseArchive()!"), this);
        }
@@ -565,7 +565,10 @@ void MainFrame::OnArcAdd(wxCommandEvent& e)
        ProcessDialog procDlg;
        procDlg.InitDialog();
        procDlg.Show(true);
-       this->ErrorCheck(this->tpi.Command(TPI_COMMAND_ADD, & swInfo, this->fnArchive.GetFullPath(), files));
+       if (! this->tpi.Command(TPI_COMMAND_ADD, & swInfo, this->fnArchive.GetFullPath(), files))
+       {
+               this->ErrorCheck(tpi.nErrorCode);
+       }
        procDlg.Show(false);
 
        // \8f\91\8cÉ\82ð\8dÄ\93Ç\82Ý\8d\9e\82Ý\81B
@@ -593,7 +596,10 @@ void MainFrame::OnArcConvert(wxCommandEvent& e)
        ProcessDialog procDlg;
        procDlg.InitDialog();
        procDlg.Show(true);
-       this->ErrorCheck(this->tpi.Command(swInfo.fMakeSFX ? TPI_COMMAND_SFX : TPI_COMMAND_UNSFX, & swInfo, this->fnArchive.GetFullPath(), files));
+       if (! this->tpi.Command(swInfo.fMakeSFX ? TPI_COMMAND_SFX : TPI_COMMAND_UNSFX, & swInfo, this->fnArchive.GetFullPath(), files))
+       {
+               this->ErrorCheck(tpi.nErrorCode);
+       }
        procDlg.Show(false);
 }
 
@@ -676,7 +682,10 @@ void MainFrame::OnArcExtract(wxCommandEvent& e)
        ProcessDialog procDlg;
        procDlg.InitDialog();
        procDlg.Show(true);
-       int nErrorCode = this->ErrorCheck(this->tpi.Command(TPI_COMMAND_EXTRACT, & swInfo, this->fnArchive.GetFullPath(), mkDlg.files));
+       if(! this->tpi.Command(TPI_COMMAND_EXTRACT, & swInfo, this->fnArchive.GetFullPath(), mkDlg.files));
+       {
+               this->ErrorCheck(tpi.nErrorCode);
+       }
        procDlg.Show(false);
 
        if (nMode == 0)
@@ -702,7 +711,7 @@ void MainFrame::OnArcExtract(wxCommandEvent& e)
                {
                        // \83R\83}\83\93\83h\82ð\8eÀ\8ds\81B
                        asFiles.Add(swInfo.fnDestinationDirectory.GetPathWithSep() + wxFileName(mkDlg.files[0]).GetFullName());
-                       if (nErrorCode == TPI_ERROR_SUCCESS)
+                       if (tpi.nErrorCode == TPI_ERROR_SUCCESS)
                        {
                                ::wxExecute(ftFile->GetOpenCommand(wxT('"') + asFiles[0] + wxT('"')), wxEXEC_SYNC);
                        }
@@ -764,7 +773,10 @@ void MainFrame::OnArcDelete(wxCommandEvent& e)
        ProcessDialog procDlg;
        procDlg.InitDialog();
        procDlg.Show(true);
-       this->ErrorCheck(this->tpi.Command(TPI_COMMAND_DELETE, & swInfo, this->fnArchive.GetFullPath(), MakeTargetFileList(this, false)));
+       if (! this->tpi.Command(TPI_COMMAND_DELETE, & swInfo, this->fnArchive.GetFullPath(), MakeTargetFileList(this, false)))
+       {
+               this->ErrorCheck(tpi.nErrorCode);
+       }
        procDlg.Show(false);    
 
        // \8f\91\8cÉ\82ð\8dÄ\93Ç\82Ý\8d\9e\82Ý\82·\82é\81B
@@ -777,10 +789,14 @@ void MainFrame::OnArcTest(wxCommandEvent&)
        ProcessDialog procDlg;
        procDlg.InitDialog();
        procDlg.Show(true);
-       if (this->ErrorCheck(this->tpi.Command(TPI_COMMAND_TEST, & swInfo, this->fnArchive.GetFullPath(), MakeTargetFileList(this, false))) == TPI_ERROR_SUCCESS)
+       if (this->tpi.Command(TPI_COMMAND_TEST, & swInfo, this->fnArchive.GetFullPath(), MakeTargetFileList(this, false)))
        {
                ::MsgDlg(wxT("This is a correct archive."), & procDlg, wxICON_INFORMATION);
        }
+       else
+       {
+               this->ErrorCheck(tpi.nErrorCode);
+       }
        procDlg.Show(false);
 }
 
@@ -790,7 +806,10 @@ void MainFrame::OnArcRepair(wxCommandEvent&)
        ProcessDialog procDlg;
        procDlg.InitDialog();
        procDlg.Show(true);
-       this->ErrorCheck(this->tpi.Command(TPI_COMMAND_REPAIR, & swInfo, this->fnArchive.GetFullPath(), MakeTargetFileList(this, false)));
+       if (! this->tpi.Command(TPI_COMMAND_REPAIR, & swInfo, this->fnArchive.GetFullPath(), MakeTargetFileList(this, false)))
+       {
+               this->ErrorCheck(tpi.nErrorCode);
+       }
        procDlg.Show(false);    
 }
 
@@ -924,7 +943,7 @@ int MainFrame::LoadTPI(wxString szFileName)
        while (! szTPIName.IsEmpty())
        {
                // \91Î\89\9e\8am\94F\81B
-               if (! tpi.InitLibrary(szTPIName, szFileName, 0) || tpi.CheckArchive(szFileName, & nFileCount) != TPI_ERROR_SUCCESS || nFileCount < 0)
+               if (! tpi.InitLibrary(szTPIName, szFileName, 0) || ! tpi.CheckArchive(szFileName, & nFileCount) || nFileCount < 0)
                {
                        tpi.FreeLibrary();
                        szTPIName = fs.FindNext();