From 096a08aca12d4435262043d5b3ccca83595f2fb4 Mon Sep 17 00:00:00 2001 From: Megamouse Date: Sat, 28 Dec 2019 18:43:30 +0100 Subject: [PATCH] Qt: fix removal functions after cache compression --- rpcs3/rpcs3qt/game_list_frame.cpp | 66 ++++++++++++++----------------- 1 file changed, 30 insertions(+), 36 deletions(-) diff --git a/rpcs3/rpcs3qt/game_list_frame.cpp b/rpcs3/rpcs3qt/game_list_frame.cpp index bfc0d00e45..544a8370b8 100644 --- a/rpcs3/rpcs3qt/game_list_frame.cpp +++ b/rpcs3/rpcs3qt/game_list_frame.cpp @@ -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;