diff options
| author | JosJuice <josjuice@gmail.com> | 2018-06-08 13:59:45 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-06-08 13:59:45 +0200 |
| commit | ca3d68cee581435217fe737390a9fed833ac3338 (patch) | |
| tree | 2cf04a27469dd2955e4b1dc2facd7b64ee00fb66 /Source/Core/UICommon/GameFileCache.cpp | |
| parent | d23c3e9524e9f5aa312fae5d320f5866bb721a8a (diff) | |
| parent | f0f8ca21723470c859b58291144b7913dfae3906 (diff) | |
Merge pull request #7076 from JosJuice/android-gamelist-uicommon
Use UICommon's game list code on Android
Diffstat (limited to 'Source/Core/UICommon/GameFileCache.cpp')
| -rw-r--r-- | Source/Core/UICommon/GameFileCache.cpp | 19 |
1 files changed, 16 insertions, 3 deletions
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 <mutex> #include <string> #include <unordered_set> +#include <utility> #include <vector> #include "Common/ChunkFile.h" @@ -38,12 +39,25 @@ std::vector<std::string> FindAllGamePaths(const std::vector<std::string>& 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<void(const std::shared_ptr<const GameFile>&)> f) const { for (const std::shared_ptr<const GameFile>& 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; } |
