OSDN Git Service

書庫名をMainFrame内に保持しておくよう変更。
authorsirakaba <sirakaba@9df91469-1e22-0410-86e7-ea8537beb833>
Fri, 23 Oct 2009 14:20:01 +0000 (14:20 +0000)
committersirakaba <sirakaba@9df91469-1e22-0410-86e7-ea8537beb833>
Fri, 23 Oct 2009 14:20:01 +0000 (14:20 +0000)
git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/tpi/tpi@77 9df91469-1e22-0410-86e7-ea8537beb833

src/frontend/cls_filedroptarget.cpp
src/frontend/dlg_make.cpp
src/frontend/frm_main.cpp
src/frontend/frm_main.h
src/frontend/frontend.cpp

index c3f26ef..817f10a 100644 (file)
@@ -45,7 +45,7 @@ bool myFileDropTarget::OnDropFiles(wxCoord, wxCoord, const wxArrayString & asFil
        if (asFiles.Count() == 1 && this->mainFrame->LoadTPI(asFiles[0]) != -1)
        {
                // \8f\91\8cÉ\82ð\8aJ\82­\81B
-               e.SetString(asFiles[0]);
+               this->mainFrame->fnArchive = wxFileName(asFiles[0]);
                this->mainFrame->OnArcOpen(e);
                return true;
        }
index 1cfafc6..c2dfa31 100644 (file)
@@ -115,9 +115,8 @@ void MakeDialog::OnInit(wxInitDialogEvent&)
                this->tcComment->SetEditable(false);
 
                // \8f\89\8aú\92l\82ð\90Ý\92è\81B
-               wxFileName fnArchive(((MainFrame *) this->GetParent())->statusbar->GetStatusText(4));
-               this->cbDir->SetValue(fnArchive.GetPath());
-               this->cbFileName->SetValue(fnArchive.GetFullName());
+               this->cbDir->SetValue(((MainFrame *) this->GetParent())->fnArchive.GetPath());
+               this->cbFileName->SetValue(((MainFrame *) this->GetParent())->fnArchive.GetFullName());
 
                // \93W\8aJ\90æ\82ð\97\\91ª\81B\82½\82¾\82µDTV\83X\83L\83\83\83\93\82É\8e\9e\8aÔ\82ª\82©\82©\82é\8fê\8d\87\82Í\83X\83L\83b\83v\89Â\94\\81B
                if (this->files.Count() < 3000 || ::AskDlg(wxT("This archive contains so many files that it takes long to check Directory Traversal Vulnerability(DTV) problem. If you are sure this archive is safe, you can skip this scanning process. Do you want to scan for DTV problem?"), this) == wxYES)
@@ -178,7 +177,7 @@ void MakeDialog::OnBtnDesktop(wxCommandEvent&)
 
 void MakeDialog::OnBtnCurrent(wxCommandEvent&)
 {
-       this->cbDir->SetValue(wxFileName::FileName(((MainFrame *) this->GetParent())->statusbar->GetStatusText(4)).GetPath());
+       this->cbDir->SetValue(((MainFrame *) this->GetParent())->fnArchive.GetPath());
 }
 
 void MakeDialog::OnBtnBrowse(wxCommandEvent&)
index 3180898..d7511e1 100644 (file)
@@ -202,9 +202,8 @@ void MainFrame::OnInit(wxInitDialogEvent&)
                }
 
                // \8f\91\8cÉ\82ð\8aJ\82­\81B
-               wxFileName fnArchive(this->cmdLine.GetParam(0));
-               fnArchive.Normalize(wxPATH_NORM_ALL, this->szCurrentPath);
-               e.SetString(fnArchive.GetFullPath());
+               this->fnArchive = wxFileName(this->cmdLine.GetParam(0));
+               this->fnArchive.Normalize(wxPATH_NORM_ALL, this->szCurrentPath);
                this->OnArcOpen(e);
                if (this->cmdLine.Found(wxT("x")))
                {
@@ -267,11 +266,14 @@ void MainFrame::OnArcCreate(wxCommandEvent& e)
                }
        }
 
