ISOFile/GameFile: Simplify IsElfOrDol
This commit is contained in:
parent
f33a9ed439
commit
4249d9ef77
|
@ -243,17 +243,8 @@ void GameFile::SaveToCache()
|
||||||
|
|
||||||
bool GameFile::IsElfOrDol() const
|
bool GameFile::IsElfOrDol() const
|
||||||
{
|
{
|
||||||
const std::string name = m_file_name.toStdString();
|
return m_file_name.endsWith(QStringLiteral(".elf"), Qt::CaseInsensitive) ||
|
||||||
const size_t pos = name.rfind('.');
|
m_file_name.endsWith(QStringLiteral(".dol"), Qt::CaseInsensitive);
|
||||||
|
|
||||||
if (pos != std::string::npos)
|
|
||||||
{
|
|
||||||
std::string ext = name.substr(pos);
|
|
||||||
std::transform(ext.begin(), ext.end(), ext.begin(), ::tolower);
|
|
||||||
|
|
||||||
return ext == ".elf" || ext == ".dol";
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString GameFile::CreateCacheFilename() const
|
QString GameFile::CreateCacheFilename() const
|
||||||
|
|
|
@ -216,15 +216,12 @@ void GameListItem::DoState(PointerWrap &p)
|
||||||
|
|
||||||
bool GameListItem::IsElfOrDol() const
|
bool GameListItem::IsElfOrDol() const
|
||||||
{
|
{
|
||||||
const size_t pos = m_FileName.rfind('.');
|
if (m_FileName.size() < 4)
|
||||||
if (pos != std::string::npos)
|
return false;
|
||||||
{
|
|
||||||
std::string ext = m_FileName.substr(pos);
|
|
||||||
std::transform(ext.begin(), ext.end(), ext.begin(), ::tolower);
|
|
||||||
|
|
||||||
return ext == ".elf" || ext == ".dol";
|
std::string name_end = m_FileName.substr(m_FileName.size() - 4);
|
||||||
}
|
std::transform(name_end.begin(), name_end.end(), name_end.begin(), ::tolower);
|
||||||
return false;
|
return name_end == ".elf" || name_end == ".dol";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string GameListItem::CreateCacheFilename() const
|
std::string GameListItem::CreateCacheFilename() const
|
||||||
|
|
Loading…
Reference in New Issue