mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-04-21 03:55:32 +00:00
Qt: use QDirIterator instead of fs::file stuff
This commit is contained in:
parent
68bb1bd6ee
commit
e7a02f1506
3 changed files with 31 additions and 36 deletions
|
@ -832,17 +832,18 @@ bool game_list_frame::DeleteShadersCache(const std::string& base_dir, bool is_in
|
|||
if (is_interactive && QMessageBox::question(this, tr("Confirm Delete"), tr("Delete shaders cache?")) != QMessageBox::Yes)
|
||||
return false;
|
||||
|
||||
fs::dir root = fs::dir(base_dir);
|
||||
fs::dir_entry tmp;
|
||||
|
||||
while (root.read(tmp))
|
||||
{
|
||||
if (!fs::is_dir(base_dir + "/" + tmp.name))
|
||||
continue;
|
||||
|
||||
const std::string shader_cache_name = base_dir + "/" + tmp.name + "/shaders_cache";
|
||||
if (fs::is_dir(shader_cache_name))
|
||||
fs::remove_all(shader_cache_name, true);
|
||||
QDirIterator dir_iter(qstr(base_dir), 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())
|
||||
LOG_NOTICE(GENERAL, "Removed shaders cache dir: %s", sstr(filepath));
|
||||
else
|
||||
LOG_WARNING(GENERAL, "Could not remove shaders cache file: %s", sstr(filepath));
|
||||
}
|
||||
}
|
||||
|
||||
LOG_SUCCESS(GENERAL, "Removed shaders cache in %s", base_dir);
|
||||
|
@ -857,21 +858,21 @@ bool game_list_frame::DeleteLLVMCache(const std::string& base_dir, bool is_inter
|
|||
if (is_interactive && QMessageBox::question(this, tr("Confirm Delete"), tr("Delete LLVM cache?")) != QMessageBox::Yes)
|
||||
return false;
|
||||
|
||||
for (auto&& subdir : fs::dir{ base_dir })
|
||||
{
|
||||
if (!subdir.is_directory || subdir.name == "." || subdir.name == "..")
|
||||
continue;
|
||||
|
||||
const std::string dir = base_dir + "/" + subdir.name;
|
||||
|
||||
for (auto&& entry : fs::dir{ dir })
|
||||
{
|
||||
if (entry.name.size() >= 4 && entry.name.compare(entry.name.size() - 4, 4, ".obj", 4) == 0)
|
||||
fs::remove_file(dir + "/" + entry.name);
|
||||
}
|
||||
QDirIterator dir_iter(qstr(base_dir), QDir::Files | QDir::NoDotAndDotDot, QDirIterator::Subdirectories);
|
||||
while (dir_iter.hasNext())
|
||||
{
|
||||
const QString filepath = dir_iter.next();
|
||||
|
||||
if (dir_iter.fileInfo().absoluteFilePath().endsWith(".obj", Qt::CaseInsensitive))
|
||||
{
|
||||
if (QFile::remove(filepath))
|
||||
LOG_NOTICE(GENERAL, "Removed LLVM cache file: %s", sstr(filepath));
|
||||
else
|
||||
LOG_WARNING(GENERAL, "Could not remove LLVM cache file: %s", sstr(filepath));
|
||||
}
|
||||
}
|
||||
|
||||
LOG_SUCCESS(GENERAL, "Removed llvm cache in %s", base_dir);
|
||||
LOG_SUCCESS(GENERAL, "Removed LLVM cache in %s", base_dir);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -1620,7 +1620,8 @@ Add valid disc games to gamelist (games.yml)
|
|||
*/
|
||||
void main_window::AddGamesFromDir(const QString& path)
|
||||
{
|
||||
if (!QFileInfo(path).isDir()) return;
|
||||
if (!QFileInfo(path).isDir())
|
||||
return;
|
||||
|
||||
const std::string s_path = sstr(path);
|
||||
|
||||
|
@ -1631,13 +1632,10 @@ void main_window::AddGamesFromDir(const QString& path)
|
|||
}
|
||||
|
||||
// search direct subdirectories, that way we can drop one folder containing all games
|
||||
for (const auto& entry : fs::dir(s_path))
|
||||
QDirIterator dir_iter(path, QDir::Dirs | QDir::NoDotAndDotDot);
|
||||
while (dir_iter.hasNext())
|
||||
{
|
||||
if (entry.name == "." || entry.name == "..") continue;
|
||||
|
||||
const std::string pth = s_path + "/" + entry.name;
|
||||
|
||||
if (!QFileInfo(qstr(pth)).isDir()) continue;
|
||||
std::string pth = sstr(dir_iter.next());
|
||||
|
||||
if (Emu.BootGame(pth, false, true))
|
||||
{
|
||||
|
|
|
@ -111,14 +111,10 @@ trophy_manager_dialog::trophy_manager_dialog(std::shared_ptr<gui_settings> gui_s
|
|||
m_splitter->addWidget(m_trophy_table);
|
||||
|
||||
// Populate the trophy database
|
||||
QDirIterator dir_iter(qstr(vfs::get(m_TROPHY_DIR)));
|
||||
QDirIterator dir_iter(qstr(vfs::get(m_TROPHY_DIR)), QDir::Dirs | QDir::NoDotAndDotDot);
|
||||
while (dir_iter.hasNext())
|
||||
{
|
||||
dir_iter.next();
|
||||
if (dir_iter.fileName() == "." || dir_iter.fileName() == ".." || dir_iter.fileName() == ".gitignore")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
std::string dirName = sstr(dir_iter.fileName());
|
||||
LOG_TRACE(GENERAL, "Loading trophy dir: %s", dirName);
|
||||
LoadTrophyFolderToDB(dirName);
|
||||
|
|
Loading…
Add table
Reference in a new issue