From d8273c38578780e1e8880648d07d292f6d2461a6 Mon Sep 17 00:00:00 2001 From: Zach Hilman Date: Wed, 17 Oct 2018 09:03:56 -0400 Subject: patch_manager: Add support for using LayeredFS with Data --- src/core/file_sys/patch_manager.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/core/file_sys') diff --git a/src/core/file_sys/patch_manager.cpp b/src/core/file_sys/patch_manager.cpp index 0117cb0bf..1f4928562 100644 --- a/src/core/file_sys/patch_manager.cpp +++ b/src/core/file_sys/patch_manager.cpp @@ -168,7 +168,8 @@ bool PatchManager::HasNSOPatch(const std::array& build_id_) const { static void ApplyLayeredFS(VirtualFile& romfs, u64 title_id, ContentRecordType type) { const auto load_dir = Service::FileSystem::GetModificationLoadRoot(title_id); - if (type != ContentRecordType::Program || load_dir == nullptr || load_dir->GetSize() <= 0) { + if ((type != ContentRecordType::Program && type != ContentRecordType::Data) || + load_dir == nullptr || load_dir->GetSize() <= 0) { return; } @@ -218,7 +219,7 @@ VirtualFile PatchManager::PatchRomFS(VirtualFile romfs, u64 ivfc_offset, Content title_id, static_cast(type)) .c_str(); - if (type == ContentRecordType::Program) + if (type == ContentRecordType::Program || type == ContentRecordType::Data) LOG_INFO(Loader, log_string); else LOG_DEBUG(Loader, log_string); -- cgit v1.2.3 From 59044862a902913700c3e7062ac8cfa43811c420 Mon Sep 17 00:00:00 2001 From: Zach Hilman Date: Wed, 17 Oct 2018 14:04:18 -0400 Subject: registered_cache: Deduplicate results of ListEntry and ListEntryFilter Prevents a Entry from appearing in the list twice if the user has it installed in two places (e.g. User NAND and SDMC) --- src/core/file_sys/registered_cache.cpp | 11 +++++++++++ src/core/file_sys/registered_cache.h | 7 +++++-- 2 files changed, 16 insertions(+), 2 deletions(-) (limited to 'src/core/file_sys') diff --git a/src/core/file_sys/registered_cache.cpp b/src/core/file_sys/registered_cache.cpp index 1febb398e..d1dea5e82 100644 --- a/src/core/file_sys/registered_cache.cpp +++ b/src/core/file_sys/registered_cache.cpp @@ -2,6 +2,7 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#include #include #include #include "common/assert.h" @@ -30,6 +31,10 @@ bool operator<(const RegisteredCacheEntry& lhs, const RegisteredCacheEntry& rhs) return (lhs.title_id < rhs.title_id) || (lhs.title_id == rhs.title_id && lhs.type < rhs.type); } +bool operator==(const RegisteredCacheEntry& lhs, const RegisteredCacheEntry& rhs) { + return std::tie(lhs.title_id, lhs.type) == std::tie(rhs.title_id, rhs.type); +} + static bool FollowsTwoDigitDirFormat(std::string_view name) { static const std::regex two_digit_regex("000000[0-9A-F]{2}", std::regex_constants::ECMAScript | std::regex_constants::icase); @@ -593,6 +598,9 @@ std::vector RegisteredCacheUnion::ListEntries() const { }, [](const CNMT& c, const ContentRecord& r) { return true; }); } + + std::sort(out.begin(), out.end()); + out.erase(std::unique(out.begin(), out.end()), out.end()); return out; } @@ -616,6 +624,9 @@ std::vector RegisteredCacheUnion::ListEntriesFilter( return true; }); } + + std::sort(out.begin(), out.end()); + out.erase(std::unique(out.begin(), out.end()), out.end()); return out; } } // namespace FileSys diff --git a/src/core/file_sys/registered_cache.h b/src/core/file_sys/registered_cache.h index 5ddacba47..aeb1c69ba 100644 --- a/src/core/file_sys/registered_cache.h +++ b/src/core/file_sys/registered_cache.h @@ -50,6 +50,9 @@ constexpr u64 GetUpdateTitleID(u64 base_title_id) { // boost flat_map requires operator< for O(log(n)) lookups. bool operator<(const RegisteredCacheEntry& lhs, const RegisteredCacheEntry& rhs); +// std unique requires operator== to identify duplicates. +bool operator==(const RegisteredCacheEntry& lhs, const RegisteredCacheEntry& rhs); + /* * A class that catalogues NCAs in the registered directory structure. * Nintendo's registered format follows this structure: @@ -60,8 +63,8 @@ bool operator<(const RegisteredCacheEntry& lhs, const RegisteredCacheEntry& rhs) * | 00 * | 01 <- Actual content split along 4GB boundaries. (optional) * - * (This impl also supports substituting the nca dir for an nca file, as that's more convenient when - * 4GB splitting can be ignored.) + * (This impl also supports substituting the nca dir for an nca file, as that's more convenient + * when 4GB splitting can be ignored.) */ class RegisteredCache { friend class RegisteredCacheUnion; -- cgit v1.2.3 From 9d0fb0f81506429fa83923b04878a5ee2e8ff420 Mon Sep 17 00:00:00 2001 From: Zach Hilman Date: Wed, 17 Oct 2018 18:27:23 -0400 Subject: qt: Add support for dumping a DLC Data RomFS --- src/core/file_sys/registered_cache.cpp | 4 ++++ src/core/file_sys/registered_cache.h | 1 + 2 files changed, 5 insertions(+) (limited to 'src/core/file_sys') diff --git a/src/core/file_sys/registered_cache.cpp b/src/core/file_sys/registered_cache.cpp index d1dea5e82..29b100414 100644 --- a/src/core/file_sys/registered_cache.cpp +++ b/src/core/file_sys/registered_cache.cpp @@ -35,6 +35,10 @@ bool operator==(const RegisteredCacheEntry& lhs, const RegisteredCacheEntry& rhs return std::tie(lhs.title_id, lhs.type) == std::tie(rhs.title_id, rhs.type); } +bool operator!=(const RegisteredCacheEntry& lhs, const RegisteredCacheEntry& rhs) { + return !operator==(lhs, rhs); +} + static bool FollowsTwoDigitDirFormat(std::string_view name) { static const std::regex two_digit_regex("000000[0-9A-F]{2}", std::regex_constants::ECMAScript | std::regex_constants::icase); diff --git a/src/core/file_sys/registered_cache.h b/src/core/file_sys/registered_cache.h index aeb1c69ba..5beceffb3 100644 --- a/src/core/file_sys/registered_cache.h +++ b/src/core/file_sys/registered_cache.h @@ -52,6 +52,7 @@ bool operator<(const RegisteredCacheEntry& lhs, const RegisteredCacheEntry& rhs) // std unique requires operator== to identify duplicates. bool operator==(const RegisteredCacheEntry& lhs, const RegisteredCacheEntry& rhs); +bool operator!=(const RegisteredCacheEntry& lhs, const RegisteredCacheEntry& rhs); /* * A class that catalogues NCAs in the registered directory structure. -- cgit v1.2.3