From db2e5e5fa6731c02a016ae583732ce1df8fae3b3 Mon Sep 17 00:00:00 2001 From: Zach Hilman Date: Mon, 24 Jun 2019 19:10:17 -0400 Subject: [PATCH] registered_cache: Add getter to determine source slot in content provider union Used to determine StorageId source for application data. --- src/core/file_sys/registered_cache.cpp | 14 ++++++++++++++ src/core/file_sys/registered_cache.h | 3 +++ 2 files changed, 17 insertions(+) diff --git a/src/core/file_sys/registered_cache.cpp b/src/core/file_sys/registered_cache.cpp index 58917e094b..3bb9212105 100644 --- a/src/core/file_sys/registered_cache.cpp +++ b/src/core/file_sys/registered_cache.cpp @@ -645,6 +645,20 @@ ContentProviderUnion::ListEntriesFilterOrigin(std::optional ContentProviderUnion::GetSlotForEntry( + u64 title_id, ContentRecordType type) const { + for (const auto& [slot, provider] : providers) { + if (provider == nullptr) + continue; + + if (provider->HasEntry(title_id, type)) { + return slot; + } + } + + return std::nullopt; +} + ManualContentProvider::~ManualContentProvider() = default; void ManualContentProvider::AddEntry(TitleType title_type, ContentRecordType content_type, diff --git a/src/core/file_sys/registered_cache.h b/src/core/file_sys/registered_cache.h index ec9052653b..4398d63e1f 100644 --- a/src/core/file_sys/registered_cache.h +++ b/src/core/file_sys/registered_cache.h @@ -199,6 +199,9 @@ public: std::optional title_type = {}, std::optional record_type = {}, std::optional title_id = {}) const; + std::optional GetSlotForEntry(u64 title_id, + ContentRecordType type) const; + private: std::map providers; };