From 7ddd0a6317ca1cbd7e96116afb5829669848c4f8 Mon Sep 17 00:00:00 2001 From: luca Date: Wed, 5 Sep 2007 15:21:08 +0000 Subject: [PATCH] Patch level :4.0 setup Files correlati : Ricompilazione Demo : [ ] Commento :aggiunto unzippamento patch di sistema git-svn-id: svn://10.65.10.50/trunk@15585 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- setup/Setup.cpp | 120 +++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 109 insertions(+), 11 deletions(-) diff --git a/setup/Setup.cpp b/setup/Setup.cpp index 6ae2ca80a..792e4409d 100755 --- a/setup/Setup.cpp +++ b/setup/Setup.cpp @@ -9,10 +9,12 @@ #include #include #include +#include #include #include #include #include +#include #ifdef WIN32 #include @@ -1946,6 +1948,9 @@ protected: bool WriteLocalMachineRegistryKey(const wxString strKey, const wxString& strValue) const; void CheckAndMakeDir(const wxString& strDir, const wxString& strMsg) const; + bool UnzipFile(const char* strZipFile, const char* strDestdir) const; + size_t GetZipList(const char* strZipFile, wxArrayString& aFiles) const; + void UnzipSystem(const wxString& strPrgLocPath) const; public: virtual bool OnInit(); @@ -2158,7 +2163,7 @@ void CampoSetup::CheckAndMakeDir(const wxString& strDir, const wxString& strMsg) strCartella += asDirs[i]; if (!wxDir::Exists(strCartella) && !wxMkdir(strCartella)) { - wxString strError = "Impossibile creare la cartella dei "; + wxString strError = "Impossibile creare la cartella "; strError += strMsg; strError += " "; strError += strCartella; @@ -2168,11 +2173,100 @@ void CampoSetup::CheckAndMakeDir(const wxString& strDir, const wxString& strMsg) } } } - wxDir dirDir(strDir); - if(dirDir.HasFiles()) //se la dir di destinazione dovesse esistere gia' (installazione abortita) almeno sia vuota + if (!strMsg.IsEmpty()) //se il messaggio e' vuoto NON deve fare alcun controllo (installazione sistema) { - ErrorBox("La cartella di destinazione non e' vuota!\nInstallazione interrotta!"); - return; + wxDir dirDir(strDir); + if(dirDir.HasFiles()) //se la dir di destinazione dovesse esistere gia' (installazione abortita) almeno sia vuota + { + ErrorBox("La cartella di destinazione non e' vuota!\nInstallazione interrotta!"); + return; + } + } +} + +size_t CampoSetup::GetZipList(const char* strZipFile, wxArrayString& aFiles) const +{ + wxFFileInputStream fin(strZipFile); + wxZipInputStream zip(fin); + for (wxZipEntry* z = zip.GetNextEntry(); z; z = zip.GetNextEntry()) + { + const wxString str = z->GetInternalName(); + aFiles.Add(str); + } + + return aFiles.GetCount(); +} + +bool CampoSetup::UnzipFile(const char* strZipFile, const char* strDestDir) const +{ + wxArrayString aFiles; + const size_t files = GetZipList(strZipFile, aFiles); + + wxProgressDialog pi("Unzip", "", (int)files, NULL, wxPD_AUTO_HIDE | wxPD_APP_MODAL | wxPD_CAN_ABORT); + + for (unsigned int f = 0; f < files; f++) + { + const wxString& strFileName = aFiles[f]; + if (!pi.Update(f, strFileName)) + break; + + if (wxEndsWithPathSeparator(strFileName) || strFileName.Find('.') < 0) // Is dir name + { + wxString strOutDir = strDestDir; + if (!wxEndsWithPathSeparator(strOutDir)) + strOutDir += wxFILE_SEP_PATH; + strOutDir += strFileName; + if (!::wxDirExists(strOutDir)) + ::wxMkdir(strOutDir); + } + else + { + wxZipInputStream fin(strZipFile, strFileName); + + wxString strOutFile = strDestDir; + if (!wxEndsWithPathSeparator(strOutFile) && !wxIsPathSeparator(strFileName[0])) + strOutFile += wxFILE_SEP_PATH; + strOutFile += strFileName; + + wxString strPath; + ::wxSplitPath(strOutFile, &strPath, NULL, NULL); + CheckAndMakeDir(strPath, wxEmptyString); + + wxFileOutputStream fout(strOutFile); + fout.Write(fin); + } + } + return files > 0; +} + +static int PatchCompare(const wxString& first, const wxString& second) +{ + const wxFileName fn1(first); + const wxFileName fn2(second); + const wxString strName1 = fn1.GetName().Lower(); + const wxString strName2 = fn2.GetName().Lower(); + if (strName1 == "syinst1") + return -1; + if (strName2 == "syinst1") + return 1; + + return strName1.CompareTo(strName2); +} + +void CampoSetup::UnzipSystem(const wxString& strPrgLocPath) const +{ + wxArrayString asFilesList; + wxFileName strSourcePath(wxGetCwd(), "sy*.zip"); + strSourcePath.AppendDir(".."); + strSourcePath.AppendDir("program"); + strSourcePath.MakeAbsolute(); + //..contando anche quanti sono e memorizzandoli in un array asFileList + const size_t uFilesToCopy = wxDir::GetAllFiles(strSourcePath.GetPath(), &asFilesList, strSourcePath.GetFullName()); + //ordina le patch per numero crescente ma mette davanti a tutte il pacco (sysinst1) + asFilesList.Sort(PatchCompare); + for (size_t i = 0; i < uFilesToCopy; i++) + { + UnzipFile(asFilesList[i] , strPrgLocPath); } } @@ -2340,24 +2434,28 @@ void CampoSetup::OnTimer(wxTimerEvent& WXUNUSED(e)) if (bDesktopShortcut) CreateIcon(CSIDL_COMMON_DESKTOPDIRECTORY, strExe); - // 1) terminato il tutto scrive/aggiorna/lascia stare il campo.stp - if (bNewInstallation) - { - CampoIniFile CampoStp("C:\\campo.stp", ""); - } // 2) procede poi al caricamento delle patch eventuali di sistema all'interno della dir 'program' - //la procedura di unzippamento dovrebbe essere quella di ba1.exe + //copia del contenuto della cartella campo nella cartella di destinazione (installaz/aggiornam) + //per prima cosa cerca la cartella dei files sorgente... + UnzipSystem(strPrgLocPath); + // 3) riaggiorna eventualmente il livello versione/patch del SY in install.ini // 4) lanciare ba1.exe -6 in uscita (non va qui! e' solo per ricordarsi di farlo!) + // 1) terminato il tutto scrive/aggiorna/lascia stare il campo.stp + if (bNewInstallation) + { + CampoIniFile CampoStp("C:\\campo.stp", ""); + } } pWizard->Destroy(); ::wxMessageBox(wxT("Installazione terminata"), APPNAME, wxOK | wxICON_INFORMATION); m_pMainFrame->Destroy(); + } bool CampoSetup::OnInit()