From 4fedd91570f37a54f923a3f33d0a028d54d11185 Mon Sep 17 00:00:00 2001 From: Patrick McIlroy Date: Wed, 13 Feb 2008 03:58:33 +0000 Subject: [PATCH] git-svn-id: https://openitg.svn.sourceforge.net/svnroot/openitg@10 83fadc84-e282-4d84-a09a-c4228d6ae7e5 --- src/ScreenArcadePatch.cpp | 35 ++++++++++++++++++++++++++++++++--- src/ScreenArcadePatch.h | 2 ++ 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/src/ScreenArcadePatch.cpp b/src/ScreenArcadePatch.cpp index 5207fbc7..40468e9a 100644 --- a/src/ScreenArcadePatch.cpp +++ b/src/ScreenArcadePatch.cpp @@ -14,6 +14,8 @@ #include "RageFileManager.h" #include "RageFileDriverSlice.h" #include "CryptHelpers.h" +#include "RageFileDriverZip.h" +#include "XmlFile.h" #include "Foreach.h" // Foreach loops without the command is hard. #include "MemoryCardManager.h" // Where else are we getting the patch from? @@ -114,7 +116,7 @@ bool ScreenArcadePatch::CommitPatch() if( CheckSignature() ) if( CheckXml() ) { - m_Status.SetText("Success!"); + m_Status.SetText(m_sSuccessMsg); return true; } } @@ -237,12 +239,39 @@ bool ScreenArcadePatch::CheckSignature() } m_Status.SetText( "Patch signature verified :)" ); - return false; + return true; } bool ScreenArcadePatch::CheckXml() { + CString sErr, sResultMessage; + int iErr; + unsigned filesize; + RageFileBasic *fRoot, *fScl, *fXml; + RageFileDriverZip *rfdZip = new RageFileDriverZip; + XNode *rNode = new XNode; + + fRoot = FILEMAN->Open( Root, RageFile::READ, iErr ); + filesize = GetFileSizeInBytes( Root ) - 128; + fScl = new RageFileDriverSlice( fRoot, 0, filesize ); + + + if (! rfdZip->Load(fScl)) { + m_Status.SetText( "Patch XML data check failed" ); + return false; + } + + fXml = rfdZip->Open("patch.xml", RageFile::READ, iErr ); + + if (fXml == NULL) { + m_Status.SetText( "Could not open patch.xml" ); + return false; + } + + rNode->m_sName = "Patch"; + rNode->LoadFromFile(*fXml); + m_sSuccessMsg = rNode->GetChildValue("Message"); + return true; } - diff --git a/src/ScreenArcadePatch.h b/src/ScreenArcadePatch.h index 57d5047c..40f1a259 100644 --- a/src/ScreenArcadePatch.h +++ b/src/ScreenArcadePatch.h @@ -38,6 +38,8 @@ private: CString Type; CString Root; + + CString m_sSuccessMsg; RageFile fPatch; -- 2.11.0