+       this->OnArcClose(e);
        mkDlg.InitDialog();
        mkDlg.cbDir->SetValue(swInfo.fnDestinationDirectory.GetPath());
        // \8f\91\8cÉ\96¼\82Í\83t\83@\83C\83\8b\96¼\82Ì\8ag\92£\8eq\82æ\82è\91O\81A\82à\82µ\82­\82Í\83f\83B\83\8c\83N\83g\83\8a\96¼\81B
-       wxFileName fnFirstFile(mkDlg.files[0]);
-       mkDlg.cbFileName->SetValue(mkDlg.files.GetCount() == 1 ? (fnFirstFile.GetName().IsEmpty() ? fnFirstFile.GetDirs().Last() : fnFirstFile.GetName()) : swInfo.fnDestinationDirectory.GetDirs().Last());
+       this->fnArchive = wxFileName(mkDlg.files[0]);
+       this->fnArchive.SetName(mkDlg.files.GetCount() == 1 ? (this->fnArchive.GetName().IsEmpty() ? this->fnArchive.GetDirs().Last() : this->fnArchive.GetName()) : swInfo.fnDestinationDirectory.GetDirs().Last());
+       this->fnArchive.SetPath(swInfo.fnDestinationDirectory.GetPath());
+       mkDlg.cbFileName->SetValue(this->fnArchive.GetName());
 
        // \83_\83C\83A\83\8d\83O\82ð\95\\8e¦\81B
        if (mkDlg.ShowModal() == wxID_CANCEL)
@@ -300,10 +302,8 @@ void MainFrame::OnArcCreate(wxCommandEvent& e)
 
        // TPI\82ð\93Ç\82Ý\8d\9e\82Ý\81B
        int nSelected = mkDlg.chType->GetSelection();
-       wxFileName fnArchive = wxFileName::DirName(mkDlg.cbDir->GetValue());
-       fnArchive.SetName(mkDlg.cbFileName->GetValue());
-       fnArchive.SetExt(swInfo.fMakeSFX ? EXE_EXT : mkDlg.afInfo[nSelected].szSuffix.BeforeFirst(wxT(';')));
-       if (! tpi.InitLibrary(mkDlg.afInfo[nSelected].szTPIName, fnArchive.GetFullPath(), mkDlg.afInfo[nSelected].llTypeId))
+       this->fnArchive = wxFileName(mkDlg.cbDir->GetValue(), mkDlg.cbFileName->GetValue(), swInfo.fMakeSFX ? EXE_EXT : mkDlg.afInfo[nSelected].szSuffix.BeforeFirst(wxT(';')));
+       if (! tpi.InitLibrary(mkDlg.afInfo[nSelected].szTPIName, this->fnArchive.GetFullPath(), mkDlg.afInfo[nSelected].llTypeId))
        {
                ::ErrDlg(wxT("InitLibrary()!"), this);
                return;
@@ -319,7 +319,7 @@ void MainFrame::OnArcCreate(wxCommandEvent& e)
        ProcessDialog procDlg;
        procDlg.InitDialog();
        procDlg.Show(true);
-       int nErrorCode = this->ErrorCheck(tpi.Command(TPI_COMMAND_ADD, & swInfo, fnArchive.GetFullPath(), mkDlg.files));
+       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)
@@ -342,15 +342,13 @@ void MainFrame::OnArcCreate(wxCommandEvent& e)
        }
 
        // \8fI\97¹\82µ\82È\82¢\8fê\8d\87\82Í\8f\91\8cÉ\82ð\8aJ\82­\81B
-       e.SetString(fnArchive.GetFullPath());
        this->OnArcOpen(e);
 }
 
 void MainFrame::OnArcOpen(wxCommandEvent& e)
 {
        // \8f\91\8cÉ\82ð\91I\91ð\81B
-       wxString szFileName = e.GetString();
-       if (szFileName.IsEmpty())
+       if (e.GetId() == XRCID("Arc_Open"))
        {
                wxFileDialog fd(this);
                fd.SetDirectory(this->conf.Read(wxT("LastOpenPath"), ::wxGetCwd()));
@@ -360,7 +358,7 @@ void MainFrame::OnArcOpen(wxCommandEvent& e)
                        return;
                }
                this->conf.Write(wxT("LastOpenPath"), fd.GetDirectory());
-               szFileName = fd.GetPath();
+               this->fnArchive = wxFileName(fd.GetPath());
        }
        this->OnArcClose(e);
 
