diff --git a/stratosphere/ncm/source/lr_contentlocationresolver.cpp b/stratosphere/ncm/source/lr_contentlocationresolver.cpp index 807eed5b6..b8a2bceb7 100644 --- a/stratosphere/ncm/source/lr_contentlocationresolver.cpp +++ b/stratosphere/ncm/source/lr_contentlocationresolver.cpp @@ -20,15 +20,15 @@ namespace sts::lr { ContentLocationResolverInterface::~ContentLocationResolverInterface() { - this->program_redirector.ClearRedirections(); - this->debug_program_redirector.ClearRedirections(); - this->app_control_redirector.ClearRedirections(); - this->html_docs_redirector.ClearRedirections(); - this->legal_info_redirector.ClearRedirections(); + this->ClearRedirections(); + } + + void ContentLocationResolverInterface::GetContentStoragePath(Path* out, ncm::ContentId content_id) { + R_ASSERT(this->content_storage->GetPath(out, content_id)); } Result ContentLocationResolverInterface::ResolveProgramPath(OutPointerWithServerSize out, ncm::TitleId tid) { - if (this->program_redirector.FindRedirection(out.pointer, tid)) { + if (this->GetRedirectedPath(out.pointer, &this->program_redirector, tid)) { return ResultSuccess; } @@ -40,7 +40,7 @@ namespace sts::lr { } } R_END_TRY_CATCH; - R_ASSERT(this->content_storage->GetPath(out.pointer, program_content_id)); + this->GetContentStoragePath(out.pointer, program_content_id); return ResultSuccess; } @@ -50,7 +50,7 @@ namespace sts::lr { } Result ContentLocationResolverInterface::ResolveApplicationControlPath(OutPointerWithServerSize out, ncm::TitleId tid) { - if (this->app_control_redirector.FindRedirection(out.pointer, tid)) { + if (this->GetRedirectedPath(out.pointer, &this->app_control_redirector, tid)) { return ResultSuccess; } @@ -58,7 +58,7 @@ namespace sts::lr { } Result ContentLocationResolverInterface::ResolveApplicationHtmlDocumentPath(OutPointerWithServerSize out, ncm::TitleId tid) { - if (this->html_docs_redirector.FindRedirection(out.pointer, tid)) { + if (this->GetRedirectedPath(out.pointer, &this->html_docs_redirector, tid)) { return ResultSuccess; } @@ -69,7 +69,7 @@ namespace sts::lr { ncm::ContentId data_content_id; R_TRY(this->content_meta_database->GetLatestData(&data_content_id, tid)); - R_ASSERT(this->content_storage->GetPath(out.pointer, data_content_id)); + this->GetContentStoragePath(out.pointer, data_content_id); return ResultSuccess; } @@ -84,7 +84,7 @@ namespace sts::lr { } Result ContentLocationResolverInterface::ResolveApplicationLegalInformationPath(OutPointerWithServerSize out, ncm::TitleId tid) { - if (this->legal_info_redirector.FindRedirection(out.pointer, tid)) { + if (this->GetRedirectedPath(out.pointer, &this->legal_info_redirector, tid)) { return ResultSuccess; } @@ -99,16 +99,12 @@ namespace sts::lr { Result ContentLocationResolverInterface::Refresh() { std::shared_ptr content_meta_database; std::shared_ptr content_storage; + R_TRY(ncm::impl::OpenContentMetaDatabase(&content_meta_database, this->storage_id)); R_TRY(ncm::impl::OpenContentStorage(&content_storage, this->storage_id)); this->content_meta_database = std::move(content_meta_database); this->content_storage = std::move(content_storage); - - this->program_redirector.ClearRedirections(); - this->debug_program_redirector.ClearRedirections(); - this->app_control_redirector.ClearRedirections(); - this->html_docs_redirector.ClearRedirections(); - this->legal_info_redirector.ClearRedirections(); + this->ClearRedirections(); return ResultSuccess; } @@ -119,11 +115,7 @@ namespace sts::lr { } Result ContentLocationResolverInterface::ClearApplicationRedirection() { - this->program_redirector.ClearRedirections(impl::RedirectionFlags_Application); - this->debug_program_redirector.ClearRedirections(impl::RedirectionFlags_Application); - this->app_control_redirector.ClearRedirections(impl::RedirectionFlags_Application); - this->html_docs_redirector.ClearRedirections(impl::RedirectionFlags_Application); - this->legal_info_redirector.ClearRedirections(impl::RedirectionFlags_Application); + this->ClearRedirections(impl::RedirectionFlags_Application); return ResultSuccess; } @@ -148,7 +140,7 @@ namespace sts::lr { } Result ContentLocationResolverInterface::ResolveProgramPathForDebug(OutPointerWithServerSize out, ncm::TitleId tid) { - if (this->debug_program_redirector.FindRedirection(out.pointer, tid)) { + if (this->GetRedirectedPath(out.pointer, &this->debug_program_redirector, tid)) { return ResultSuccess; } diff --git a/stratosphere/ncm/source/lr_contentlocationresolver.hpp b/stratosphere/ncm/source/lr_contentlocationresolver.hpp index ee4667d51..d7146fadd 100644 --- a/stratosphere/ncm/source/lr_contentlocationresolver.hpp +++ b/stratosphere/ncm/source/lr_contentlocationresolver.hpp @@ -34,6 +34,8 @@ namespace sts::lr { ContentLocationResolverInterface(ncm::StorageId storage_id) : storage_id(storage_id) { /* ... */ } ~ContentLocationResolverInterface(); + private: + void GetContentStoragePath(Path* out, ncm::ContentId content_id); public: virtual Result ResolveProgramPath(OutPointerWithServerSize out, ncm::TitleId tid) override; virtual Result RedirectProgramPath(InPointer path, ncm::TitleId tid) override; diff --git a/stratosphere/ncm/source/lr_ilocationresolver.hpp b/stratosphere/ncm/source/lr_ilocationresolver.hpp index fa669430f..5910b16b8 100644 --- a/stratosphere/ncm/source/lr_ilocationresolver.hpp +++ b/stratosphere/ncm/source/lr_ilocationresolver.hpp @@ -52,6 +52,18 @@ namespace sts::lr { impl::LocationRedirector app_control_redirector; impl::LocationRedirector html_docs_redirector; impl::LocationRedirector legal_info_redirector; + protected: + bool GetRedirectedPath(Path* out, impl::LocationRedirector* redirector, ncm::TitleId tid) { + return redirector->FindRedirection(out, tid); + } + + void ClearRedirections(u32 flags = impl::RedirectionFlags_None) { + this->program_redirector.ClearRedirections(flags); + this->debug_program_redirector.ClearRedirections(flags); + this->app_control_redirector.ClearRedirections(flags); + this->html_docs_redirector.ClearRedirections(flags); + this->legal_info_redirector.ClearRedirections(flags); + } public: virtual Result ResolveProgramPath(OutPointerWithServerSize out, ncm::TitleId tid); virtual Result RedirectProgramPath(InPointer path, ncm::TitleId tid); diff --git a/stratosphere/ncm/source/lr_redirectonlylocationresolver.cpp b/stratosphere/ncm/source/lr_redirectonlylocationresolver.cpp index 97f8592fd..c8c61a80d 100644 --- a/stratosphere/ncm/source/lr_redirectonlylocationresolver.cpp +++ b/stratosphere/ncm/source/lr_redirectonlylocationresolver.cpp @@ -28,7 +28,7 @@ namespace sts::lr { } Result RedirectOnlyLocationResolverInterface::ResolveProgramPath(OutPointerWithServerSize out, ncm::TitleId tid) { - if (this->program_redirector.FindRedirection(out.pointer, tid)) { + if (this->GetRedirectedPath(out.pointer, &this->program_redirector, tid)) { return ResultSuccess; } @@ -41,7 +41,7 @@ namespace sts::lr { } Result RedirectOnlyLocationResolverInterface::ResolveApplicationControlPath(OutPointerWithServerSize out, ncm::TitleId tid) { - if (this->app_control_redirector.FindRedirection(out.pointer, tid)) { + if (this->GetRedirectedPath(out.pointer, &this->app_control_redirector, tid)) { return ResultSuccess; } @@ -49,7 +49,7 @@ namespace sts::lr { } Result RedirectOnlyLocationResolverInterface::ResolveApplicationHtmlDocumentPath(OutPointerWithServerSize out, ncm::TitleId tid) { - if (this->html_docs_redirector.FindRedirection(out.pointer, tid)) { + if (this->GetRedirectedPath(out.pointer, &this->html_docs_redirector, tid)) { return ResultSuccess; } @@ -71,7 +71,7 @@ namespace sts::lr { } Result RedirectOnlyLocationResolverInterface::ResolveApplicationLegalInformationPath(OutPointerWithServerSize out, ncm::TitleId tid) { - if (this->legal_info_redirector.FindRedirection(out.pointer, tid)) { + if (this->GetRedirectedPath(out.pointer, &this->legal_info_redirector, tid)) { return ResultSuccess; } @@ -127,7 +127,7 @@ namespace sts::lr { } Result RedirectOnlyLocationResolverInterface::ResolveProgramPathForDebug(OutPointerWithServerSize out, ncm::TitleId tid) { - if (this->debug_program_redirector.FindRedirection(out.pointer, tid)) { + if (this->GetRedirectedPath(out.pointer, &this->debug_program_redirector, tid)) { return ResultSuccess; }