2017-12-31 19:33:36 +00:00
|
|
|
// Copyright 2017 Dolphin Emulator Project
|
|
|
|
// Licensed under GPLv2+
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <cstddef>
|
|
|
|
#include <functional>
|
|
|
|
#include <list>
|
|
|
|
#include <memory>
|
|
|
|
#include <mutex>
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include "Common/CommonTypes.h"
|
|
|
|
|
|
|
|
class PointerWrap;
|
|
|
|
|
|
|
|
namespace UICommon
|
|
|
|
{
|
|
|
|
class GameFile;
|
|
|
|
|
|
|
|
std::vector<std::string> FindAllGamePaths(const std::vector<std::string>& directories_to_scan,
|
|
|
|
bool recursive_scan);
|
|
|
|
|
|
|
|
class GameFileCache
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
void ForEach(std::function<void(const std::shared_ptr<const GameFile>&)> f) const;
|
|
|
|
|
|
|
|
void Clear();
|
|
|
|
|
2018-03-29 19:52:21 +00:00
|
|
|
// Returns nullptr if the file is invalid.
|
2018-06-03 10:07:53 +00:00
|
|
|
std::shared_ptr<const GameFile> AddOrGet(const std::string& path, bool* cache_changed);
|
2017-12-31 19:33:36 +00:00
|
|
|
|
|
|
|
// These functions return true if the call modified the cache.
|
2018-05-26 16:22:14 +00:00
|
|
|
bool Update(const std::vector<std::string>& all_game_paths,
|
|
|
|
std::function<void(const std::shared_ptr<const GameFile>&)> game_added_to_cache = {},
|
|
|
|
std::function<void(const std::string&)> game_removed_from_cache = {});
|
|
|
|
bool UpdateAdditionalMetadata(
|
|
|
|
std::function<void(const std::shared_ptr<const GameFile>&)> game_updated = {});
|
2017-12-31 19:33:36 +00:00
|
|
|
|
|
|
|
bool Load();
|
|
|
|
bool Save();
|
|
|
|
|
|
|
|
private:
|
2018-06-03 10:07:53 +00:00
|
|
|
bool UpdateAdditionalMetadata(std::shared_ptr<GameFile>* game_file);
|
2017-12-31 19:33:36 +00:00
|
|
|
|
|
|
|
bool SyncCacheFile(bool save);
|
|
|
|
void DoState(PointerWrap* p, u64 size = 0);
|
|
|
|
|
|
|
|
std::vector<std::shared_ptr<GameFile>> m_cached_files;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace UICommon
|