@@ -374,8 +372,8 @@ void MainFrame::OnArcOpen(wxCommandEvent& e)
        piInfo.uMessage = TPI_MESSAGE_STATUS;
        piInfo.uStatus = 0x1000;
        piInfo.llProcessedSize = 0;
-       piInfo.fiInfo.fnFileName = wxFileName::FileName(szFileName);
-       piInfo.fiInfo.llUnpackedSize = this->LoadTPI(szFileName);
+       piInfo.fiInfo.fnFileName = this->fnArchive;
+       piInfo.fiInfo.llUnpackedSize = this->LoadTPI(this->fnArchive.GetFullPath());
        if ((signed) piInfo.fiInfo.llUnpackedSize.ToULong() == -1)
        {
                procDlg.Show(false);
@@ -389,7 +387,7 @@ void MainFrame::OnArcOpen(wxCommandEvent& e)
        this->fileinfo.Alloc(piInfo.fiInfo.llUnpackedSize.ToULong());
 
        // \8f\91\8cÉ\82ð\8aJ\82­\81B
-       if (tpi.OpenArchive(szFileName) != TPI_ERROR_SUCCESS)
+       if (tpi.OpenArchive(this->fnArchive.GetFullPath()) != TPI_ERROR_SUCCESS)
        {
                procDlg.Show(false);
                tpi.FreeLibrary();
@@ -501,9 +499,9 @@ void MainFrame::OnArcOpen(wxCommandEvent& e)
        // \83X\83e\81[\83^\83X\83o\81[\90Ý\92è\81B
        this->statusbar->SetStatusText(aiInfo.fiInfo.szTypeName, 0);
        this->statusbar->SetStatusText(wxString::Format(wxT("%d file(s)"), this->fileinfo.Count()), 1);
-       this->statusbar->SetStatusText(aiInfo.llUnpackedSize.ToString() + wxT(" B -> ") + aiInfo.llPackedSize.ToString()   + wxT(" B"), 2);
+       this->statusbar->SetStatusText(aiInfo.llUnpackedSize.ToString() + wxT(" B -> ") + aiInfo.llPackedSize.ToString() + wxT(" B"), 2);
        this->statusbar->SetStatusText(wxString::Format(wxT("%3.1f%%"), aiInfo.wCompressRatio / 10.0), 3);
-       this->statusbar->SetStatusText(szFileName, 4);
+       this->statusbar->SetStatusText(this->fnArchive.GetFullPath(), 4);
 
        // \83c\81[\83\8b\83o\81[\81E\83\81\83j\83\85\81[\83o\81[\90Ý\92è\81B
        SetMenuToolState("Arc_Close",   true);
@@ -565,16 +563,14 @@ void MainFrame::OnArcAdd(wxCommandEvent& e)
        swInfo.fnDestinationDirectory = wxFileName::DirName(fd.GetDirectory());
        swInfo.fMakeSFX = false;
        swInfo.pCustomSwitches = NULL;
-       wxString szArcName = this->statusbar->GetStatusText(4);
 
        ProcessDialog procDlg;
        procDlg.InitDialog();
        procDlg.Show(true);
-       this->ErrorCheck(this->tpi.Command(TPI_COMMAND_ADD, & swInfo, szArcName, files));
+       this->ErrorCheck(this->tpi.Command(TPI_COMMAND_ADD, & swInfo, this->fnArchive.GetFullPath(), files));
        procDlg.Show(false);
 
        // \8f\91\8cÉ\82ð\8dÄ\93Ç\82Ý\8d\9e\82Ý\81B
-       e.SetString(szArcName);
        this->OnArcOpen(e);
 }
 
@@ -584,8 +580,7 @@ void MainFrame::OnArcConvert(wxCommandEvent& e)
        swInfo.fMakeSFX = e.GetId() == XRCID("Arc_SFX");
 
        // \95Û\91\90æ\82ð\90q\82Ë\82é\81B
-       wxFileName fnArchive(this->statusbar->GetStatusText(4));
-       wxFileDialog fd(this, swInfo.fMakeSFX ? wxT("Save as SFX") : wxT("Save as normal archive"), fnArchive.GetPath(), fnArchive.GetName() + (swInfo.fMakeSFX ? EXE_EXT : (wxString) wxEmptyString));
+       wxFileDialog fd(this, swInfo.fMakeSFX ? wxT("Save as SFX") : wxT("Save as normal archive"), this->fnArchive.GetPath(), this->fnArchive.GetName() + (swInfo.fMakeSFX ? EXE_EXT : (wxString) wxEmptyString));
        fd.SetWindowStyleFlag(wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
        if (fd.ShowModal() == wxID_CANCEL)
        {
@@ -600,7 +595,7 @@ 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, fnArchive.GetFullPath(), files));
+       this->ErrorCheck(this->tpi.Command(swInfo.fMakeSFX ? TPI_COMMAND_SFX : TPI_COMMAND_UNSFX, & swInfo, this->fnArchive.GetFullPath(), files));
        procDlg.Show(false);
 }
 
