Patch level :

Files correlati     :
Ricompilazione Demo : [ ]
Commento            :


git-svn-id: svn://10.65.10.50/trunk@16997 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
luca 2008-08-04 14:43:54 +00:00
parent 4376d3d92d
commit 504aee7f31

View File

@ -45,12 +45,12 @@ void UpdateFrame::OnErase(wxEraseEvent& e)
const int k = nHeight / 16 + 1;
dc.SetTextForeground(c2);
dc.DrawText(APPNAME, k, k);
dc.DrawText("Tower", k, k);
dc.SetTextForeground(c1);
dc.DrawText(APPNAME, k/2, k/2);
dc.DrawText("Tower", k/2, k/2);
int w, h;
const wxString strSetup = wxT("Update");
const wxString strSetup = wxT("Backup");
dc.GetTextExtent(strSetup, &w, &h);
dc.SetTextForeground(c2);
@ -65,6 +65,8 @@ UpdateFrame::UpdateFrame()
ShowFullScreen(true);
}
WX_DECLARE_STRING_HASH_MAP( int, HashMap );
///////////////////////////////////////////////////////////
// UpdateExternal
///////////////////////////////////////////////////////////
@ -82,8 +84,9 @@ protected:
void OnTimer(wxTimerEvent& e);
//metodi di utility per i vari modi di aggiornamento
void CopyDir(const wxString& strSourcePath, const wxString& strDestPath, const wxString strModule) const;
bool CheckAndCopyFile(const wxString& FilesListI, wxString strFileCurr) const;
void CopyDir(const wxString& strSourcePath, const wxString& strDestPath, const wxString& strModule,
HashMap& hmBadExt, wxArrayString& asBadDir) const;
bool CheckAndCopyFile(const wxString& FilesListI, wxString strFileCurr, HashMap& hmBadExt, wxArrayString& asBadDir) const;
public:
virtual bool OnInit();
@ -115,7 +118,8 @@ static int PatchCompare(const wxString& first, const wxString& second)
}
bool UpdateExternal::CheckAndCopyFile(const wxString& FilesListI, wxString strFileCurr) const
bool UpdateExternal::CheckAndCopyFile(const wxString& FilesListI, wxString strFileCurr,
HashMap& hmBadExt, wxArrayString& asBadDir) const
{
bool ok = true;
strFileCurr.MakeLower(); //minuscolizzazione di sicurezza
@ -123,8 +127,20 @@ bool UpdateExternal::CheckAndCopyFile(const wxString& FilesListI, wxString strFi
//NON copiare i sorgenti cocco!!
const wxString strExt = strFileName.GetExt();
if (strExt != "cpp" && strExt != "c" && strExt != "src" && strFileCurr.Find("\\cvs\\") < 0 )
//if (strFileCurr.Find("/cvs/") < 0 && strFileCurr.Find("/modf24/") < 0 )
if (hmBadExt[strExt] == 0)
{
//e nemmeno le directory personali o inutili!
size_t nBadDirItems = asBadDir.GetCount();
for (size_t i = 0; i < nBadDirItems; i++)
{
wxString strBadDir = asBadDir[i];
int nFound = strFileCurr.Find(strBadDir);
if (nFound >= 0)
return ok; // salta sottocartella proibita
}
//eventuali sottodirectory le crea (solo se hanno un nome)
const wxString strDir = strFileName.GetPath();
if (!strDir.IsEmpty() && !wxDirExists(strDir))
@ -156,7 +172,8 @@ bool UpdateExternal::CheckAndCopyFile(const wxString& FilesListI, wxString strFi
}
//metodo per copiare una directory e tutti i files che contiene
void UpdateExternal::CopyDir(const wxString& strSrc, const wxString& strDest, const wxString strModule) const
void UpdateExternal::CopyDir(const wxString& strSrc, const wxString& strDest, const wxString& strModule,
HashMap& hmBadExt, wxArrayString& asBadDir) const
{
wxArrayString asList;
const size_t uFilesToCopy = wxDir::GetAllFiles(strSrc + strModule, &asList);
@ -174,7 +191,7 @@ void UpdateExternal::CopyDir(const wxString& strSrc, const wxString& strDest, co
if (!strFileCurr.IsEmpty())
{
if (!CheckAndCopyFile(asList[i], strFileCurr))
if (!CheckAndCopyFile(asList[i], strFileCurr, hmBadExt, asBadDir))
break;
}
}
@ -185,15 +202,56 @@ void UpdateExternal::CopyDir(const wxString& strSrc, const wxString& strDest, co
//metodo principale che sceglie la modalita' di lancio del programma
void UpdateExternal::OnTimer(wxTimerEvent& WXUNUSED(e))
{
//copia dei files sulla dir di destinazione
const wxString strDestPath = "Z:\\";
const wxString strSrcPath = "C:\\U\\Luca\\R_10_00\\";
const wxString strCurrDir = wxGetCwd();
const wxString strIniName = strCurrDir + "\\update.ini";
wxString strSrcPath;
wxString strDestPath;
CopyDir(strSrcPath, strDestPath, "include");
CopyDir(strSrcPath, strDestPath, "lib");
CopyDir(strSrcPath, strDestPath, "ba");
CopyDir(strSrcPath, strDestPath, "cg");
CopyDir(strSrcPath, strDestPath, "ve");
//legge il file di configurazione per sapere i path di origine e destinazione (tra {} x poterlo chiudere subito)
{
CampoIniFile UpdateIni(strIniName, "path");
strSrcPath = UpdateIni.Get("origine");
strDestPath = UpdateIni.Get("destinazione");
}
//array con le estensioni proibite
HashMap hmBadExt;
{
CampoIniFile UpdateExt(strIniName, "badext");
wxString strWrk;
long nIndex;
wxString strBadExt;
for (bool ok = UpdateExt.GetFirstEntry(strWrk, nIndex); ok; ok = UpdateExt.GetNextEntry(strWrk, nIndex))
{
strBadExt = UpdateExt.Get(strWrk);
hmBadExt[strBadExt] = 1;
}
}
//array con le directory proibite
wxArrayString asBadDir;
{
CampoIniFile UpdateDir(strIniName, "baddir");
wxString strWrk;
long nIndex;
wxString strBadDir;
for (bool ok = UpdateDir.GetFirstEntry(strWrk, nIndex); ok; ok = UpdateDir.GetNextEntry(strWrk, nIndex))
{
strBadDir = UpdateDir.Get(strWrk);
asBadDir.Add(strBadDir);
}
}
//legge il file di configurazione per avere l'elenco delle directory da copiare e le copia finche ce n'e'!
CampoIniFile UpdateDirs(strIniName, "dirs");
wxString strWrk;
long nIndex;
wxString strNomeDir;
for (bool ok = UpdateDirs.GetFirstEntry(strWrk, nIndex); ok; ok = UpdateDirs.GetNextEntry(strWrk, nIndex))
{
strNomeDir = UpdateDirs.Get(strWrk);
CopyDir(strSrcPath, strDestPath, strNomeDir, hmBadExt, asBadDir);
}
m_pMainFrame->Destroy();
}