bool ScreenArcadePatch::GetXMLData( RageFileDriverZip *fZip, CString &sGame, CString &sMessage, int &iRevision ) { int iError; RageFileBasic *fXML = fZip->Open( "patch.xml", RageFile::READ, iError ); if( fXML == NULL ) { STATE_TEXT( "Patch information check failed: could not open patch.xml." ); return false; } /* check the actual XML data now */ XNode *pNode = new XNode; pNode->m_sName = "Patch"; pNode->LoadFromFile( *fXML ); if( !pNode->GetChild("Game") || !pNode->GetChild("Revision") || !pNode->GetChild("Message") ) { STATE_TEXT( "Patch information check failed: patch.xml is corrupt." ); SAFE_DELETE( pNode ); SAFE_DELETE( fXML ); return false; } /* save the patch data */ pNode->GetChild("Revision")->GetValue(iRevision); sGame = pNode->GetChildValue("Game"); sMessage = pNode->GetChildValue("Message"); SAFE_DELETE( pNode ); SAFE_DELETE( fXML ); return true; }
void TitleSubst::Load(const std::string &filename, const std::string §ion) { XNode xml; if( !XmlFileUtil::LoadFromFileShowErrors(xml,filename) ) { // LoadFromFile will show its own error //LOG->Trace("Error opening %s: %s", filename.c_str(), f.GetError().c_str() ); return; } XNode *pGroup = xml.GetChild( section ); if( pGroup == nullptr ) { return; } for (auto const *child: *pGroup) { if( child == nullptr || child->GetName() != "Translation" ) { continue; } TitleTrans tr; tr.LoadFromNode( child ); AddTrans(tr); } }
int DiagnosticsUtil::GetRevision() { // default value if a patch value can't be found/loaded int iRevision = 1; // Create the XML Handler, and clear it, for practice. XNode *xml = new XNode; xml->Clear(); xml->m_sName = "patch"; // if the file is readable and has the proper node, save its value if( !IsAFile(PATCH_XML_PATH) ) LOG->Warn( "GetRevision(): There is no patch file (patch.xml)" ); else if( !xml->LoadFromFile(PATCH_XML_PATH) ) LOG->Warn( "GetRevision(): Could not load from patch.xml" ); else if( !xml->GetChild("Revision") ) LOG->Warn( "GetRevision(): Revision node missing! (patch.xml)" ); else iRevision = atoi( xml->GetChild("Revision")->m_sValue ); SAFE_DELETE( xml ); return iRevision; }
int DiagnosticsUtil::GetNumMachineScores() { // Create the XML Handler and clear it, for practice XNode *xml = new XNode; xml->Clear(); // Check for the file existing if( !IsAFile(STATS_XML_PATH) ) { LOG->Warn( "There is no Stats.xml file!" ); SAFE_DELETE( xml ); return 0; } // Make sure you can read it if( !xml->LoadFromFile(STATS_XML_PATH) ) { LOG->Trace( "Stats.xml unloadable!" ); SAFE_DELETE( xml ); return 0; } const XNode *pData = xml->GetChild( "SongScores" ); if( pData == NULL ) { LOG->Warn( "Error loading scores: <SongScores> node missing" ); SAFE_DELETE( xml ); return 0; } unsigned int iScoreCount = 0; // Named here, for LoadFromFile() renames it to "Stats" xml->m_sName = "SongScores"; // For each pData Child, or the Child in SongScores... FOREACH_CONST_Child( pData , p ) iScoreCount++; SAFE_DELETE( xml ); return iScoreCount; }
bool PropertySet::XMLLoad(XNode *pBackupNode) { XNode *pPropertiesNode = pBackupNode->GetChild(_T("Properties")); if (!pPropertiesNode) return true; for (int i = 0; i < pPropertiesNode->GetChildCount(); i++) { XNode *pPropertyNode = pPropertiesNode->GetChild(i); String sName = pPropertyNode->name; String sStringValue = pPropertyNode->GetAttrValue(_T("StringValue")); int iLongValue = _ttoi(pPropertyNode->GetAttrValue(_T("LongValue"))); std::shared_ptr<Property> pProperty = GetProperty_(sName); if (pProperty) { pProperty->SetStringValue(sStringValue); pProperty->SetLongValue(iLongValue); } } return true; }