diff options
author | Zach Hilman <zachhilman@gmail.com> | 2018-08-26 01:00:36 +0200 |
---|---|---|
committer | Zach Hilman <zachhilman@gmail.com> | 2018-09-04 22:21:40 +0200 |
commit | 9951f6d0543980e29e6107e0bd4ea35977f1cf29 (patch) | |
tree | 2ee34991b03ab10607d41c90588a52a0476ddfc6 /src/core/file_sys/registered_cache.h | |
parent | game_list: Use RegisteredCacheUnion for installed (diff) | |
download | yuzu-9951f6d0543980e29e6107e0bd4ea35977f1cf29.tar yuzu-9951f6d0543980e29e6107e0bd4ea35977f1cf29.tar.gz yuzu-9951f6d0543980e29e6107e0bd4ea35977f1cf29.tar.bz2 yuzu-9951f6d0543980e29e6107e0bd4ea35977f1cf29.tar.lz yuzu-9951f6d0543980e29e6107e0bd4ea35977f1cf29.tar.xz yuzu-9951f6d0543980e29e6107e0bd4ea35977f1cf29.tar.zst yuzu-9951f6d0543980e29e6107e0bd4ea35977f1cf29.zip |
Diffstat (limited to '')
-rw-r--r-- | src/core/file_sys/registered_cache.h | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/core/file_sys/registered_cache.h b/src/core/file_sys/registered_cache.h index 467ceeef1..dcce3fd16 100644 --- a/src/core/file_sys/registered_cache.h +++ b/src/core/file_sys/registered_cache.h @@ -43,6 +43,10 @@ struct RegisteredCacheEntry { std::string DebugInfo() const; }; +constexpr inline 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); @@ -60,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 @@ -74,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; @@ -131,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 |