diff --git a/src/IniFile.cpp b/src/IniFile.cpp index ae84b482f8..62da670571 100644 --- a/src/IniFile.cpp +++ b/src/IniFile.cpp @@ -49,6 +49,7 @@ bool IniFile::ReadFile( RageFileBasic &f ) { case -1: m_sError = f.GetError(); + LOG->Warn("Error reading line in file '%s': %s", m_sPath.c_str(), m_sError.c_str()); return false; case 0: return true; // eof @@ -107,6 +108,11 @@ bool IniFile::ReadFile( RageFileBasic &f ) SetKeyValue(keychild, valuename, value); } } + else + { + LOG->Warn("No '=' found in line of file '%s': %s", m_sPath.c_str(), line.c_str()); + } + break; } } @@ -135,6 +141,7 @@ bool IniFile::WriteFile( RageFileBasic &f ) const if( f.PutLine( ssprintf("[%s]", pKey->GetName().c_str()) ) == -1 ) { m_sError = f.GetError(); + LOG->Warn( "Error when writing key to file '%s': %s", m_sPath.c_str(), m_sError.c_str() ); return false; } @@ -151,6 +158,7 @@ bool IniFile::WriteFile( RageFileBasic &f ) const if( f.PutLine( ssprintf("%s=%s", sName.c_str(), sValue.c_str()) ) == -1 ) { m_sError = f.GetError(); + LOG->Warn( "Error when writing attribute: %s", m_sError.c_str() ); return false; } } @@ -158,6 +166,7 @@ bool IniFile::WriteFile( RageFileBasic &f ) const if( f.PutLine( "" ) == -1 ) { m_sError = f.GetError(); + LOG->Warn( "Error when writing newline: %s", m_sError.c_str() ); return false; } } @@ -167,18 +176,33 @@ bool IniFile::WriteFile( RageFileBasic &f ) const bool IniFile::DeleteValue(const RString &keyname, const RString &valuename) { XNode* pNode = GetChild( keyname ); - if( pNode == nullptr ) + if ( pNode == nullptr ) + { + LOG->Warn("Key '%s' not found when attempting to delete a value.", keyname.c_str()); return false; - return pNode->RemoveAttr( valuename ); + } + bool result = pNode->RemoveAttr(valuename); + if (!result) + { + LOG->Warn("Value '%s' not found in key '%s'.", valuename.c_str(), keyname.c_str()); + } + return result; } - bool IniFile::DeleteKey(const RString &keyname) { XNode* pNode = GetChild( keyname ); if( pNode == nullptr ) + { + LOG->Warn("Key '%s' not found when attempting to delete a key.", keyname.c_str()); return false; - return RemoveChild( pNode ); + } + bool result = RemoveChild(pNode); + if (!result) + { + LOG->Warn("Error removing key '%s'.", keyname.c_str()); + } + return result; } bool IniFile::RenameKey(const RString &from, const RString &to) @@ -189,7 +213,10 @@ bool IniFile::RenameKey(const RString &from, const RString &to) XNode* pNode = GetChild( from ); if( pNode == nullptr ) + { + LOG->Warn("Key '%s' not found.", from.c_str()); return false; + } pNode->SetName( to ); RenameChildInByName(pNode); @@ -197,7 +224,6 @@ bool IniFile::RenameKey(const RString &from, const RString &to) return true; } - /* * (c) 2001-2004 Adam Clauss, Chris Danford * All rights reserved.