From 33664a20f584a906455f63da52a2cda0eb630cc4 Mon Sep 17 00:00:00 2001 From: sirakaba Date: Fri, 23 Oct 2009 14:20:01 +0000 Subject: [PATCH] =?utf8?q?=E6=9B=B8=E5=BA=AB=E5=90=8D=E3=82=92MainFrame?= =?utf8?q?=E5=86=85=E3=81=AB=E4=BF=9D=E6=8C=81=E3=81=97=E3=81=A6=E3=81=8A?= =?utf8?q?=E3=81=8F=E3=82=88=E3=81=86=E5=A4=89=E6=9B=B4=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/tpi/tpi@77 9df91469-1e22-0410-86e7-ea8537beb833 --- src/frontend/cls_filedroptarget.cpp | 2 +- src/frontend/dlg_make.cpp | 7 ++--- src/frontend/frm_main.cpp | 61 ++++++++++++++++--------------------- src/frontend/frm_main.h | 3 +- src/frontend/frontend.cpp | 7 +++-- 5 files changed, 37 insertions(+), 43 deletions(-) diff --git a/src/frontend/cls_filedroptarget.cpp b/src/frontend/cls_filedroptarget.cpp index c3f26ef..817f10a 100644 --- a/src/frontend/cls_filedroptarget.cpp +++ b/src/frontend/cls_filedroptarget.cpp @@ -45,7 +45,7 @@ bool myFileDropTarget::OnDropFiles(wxCoord, wxCoord, const wxArrayString & asFil if (asFiles.Count() == 1 && this->mainFrame->LoadTPI(asFiles[0]) != -1) { // ‘ŒÉ‚ðŠJ‚­B - e.SetString(asFiles[0]); + this->mainFrame->fnArchive = wxFileName(asFiles[0]); this->mainFrame->OnArcOpen(e); return true; } diff --git a/src/frontend/dlg_make.cpp b/src/frontend/dlg_make.cpp index 1cfafc6..c2dfa31 100644 --- a/src/frontend/dlg_make.cpp +++ b/src/frontend/dlg_make.cpp @@ -115,9 +115,8 @@ void MakeDialog::OnInit(wxInitDialogEvent&) this->tcComment->SetEditable(false); // ‰Šú’l‚ðÝ’èB - 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()); // “WŠJæ‚ð—\‘ªB‚½‚¾‚µDTVƒXƒLƒƒƒ“‚ÉŽžŠÔ‚ª‚©‚©‚éê‡‚̓XƒLƒbƒv‰Â”\B 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&) diff --git a/src/frontend/frm_main.cpp b/src/frontend/frm_main.cpp index 3180898..d7511e1 100644 --- a/src/frontend/frm_main.cpp +++ b/src/frontend/frm_main.cpp @@ -202,9 +202,8 @@ void MainFrame::OnInit(wxInitDialogEvent&) } // ‘ŒÉ‚ðŠJ‚­B - 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()); // ‘ŒÉ–¼‚̓tƒ@ƒCƒ‹–¼‚ÌŠg’£Žq‚æ‚è‘OA‚à‚µ‚­‚̓fƒBƒŒƒNƒgƒŠ–¼B - 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()); // ƒ_ƒCƒAƒƒO‚ð•\Ž¦B if (mkDlg.ShowModal() == wxID_CANCEL) @@ -300,10 +302,8 @@ void MainFrame::OnArcCreate(wxCommandEvent& e) // TPI‚ð“ǂݍž‚݁B 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) } // I—¹‚µ‚È‚¢ê‡‚͏‘ŒÉ‚ðŠJ‚­B - e.SetString(fnArchive.GetFullPath()); this->OnArcOpen(e); } void MainFrame::OnArcOpen(wxCommandEvent& e) { // ‘ŒÉ‚ð‘I‘ðB - 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()); // ‘ŒÉ‚ðŠJ‚­B - 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) // ƒXƒe[ƒ^ƒXƒo[Ý’èB 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); // ƒc[ƒ‹ƒo[Eƒƒjƒ…[ƒo[Ý’èB 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); // ‘ŒÉ‚ðÄ“ǂݍž‚݁B - e.SetString(szArcName); this->OnArcOpen(e); } @@ -584,8 +580,7 @@ void MainFrame::OnArcConvert(wxCommandEvent& e) swInfo.fMakeSFX = e.GetId() == XRCID("Arc_SFX"); // •Û‘¶æ‚ðq‚Ë‚éB - 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("-----")) { // ‘ŒÉƒ‹[ƒg‚Ì‚Æ‚«‚͏‘ŒÉ–¼‚É‚µ‚Ä‚¨‚­B - 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) // •K—v‚Ȃ珑ŒÉ–¼‚ŃfƒBƒŒƒNƒgƒŠ‚ðì¬‚·‚éB 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) // ŠeŽíÝ’èB 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); // ‘ŒÉ‚ðÄ“ǂݍž‚Ý‚·‚éB - 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&) // ƒCƒxƒ“ƒgƒnƒ“ƒhƒ‰ˆÈŠOB -int MainFrame::LoadTPI(wxString & szFileName) +int MainFrame::LoadTPI(wxString szFileName) { // TPI‚ð“ǂݍž‚݁B wxFileSystem fs; diff --git a/src/frontend/frm_main.h b/src/frontend/frm_main.h index d107019..e577ee2 100644 --- a/src/frontend/frm_main.h +++ b/src/frontend/frm_main.h @@ -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(); diff --git a/src/frontend/frontend.cpp b/src/frontend/frontend.cpp index 849ae95..7835e61 100644 --- a/src/frontend/frontend.cpp +++ b/src/frontend/frontend.cpp @@ -39,16 +39,17 @@ bool Frontend::OnInit() wxInitAllImageHandlers(); ::wxXmlResource::Get()->InitAllHandlers(); - MainFrame * frm_main = new MainFrame(); - // ì‹ÆƒpƒX‚ðÝ’èB + 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); -- 2.11.0