@@ -645,7 +640,7 @@ void MainFrame::OnArcExtract(wxCommandEvent& e)
                if (szDestDirBase == wxT("-----"))
                {
                        // \8f\91\8cÉ\83\8b\81[\83g\82Ì\82Æ\82«\82Í\8f\91\8cÉ\96¼\82É\82µ\82Ä\82¨\82­\81B
-                       szDestDirBase = wxFileName::FileName(this->statusbar->GetStatusText(4)).GetName();
+                       szDestDirBase = this->fnArchive.GetName();
                }
                swInfo.fnDestinationDirectory = MakeDirPath(wxFileName::DirName(::wxGetCwd()), szDestDirBase, true);
                if (! swInfo.fnDestinationDirectory.IsOk())
@@ -671,7 +666,7 @@ void MainFrame::OnArcExtract(wxCommandEvent& e)
                // \95K\97v\82È\82ç\8f\91\8cÉ\96¼\82Å\83f\83B\83\8c\83N\83g\83\8a\82ð\8dì\90¬\82·\82é\81B
                if (WillMakeDirByArcName(this, & mkDlg))
                {
-                       swInfo.fnDestinationDirectory = MakeDirPath(swInfo.fnDestinationDirectory, wxFileName::FileName(this->statusbar->GetStatusText(4)).GetName(), true);
+                       swInfo.fnDestinationDirectory = MakeDirPath(swInfo.fnDestinationDirectory, this->fnArchive.GetName(), true);
                        if (! swInfo.fnDestinationDirectory.IsOk())
                        {
                                ::ErrDlg(wxT("Unable to make the destination directory!"), this);
@@ -683,7 +678,7 @@ void MainFrame::OnArcExtract(wxCommandEvent& e)
        ProcessDialog procDlg;
        procDlg.InitDialog();
        procDlg.Show(true);
-       int nErrorCode = this->ErrorCheck(this->tpi.Command(TPI_COMMAND_EXTRACT, & swInfo, this->statusbar->GetStatusText(4), mkDlg.files));
+       int nErrorCode = this->ErrorCheck(this->tpi.Command(TPI_COMMAND_EXTRACT, & swInfo, this->fnArchive.GetFullPath(), mkDlg.files));
        procDlg.Show(false);
 
        if (nMode == 0)
@@ -768,17 +763,15 @@ void MainFrame::OnArcDelete(wxCommandEvent& e)
 
        // \8ae\8eí\90Ý\92è\81B
        TPI_SWITCHES swInfo;
-       wxString szArcName = this->statusbar->GetStatusText(4);
        wxArrayString files = MakeTargetFileList(this, false);
 
        ProcessDialog procDlg;
        procDlg.InitDialog();
        procDlg.Show(true);
-       this->ErrorCheck(this->tpi.Command(TPI_COMMAND_DELETE, & swInfo, szArcName, files));
+       this->ErrorCheck(this->tpi.Command(TPI_COMMAND_DELETE, & swInfo, this->fnArchive.GetFullPath(), files));
        procDlg.Show(false);    
 
        // \8f\91\8cÉ\82ð\8dÄ\93Ç\82Ý\8d\9e\82Ý\82·\82é\81B
-       e.SetString(szArcName);
        this->OnArcOpen(e);
 }
 
@@ -791,7 +784,7 @@ void MainFrame::OnArcTest(wxCommandEvent&)
        ProcessDialog procDlg;
        procDlg.InitDialog();
        procDlg.Show(true);
-       if (this->ErrorCheck(this->tpi.Command(TPI_COMMAND_TEST, & swInfo, this->statusbar->GetStatusText(4), files)) == TPI_ERROR_SUCCESS)
+       if (this->ErrorCheck(this->tpi.Command(TPI_COMMAND_TEST, & swInfo, this->fnArchive.GetFullPath(), files)) == TPI_ERROR_SUCCESS)
        {
                ::MsgDlg(wxT("This is a correct archive."), & procDlg, wxICON_INFORMATION);
        }
@@ -807,7 +800,7 @@ void MainFrame::OnArcRepair(wxCommandEvent&)
        ProcessDialog procDlg;
        procDlg.InitDialog();
        procDlg.Show(true);
-       this->ErrorCheck(this->tpi.Command(TPI_COMMAND_REPAIR, & swInfo, this->statusbar->GetStatusText(4), files));
+       this->ErrorCheck(this->tpi.Command(TPI_COMMAND_REPAIR, & swInfo, this->fnArchive.GetFullPath(), files));
        procDlg.Show(false);    
 }
 
