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
This commit is contained in:
parent
196a02f344
commit
7ddd0a6317
112
setup/Setup.cpp
112
setup/Setup.cpp
@ -9,10 +9,12 @@
|
||||
#include <wx/gbsizer.h>
|
||||
#include <wx/html/htmlwin.h>
|
||||
#include <wx/mimetype.h>
|
||||
#include <wx/progdlg.h>
|
||||
#include <wx/radiobox.h>
|
||||
#include <wx/txtstrm.h>
|
||||
#include <wx/wfstream.h>
|
||||
#include <wx/wizard.h>
|
||||
#include <wx/zipstrm.h>
|
||||
|
||||
#ifdef WIN32
|
||||
#include <shlobj.h>
|
||||
@ -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,6 +2173,8 @@ void CampoSetup::CheckAndMakeDir(const wxString& strDir, const wxString& strMsg)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!strMsg.IsEmpty()) //se il messaggio e' vuoto NON deve fare alcun controllo (installazione sistema)
|
||||
{
|
||||
wxDir dirDir(strDir);
|
||||
if(dirDir.HasFiles()) //se la dir di destinazione dovesse esistere gia' (installazione abortita) almeno sia vuota
|
||||
{
|
||||
@ -2175,6 +2182,93 @@ void CampoSetup::CheckAndMakeDir(const wxString& strDir, const wxString& strMsg)
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
//metodo principale dell'applicazione che gestisce l'ordine degli eventi nella installazione vera e propria
|
||||
void CampoSetup::OnTimer(wxTimerEvent& WXUNUSED(e))
|
||||
@ -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()
|
||||
|
Loading…
x
Reference in New Issue
Block a user