Qt: fix removal functions after cache compression

This commit is contained in:
Megamouse 2019-12-28 18:43:30 +01:00
parent ef6f565dbd
commit 096a08aca1

View File

@ -1248,24 +1248,22 @@ bool game_list_frame::RemoveShadersCache(const std::string& base_dir, bool is_in
u32 caches_removed = 0;
u32 caches_total = 0;
QDirIterator dir_iter(qstr(base_dir), QDir::Dirs | QDir::NoDotAndDotDot, QDirIterator::Subdirectories);
QDirIterator dir_iter(qstr(base_dir), QStringList() << QStringLiteral("shaders_cache"), QDir::Dirs | QDir::NoDotAndDotDot, QDirIterator::Subdirectories);
while (dir_iter.hasNext())
{
const QString filepath = dir_iter.next();
if (dir_iter.fileName() == "shaders_cache")
if (QDir(filepath).removeRecursively())
{
if (QDir(filepath).removeRecursively())
{
++caches_removed;
LOG_NOTICE(GENERAL, "Removed shaders cache dir: %s", sstr(filepath));
}
else
{
LOG_WARNING(GENERAL, "Could not completely remove shaders cache dir: %s", sstr(filepath));
}
++caches_total;
++caches_removed;
LOG_NOTICE(GENERAL, "Removed shaders cache dir: %s", sstr(filepath));
}
else
{
LOG_WARNING(GENERAL, "Could not completely remove shaders cache dir: %s", sstr(filepath));
}
++caches_total;
}
const bool success = caches_total == caches_removed;
@ -1289,24 +1287,22 @@ bool game_list_frame::RemovePPUCache(const std::string& base_dir, bool is_intera
u32 files_removed = 0;
u32 files_total = 0;
QDirIterator dir_iter(qstr(base_dir), QDir::Files | QDir::NoDotAndDotDot, QDirIterator::Subdirectories);
QDirIterator dir_iter(qstr(base_dir), QStringList() << QStringLiteral("*.obj") << QStringLiteral("*.obj.gz"), QDir::Files | QDir::NoDotAndDotDot, QDirIterator::Subdirectories);
while (dir_iter.hasNext())
{
const QString filepath = dir_iter.next();
if (QString::compare(dir_iter.fileInfo().suffix(), QStringLiteral("obj"), Qt::CaseInsensitive) == 0)
if (QFile::remove(filepath))
{
if (QFile::remove(filepath))
{
++files_removed;
LOG_NOTICE(GENERAL, "Removed PPU cache file: %s", sstr(filepath));
}
else
{
LOG_WARNING(GENERAL, "Could not remove PPU cache file: %s", sstr(filepath));
}
++files_total;
++files_removed;
LOG_NOTICE(GENERAL, "Removed PPU cache file: %s", sstr(filepath));
}
else
{
LOG_WARNING(GENERAL, "Could not remove PPU cache file: %s", sstr(filepath));
}
++files_total;
}
const bool success = files_total == files_removed;
@ -1330,24 +1326,22 @@ bool game_list_frame::RemoveSPUCache(const std::string& base_dir, bool is_intera
u32 files_removed = 0;
u32 files_total = 0;
QDirIterator dir_iter(qstr(base_dir), QDir::Files | QDir::NoDotAndDotDot, QDirIterator::Subdirectories);
QDirIterator dir_iter(qstr(base_dir), QStringList() << QStringLiteral("*.dat") << QStringLiteral("*.dat.gz"), QDir::Files | QDir::NoDotAndDotDot, QDirIterator::Subdirectories);
while (dir_iter.hasNext())
{
const QString filepath = dir_iter.next();
if (QString::compare(dir_iter.fileInfo().suffix(), QStringLiteral("dat"), Qt::CaseInsensitive) == 0)
if (QFile::remove(filepath))
{
if (QFile::remove(filepath))
{
++files_removed;
LOG_NOTICE(GENERAL, "Removed SPU cache file: %s", sstr(filepath));
}
else
{
LOG_WARNING(GENERAL, "Could not remove SPU cache file: %s", sstr(filepath));
}
++files_total;
++files_removed;
LOG_NOTICE(GENERAL, "Removed SPU cache file: %s", sstr(filepath));
}
else
{
LOG_WARNING(GENERAL, "Could not remove SPU cache file: %s", sstr(filepath));
}
++files_total;
}
const bool success = files_total == files_removed;