From 1c027bc148574cf0b05cd04f8ce15132e8115170 Mon Sep 17 00:00:00 2001 From: JosJuice Date: Fri, 1 Jun 2018 09:36:29 +0200 Subject: Use UICommon's game list code on Android Deduplicates code, and gets rid of some problems the old code had (such as: bad performance when calling native functions, only one disc showing up for multi-disc games, Wii banners being low-res, unnecessarily much effort being needed for adding more metadata). --- Source/Core/UICommon/GameFileCache.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'Source/Core/UICommon/GameFileCache.cpp') diff --git a/Source/Core/UICommon/GameFileCache.cpp b/Source/Core/UICommon/GameFileCache.cpp index 7a71ca75f1..074dc7fe62 100644 --- a/Source/Core/UICommon/GameFileCache.cpp +++ b/Source/Core/UICommon/GameFileCache.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include "Common/ChunkFile.h" @@ -38,12 +39,25 @@ std::vector FindAllGamePaths(const std::vector& direct return Common::DoFileSearch(directories_to_scan, search_extensions, recursive_scan); } +GameFileCache::GameFileCache() : m_path(File::GetUserPath(D_CACHE_IDX) + "gamelist.cache") +{ +} + +GameFileCache::GameFileCache(std::string path) : m_path(std::move(path)) +{ +} + void GameFileCache::ForEach(std::function&)> f) const { for (const std::shared_ptr& item : m_cached_files) f(item); } +size_t GameFileCache::GetSize() const +{ + return m_cached_files.size(); +} + void GameFileCache::Clear() { m_cached_files.clear(); @@ -179,9 +193,8 @@ bool GameFileCache::Save() bool GameFileCache::SyncCacheFile(bool save) { - std::string filename(File::GetUserPath(D_CACHE_IDX) + "gamelist.cache"); const char* open_mode = save ? "wb" : "rb"; - File::IOFile f(filename, open_mode); + File::IOFile f(m_path, open_mode); if (!f) return false; bool success = false; @@ -217,7 +230,7 @@ bool GameFileCache::SyncCacheFile(bool save) { // If some file operation failed, try to delete the probably-corrupted cache f.Close(); - File::Delete(filename); + File::Delete(m_path); } return success; } -- cgit v1.2.3