loader: Add accessor for Manual RomFS

This commit is contained in:
Zach Hilman 2018-12-24 16:19:41 -05:00
parent 621b25b6be
commit 4c20a39828
5 changed files with 30 additions and 0 deletions

View file

@ -259,6 +259,15 @@ public:
return ResultStatus::ErrorNotImplemented; return ResultStatus::ErrorNotImplemented;
} }
/**
* Get the RomFS of the manual of the application
* @param file The raw manual RomFS of the game
* @return ResultStatus result of function
*/
virtual ResultStatus ReadManualRomFS(FileSys::VirtualFile& file) {
return ResultStatus::ErrorNotImplemented;
}
protected: protected:
FileSys::VirtualFile file; FileSys::VirtualFile file;
bool is_loaded = false; bool is_loaded = false;

View file

@ -158,4 +158,12 @@ ResultStatus AppLoader_NSP::ReadControlData(FileSys::NACP& nacp) {
nacp = *nacp_file; nacp = *nacp_file;
return ResultStatus::Success; return ResultStatus::Success;
} }
ResultStatus AppLoader_NSP::ReadManualRomFS(FileSys::VirtualFile& file) {
const auto nca = nsp->GetNCA(nsp->GetProgramTitleID(), FileSys::ContentRecordType::Manual);
if (nsp->GetStatus() != ResultStatus::Success || nca == nullptr)
return ResultStatus::ErrorNoRomFS;
file = nca->GetRomFS();
return file == nullptr ? ResultStatus::ErrorNoRomFS : ResultStatus::Success;
}
} // namespace Loader } // namespace Loader

View file

@ -44,6 +44,8 @@ public:
ResultStatus ReadIcon(std::vector<u8>& buffer) override; ResultStatus ReadIcon(std::vector<u8>& buffer) override;
ResultStatus ReadTitle(std::string& title) override; ResultStatus ReadTitle(std::string& title) override;
ResultStatus ReadControlData(FileSys::NACP& nacp) override; ResultStatus ReadControlData(FileSys::NACP& nacp) override;
ResultStatus ReadDeveloper(std::string& developer) override;
ResultStatus ReadManualRomFS(FileSys::VirtualFile& file) override;
private: private:
std::unique_ptr<FileSys::NSP> nsp; std::unique_ptr<FileSys::NSP> nsp;

View file

@ -128,4 +128,13 @@ ResultStatus AppLoader_XCI::ReadControlData(FileSys::NACP& control) {
return ResultStatus::Success; return ResultStatus::Success;
} }
ResultStatus AppLoader_XCI::ReadManualRomFS(FileSys::VirtualFile& file) {
const auto nca = xci->GetSecurePartitionNSP()->GetNCA(xci->GetProgramTitleID(),
FileSys::ContentRecordType::Manual);
if (xci->GetStatus() != ResultStatus::Success || nca == nullptr)
return ResultStatus::ErrorXCIMissingPartition;
file = nca->GetRomFS();
return file == nullptr ? ResultStatus::ErrorNoRomFS : ResultStatus::Success;
}
} // namespace Loader } // namespace Loader

View file

@ -44,6 +44,8 @@ public:
ResultStatus ReadIcon(std::vector<u8>& buffer) override; ResultStatus ReadIcon(std::vector<u8>& buffer) override;
ResultStatus ReadTitle(std::string& title) override; ResultStatus ReadTitle(std::string& title) override;
ResultStatus ReadControlData(FileSys::NACP& control) override; ResultStatus ReadControlData(FileSys::NACP& control) override;
ResultStatus ReadDeveloper(std::string& developer) override;
ResultStatus ReadManualRomFS(FileSys::VirtualFile& file) override;
private: private:
std::unique_ptr<FileSys::XCI> xci; std::unique_ptr<FileSys::XCI> xci;