Fix XML loading not handling UTF-8 paths

This commit is contained in:
Silent 2020-09-13 19:57:35 +02:00
parent 8d5a6acfc7
commit a35a2838b6
No known key found for this signature in database
GPG key ID: AE53149BB0C45AF1

View file

@ -740,8 +740,12 @@ void GameList::LoadDatabase()
if (m_database_filename.empty())
return;
auto fp = FileSystem::OpenManagedCFile(m_database_filename.c_str(), "rb");
if (!fp)
return;
tinyxml2::XMLDocument doc;
tinyxml2::XMLError error = doc.LoadFile(m_database_filename.c_str());
tinyxml2::XMLError error = doc.LoadFile(fp.get());
if (error != tinyxml2::XML_SUCCESS)
{
Log_ErrorPrintf("Failed to parse redump dat '%s': %s", m_database_filename.c_str(),
@ -858,8 +862,12 @@ void GameList::LoadCompatibilityList()
if (m_compatibility_list_filename.empty())
return;
auto fp = FileSystem::OpenManagedCFile(m_compatibility_list_filename.c_str(), "rb");
if (!fp)
return;
tinyxml2::XMLDocument doc;
tinyxml2::XMLError error = doc.LoadFile(m_compatibility_list_filename.c_str());
tinyxml2::XMLError error = doc.LoadFile(fp.get());
if (error != tinyxml2::XML_SUCCESS)
{
Log_ErrorPrintf("Failed to parse compatibility list '%s': %s", m_compatibility_list_filename.c_str(),
@ -989,11 +997,12 @@ bool GameList::SaveCompatibilityDatabaseForEntry(const GameListCompatibilityEntr
if (m_compatibility_list_filename.empty())
return false;
if (!FileSystem::FileExists(m_compatibility_list_filename.c_str()))
auto fp = FileSystem::OpenManagedCFile(m_compatibility_list_filename.c_str(), "rb");
if (!fp)
return SaveCompatibilityDatabase();
tinyxml2::XMLDocument doc;
tinyxml2::XMLError error = doc.LoadFile(m_compatibility_list_filename.c_str());
tinyxml2::XMLError error = doc.LoadFile(fp.get());
if (error != tinyxml2::XML_SUCCESS)
{
Log_ErrorPrintf("Failed to parse compatibility list '%s': %s", m_compatibility_list_filename.c_str(),