mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-07-07 10:02:14 +02:00
lr: RegisteredLocationResolver helpers
This commit is contained in:
parent
d1138d43c9
commit
4bc54a88d7
@ -20,28 +20,40 @@ namespace sts::lr {
|
|||||||
|
|
||||||
RegisteredLocationResolverInterface::~RegisteredLocationResolverInterface() {
|
RegisteredLocationResolverInterface::~RegisteredLocationResolverInterface() {
|
||||||
/* Ensure entries are deallocated */
|
/* Ensure entries are deallocated */
|
||||||
|
this->ClearRedirections();
|
||||||
|
}
|
||||||
|
|
||||||
|
void RegisteredLocationResolverInterface::ClearRedirections(u32 flags) {
|
||||||
this->html_docs_redirector.ClearRedirections();
|
this->html_docs_redirector.ClearRedirections();
|
||||||
this->program_redirector.ClearRedirections();
|
this->program_redirector.ClearRedirections();
|
||||||
}
|
}
|
||||||
|
|
||||||
Result RegisteredLocationResolverInterface::ResolveProgramPath(OutPointerWithServerSize<Path, 0x1> out, ncm::TitleId tid) {
|
void RegisteredLocationResolverInterface::RegisterPath(const Path& path, impl::RegisteredLocations<ncm::TitleId, 16>* locations, ncm::TitleId tid) {
|
||||||
if (!this->program_redirector.FindRedirection(out.pointer, tid)) {
|
if (!locations->Register(tid, path)) {
|
||||||
if (!this->registered_program_locations.Find(out.pointer, tid)) {
|
locations->Clear();
|
||||||
return ResultLrProgramNotFound;
|
locations->Register(tid, path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool RegisteredLocationResolverInterface::ResolvePath(Path* out, impl::LocationRedirector* redirector, impl::RegisteredLocations<ncm::TitleId, 16>* locations, ncm::TitleId tid) {
|
||||||
|
if (!redirector->FindRedirection(out, tid)) {
|
||||||
|
if (!locations->Find(out, tid)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Result RegisteredLocationResolverInterface::ResolveProgramPath(OutPointerWithServerSize<Path, 0x1> out, ncm::TitleId tid) {
|
||||||
|
if (!this->ResolvePath(out.pointer, &this->program_redirector, &this->registered_program_locations, tid)) {
|
||||||
|
return ResultLrProgramNotFound;
|
||||||
|
}
|
||||||
|
|
||||||
return ResultSuccess;
|
return ResultSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
Result RegisteredLocationResolverInterface::RegisterProgramPath(InPointer<const Path> path, ncm::TitleId tid) {
|
Result RegisteredLocationResolverInterface::RegisterProgramPath(InPointer<const Path> path, ncm::TitleId tid) {
|
||||||
const Path& tmp_path = *path.pointer;
|
this->RegisterPath(*path.pointer, &this->registered_program_locations, tid);
|
||||||
|
|
||||||
if (!this->registered_program_locations.Register(tid, tmp_path)) {
|
|
||||||
this->registered_program_locations.Clear();
|
|
||||||
this->registered_program_locations.Register(tid, tmp_path);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ResultSuccess;
|
return ResultSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,23 +68,15 @@ namespace sts::lr {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Result RegisteredLocationResolverInterface::ResolveHtmlDocumentPath(OutPointerWithServerSize<Path, 0x1> out, ncm::TitleId tid) {
|
Result RegisteredLocationResolverInterface::ResolveHtmlDocumentPath(OutPointerWithServerSize<Path, 0x1> out, ncm::TitleId tid) {
|
||||||
if (!this->html_docs_redirector.FindRedirection(out.pointer, tid)) {
|
if (!this->ResolvePath(out.pointer, &this->html_docs_redirector, &this->registered_html_docs_locations, tid)) {
|
||||||
if (!this->registered_html_docs_locations.Find(out.pointer, tid)) {
|
|
||||||
return ResultLrProgramNotFound;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return ResultLrHtmlDocumentNotFound;
|
return ResultLrHtmlDocumentNotFound;
|
||||||
}
|
}
|
||||||
|
|
||||||
Result RegisteredLocationResolverInterface::RegisterHtmlDocumentPath(InPointer<const Path> path, ncm::TitleId tid) {
|
return ResultSuccess;
|
||||||
const Path& tmp_path = *path.pointer;
|
|
||||||
|
|
||||||
if (!this->registered_html_docs_locations.Register(tid, tmp_path)) {
|
|
||||||
this->registered_html_docs_locations.Clear();
|
|
||||||
this->registered_html_docs_locations.Register(tid, tmp_path);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Result RegisteredLocationResolverInterface::RegisterHtmlDocumentPath(InPointer<const Path> path, ncm::TitleId tid) {
|
||||||
|
this->RegisterPath(*path.pointer, &this->registered_html_docs_locations, tid);
|
||||||
return ResultSuccess;
|
return ResultSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,8 +91,7 @@ namespace sts::lr {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Result RegisteredLocationResolverInterface::Refresh() {
|
Result RegisteredLocationResolverInterface::Refresh() {
|
||||||
this->registered_program_locations.Clear();
|
this->ClearRedirections();
|
||||||
this->registered_html_docs_locations.Clear();
|
|
||||||
return ResultSuccess;
|
return ResultSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,6 +41,10 @@ namespace sts::lr {
|
|||||||
impl::RegisteredLocations<ncm::TitleId, 16> registered_program_locations;
|
impl::RegisteredLocations<ncm::TitleId, 16> registered_program_locations;
|
||||||
impl::LocationRedirector html_docs_redirector;
|
impl::LocationRedirector html_docs_redirector;
|
||||||
impl::RegisteredLocations<ncm::TitleId, 16> registered_html_docs_locations;
|
impl::RegisteredLocations<ncm::TitleId, 16> registered_html_docs_locations;
|
||||||
|
private:
|
||||||
|
void ClearRedirections(u32 flags = impl::RedirectionFlags_None);
|
||||||
|
void RegisterPath(const Path& path, impl::RegisteredLocations<ncm::TitleId, 16>* locations, ncm::TitleId tid);
|
||||||
|
bool ResolvePath(Path* out, impl::LocationRedirector* redirector, impl::RegisteredLocations<ncm::TitleId, 16>* locations, ncm::TitleId tid);
|
||||||
public:
|
public:
|
||||||
~RegisteredLocationResolverInterface();
|
~RegisteredLocationResolverInterface();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user