summaryrefslogtreecommitdiffstats
path: root/src/core/file_sys/registered_cache.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/file_sys/registered_cache.h')
-rw-r--r--src/core/file_sys/registered_cache.h58
1 files changed, 52 insertions, 6 deletions
diff --git a/src/core/file_sys/registered_cache.h b/src/core/file_sys/registered_cache.h
index 7b8955dfa..f487b0cf0 100644
--- a/src/core/file_sys/registered_cache.h
+++ b/src/core/file_sys/registered_cache.h
@@ -11,15 +11,19 @@
#include <string>
#include <vector>
#include <boost/container/flat_map.hpp>
-#include "common/common_funcs.h"
#include "common/common_types.h"
-#include "content_archive.h"
-#include "core/file_sys/nca_metadata.h"
#include "core/file_sys/vfs.h"
namespace FileSys {
-class XCI;
class CNMT;
+class NCA;
+class NSP;
+class XCI;
+
+enum class ContentRecordType : u8;
+enum class TitleType : u8;
+
+struct ContentRecord;
using NcaID = std::array<u8, 0x10>;
using RegisteredCacheParsingFunction = std::function<VirtualFile(const VirtualFile&, const NcaID&)>;
@@ -39,6 +43,10 @@ struct RegisteredCacheEntry {
std::string DebugInfo() const;
};
+constexpr u64 GetUpdateTitleID(u64 base_title_id) {
+ return base_title_id | 0x800;
+}
+
// boost flat_map requires operator< for O(log(n)) lookups.
bool operator<(const RegisteredCacheEntry& lhs, const RegisteredCacheEntry& rhs);
@@ -56,6 +64,8 @@ bool operator<(const RegisteredCacheEntry& lhs, const RegisteredCacheEntry& rhs)
* 4GB splitting can be ignored.)
*/
class RegisteredCache {
+ friend class RegisteredCacheUnion;
+
public:
// Parsing function defines the conversion from raw file to NCA. If there are other steps
// besides creating the NCA from the file (e.g. NAX0 on SD Card), that should go in a custom
@@ -70,6 +80,8 @@ public:
bool HasEntry(u64 title_id, ContentRecordType type) const;
bool HasEntry(RegisteredCacheEntry entry) const;
+ boost::optional<u32> GetEntryVersion(u64 title_id) const;
+
VirtualFile GetEntryUnparsed(u64 title_id, ContentRecordType type) const;
VirtualFile GetEntryUnparsed(RegisteredCacheEntry entry) const;
@@ -86,10 +98,12 @@ public:
boost::optional<ContentRecordType> record_type = boost::none,
boost::optional<u64> title_id = boost::none) const;
- // Raw copies all the ncas from the xci to the csache. Does some quick checks to make sure there
- // is a meta NCA and all of them are accessible.
+ // Raw copies all the ncas from the xci/nsp to the csache. Does some quick checks to make sure
+ // there is a meta NCA and all of them are accessible.
InstallResult InstallEntry(std::shared_ptr<XCI> xci, bool overwrite_if_exists = false,
const VfsCopyFunction& copy = &VfsRawCopy);
+ InstallResult InstallEntry(std::shared_ptr<NSP> nsp, bool overwrite_if_exists = false,
+ const VfsCopyFunction& copy = &VfsRawCopy);
// Due to the fact that we must use Meta-type NCAs to determine the existance of files, this
// poses quite a challenge. Instead of creating a new meta NCA for this file, yuzu will create a
@@ -125,4 +139,36 @@ private:
boost::container::flat_map<u64, CNMT> yuzu_meta;
};
+// Combines multiple RegisteredCaches (i.e. SysNAND, UserNAND, SDMC) into one interface.
+class RegisteredCacheUnion {
+public:
+ explicit RegisteredCacheUnion(std::vector<std::shared_ptr<RegisteredCache>> caches);
+
+ void Refresh();
+
+ bool HasEntry(u64 title_id, ContentRecordType type) const;
+ bool HasEntry(RegisteredCacheEntry entry) const;
+
+ boost::optional<u32> GetEntryVersion(u64 title_id) const;
+
+ VirtualFile GetEntryUnparsed(u64 title_id, ContentRecordType type) const;
+ VirtualFile GetEntryUnparsed(RegisteredCacheEntry entry) const;
+
+ VirtualFile GetEntryRaw(u64 title_id, ContentRecordType type) const;
+ VirtualFile GetEntryRaw(RegisteredCacheEntry entry) const;
+
+ std::shared_ptr<NCA> GetEntry(u64 title_id, ContentRecordType type) const;
+ std::shared_ptr<NCA> GetEntry(RegisteredCacheEntry entry) const;
+
+ std::vector<RegisteredCacheEntry> ListEntries() const;
+ // If a parameter is not boost::none, it will be filtered for from all entries.
+ std::vector<RegisteredCacheEntry> ListEntriesFilter(
+ boost::optional<TitleType> title_type = boost::none,
+ boost::optional<ContentRecordType> record_type = boost::none,
+ boost::optional<u64> title_id = boost::none) const;
+
+private:
+ std::vector<std::shared_ptr<RegisteredCache>> caches;
+};
+
} // namespace FileSys