@@ -927,7 +920,7 @@ void MainFrame::OnFilter(wxCommandEvent&)
 
 // \83C\83x\83\93\83g\83n\83\93\83h\83\89\88È\8aO\81B
 
-int MainFrame::LoadTPI(wxString szFileName)
+int MainFrame::LoadTPI(wxString szFileName)
 {
        // TPI\82ð\93Ç\82Ý\8d\9e\82Ý\81B
        wxFileSystem fs;
index d107019..e577ee2 100644 (file)
@@ -35,6 +35,7 @@ public:
        TPIHandle tpi;
        wxString szCurrentPath;
        wxCmdLineParser cmdLine;
+       wxFileName fnArchive;
 
     // Event handler.
     void OnInit(    wxInitDialogEvent&);
@@ -66,7 +67,7 @@ public:
 
        void OnFilter(wxCommandEvent&);
 
-       int LoadTPI(wxString &);
+       int LoadTPI(wxString);
        int ErrorCheck(int);
 
        MainFrame();
index 849ae95..7835e61 100644 (file)
@@ -39,16 +39,17 @@ bool Frontend::OnInit()
        wxInitAllImageHandlers();
        ::wxXmlResource::Get()->InitAllHandlers();
 
-       MainFrame * frm_main = new MainFrame();
-
        // \8dì\8bÆ\83p\83X\82ð\90Ý\92è\81B
+       wxString szCwd;
        {
                wxChar cSep = wxFileName::GetPathSeparator();
+               szCwd = ::wxGetCwd() + cSep;
                wxStandardPaths p;
-               frm_main->szCurrentPath = ::wxGetCwd() + cSep;
                ::wxSetWorkingDirectory(::wxPathOnly(p.GetExecutablePath()) + cSep);
        }
 
+       MainFrame * frm_main = new MainFrame();
+       frm_main->szCurrentPath = szCwd;
        if (! ::wxXmlResource::Get()->Load(FE_DIR_S_XRC wxT("frm_main.xrc")))
        {
                ::ErrDlg(wxT("Unable to find XRC!"), NULL);