romfs_factory: Extract packed update setter to new function
This commit is contained in:
parent
5acaeb04c4
commit
38c2ac95af
|
@ -206,7 +206,7 @@ VirtualFile PatchManager::PatchRomFS(VirtualFile romfs, u64 ivfc_offset, Content
|
||||||
romfs = new_nca->GetRomFS();
|
romfs = new_nca->GetRomFS();
|
||||||
}
|
}
|
||||||
} else if (update_raw != nullptr) {
|
} else if (update_raw != nullptr) {
|
||||||
const auto new_nca = std::make_shared<NCA>(update, romfs, ivfc_offset);
|
const auto new_nca = std::make_shared<NCA>(update_raw, romfs, ivfc_offset);
|
||||||
if (new_nca->GetStatus() == Loader::ResultStatus::Success &&
|
if (new_nca->GetStatus() == Loader::ResultStatus::Success &&
|
||||||
new_nca->GetRomFS() != nullptr) {
|
new_nca->GetRomFS() != nullptr) {
|
||||||
LOG_INFO(Loader, " RomFS: Update (PACKED) applied successfully");
|
LOG_INFO(Loader, " RomFS: Update (PACKED) applied successfully");
|
||||||
|
@ -231,7 +231,8 @@ static bool IsDirValidAndNonEmpty(const VirtualDir& dir) {
|
||||||
return dir != nullptr && (!dir->GetFiles().empty() || !dir->GetSubdirectories().empty());
|
return dir != nullptr && (!dir->GetFiles().empty() || !dir->GetSubdirectories().empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
std::map<PatchType, std::string> PatchManager::GetPatchVersionNames(VirtualFile update_raw) const {
|
std::map<std::string, std::string, std::less<>> PatchManager::GetPatchVersionNames(
|
||||||
|
VirtualFile update_raw) const {
|
||||||
std::map<std::string, std::string, std::less<>> out;
|
std::map<std::string, std::string, std::less<>> out;
|
||||||
const auto installed = Service::FileSystem::GetUnionContents();
|
const auto installed = Service::FileSystem::GetUnionContents();
|
||||||
|
|
||||||
|
@ -253,7 +254,7 @@ std::map<PatchType, std::string> PatchManager::GetPatchVersionNames(VirtualFile
|
||||||
FormatTitleVersion(meta_ver.get(), TitleVersionFormat::ThreeElements));
|
FormatTitleVersion(meta_ver.get(), TitleVersionFormat::ThreeElements));
|
||||||
}
|
}
|
||||||
} else if (update_raw != nullptr) {
|
} else if (update_raw != nullptr) {
|
||||||
out[PatchType::Update] = "PACKED";
|
out.insert_or_assign("Update", "PACKED");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,8 @@ public:
|
||||||
|
|
||||||
// Returns a vector of pairs between patch names and patch versions.
|
// Returns a vector of pairs between patch names and patch versions.
|
||||||
// i.e. Update 3.2.2 will return {"Update", "3.2.2"}
|
// i.e. Update 3.2.2 will return {"Update", "3.2.2"}
|
||||||
std::map<std::string, std::string, std::less<>> GetPatchVersionNames() const;
|
std::map<std::string, std::string, std::less<>> GetPatchVersionNames(
|
||||||
|
VirtualFile update_raw = nullptr) const;
|
||||||
|
|
||||||
// Given title_id of the program, attempts to get the control data of the update and parse it,
|
// Given title_id of the program, attempts to get the control data of the update and parse it,
|
||||||
// falling back to the base control data.
|
// falling back to the base control data.
|
||||||
|
|
|
@ -24,13 +24,16 @@ RomFSFactory::RomFSFactory(Loader::AppLoader& app_loader) {
|
||||||
LOG_ERROR(Service_FS, "Unable to read RomFS!");
|
LOG_ERROR(Service_FS, "Unable to read RomFS!");
|
||||||
}
|
}
|
||||||
|
|
||||||
app_loader.ReadUpdateRaw(update_raw);
|
|
||||||
updatable = app_loader.IsRomFSUpdatable();
|
updatable = app_loader.IsRomFSUpdatable();
|
||||||
ivfc_offset = app_loader.ReadRomFSIVFCOffset();
|
ivfc_offset = app_loader.ReadRomFSIVFCOffset();
|
||||||
}
|
}
|
||||||
|
|
||||||
RomFSFactory::~RomFSFactory() = default;
|
RomFSFactory::~RomFSFactory() = default;
|
||||||
|
|
||||||
|
void RomFSFactory::SetPackedUpdate(VirtualFile update_raw) {
|
||||||
|
this->update_raw = std::move(update_raw);
|
||||||
|
}
|
||||||
|
|
||||||
ResultVal<VirtualFile> RomFSFactory::OpenCurrentProcess() {
|
ResultVal<VirtualFile> RomFSFactory::OpenCurrentProcess() {
|
||||||
if (!updatable)
|
if (!updatable)
|
||||||
return MakeResult<VirtualFile>(file);
|
return MakeResult<VirtualFile>(file);
|
||||||
|
|
|
@ -32,6 +32,7 @@ public:
|
||||||
explicit RomFSFactory(Loader::AppLoader& app_loader);
|
explicit RomFSFactory(Loader::AppLoader& app_loader);
|
||||||
~RomFSFactory();
|
~RomFSFactory();
|
||||||
|
|
||||||
|
void SetPackedUpdate(VirtualFile update_raw);
|
||||||
ResultVal<VirtualFile> OpenCurrentProcess();
|
ResultVal<VirtualFile> OpenCurrentProcess();
|
||||||
ResultVal<VirtualFile> Open(u64 title_id, StorageId storage, ContentRecordType type);
|
ResultVal<VirtualFile> Open(u64 title_id, StorageId storage, ContentRecordType type);
|
||||||
|
|
||||||
|
|
|
@ -259,9 +259,12 @@ void NSP::ReadNCAs(const std::vector<VirtualFile>& files) {
|
||||||
auto next_nca = std::make_shared<NCA>(next_file);
|
auto next_nca = std::make_shared<NCA>(next_file);
|
||||||
if (next_nca->GetType() == NCAContentType::Program)
|
if (next_nca->GetType() == NCAContentType::Program)
|
||||||
program_status[cnmt.GetTitleID()] = next_nca->GetStatus();
|
program_status[cnmt.GetTitleID()] = next_nca->GetStatus();
|
||||||
if (next_nca->GetStatus() == Loader::ResultStatus::Success)
|
if (next_nca->GetStatus() == Loader::ResultStatus::Success ||
|
||||||
|
(next_nca->GetStatus() == Loader::ResultStatus::ErrorMissingBKTRBaseRomFS &&
|
||||||
|
(cnmt.GetTitleID() & 0x800) != 0)) {
|
||||||
ncas_title[rec.type] = std::move(next_nca);
|
ncas_title[rec.type] = std::move(next_nca);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -264,6 +264,15 @@ ResultCode RegisterBIS(std::unique_ptr<FileSys::BISFactory>&& factory) {
|
||||||
return RESULT_SUCCESS;
|
return RESULT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SetPackedUpdate(FileSys::VirtualFile update_raw) {
|
||||||
|
LOG_TRACE(Service_FS, "Setting packed update for romfs");
|
||||||
|
|
||||||
|
if (romfs_factory == nullptr)
|
||||||
|
return;
|
||||||
|
|
||||||
|
romfs_factory->SetPackedUpdate(std::move(update_raw));
|
||||||
|
}
|
||||||
|
|
||||||
ResultVal<FileSys::VirtualFile> OpenRomFSCurrentProcess() {
|
ResultVal<FileSys::VirtualFile> OpenRomFSCurrentProcess() {
|
||||||
LOG_TRACE(Service_FS, "Opening RomFS for current process");
|
LOG_TRACE(Service_FS, "Opening RomFS for current process");
|
||||||
|
|
||||||
|
|
|
@ -39,6 +39,7 @@ ResultCode RegisterSaveData(std::unique_ptr<FileSys::SaveDataFactory>&& factory)
|
||||||
ResultCode RegisterSDMC(std::unique_ptr<FileSys::SDMCFactory>&& factory);
|
ResultCode RegisterSDMC(std::unique_ptr<FileSys::SDMCFactory>&& factory);
|
||||||
ResultCode RegisterBIS(std::unique_ptr<FileSys::BISFactory>&& factory);
|
ResultCode RegisterBIS(std::unique_ptr<FileSys::BISFactory>&& factory);
|
||||||
|
|
||||||
|
void SetPackedUpdate(FileSys::VirtualFile update_raw);
|
||||||
ResultVal<FileSys::VirtualFile> OpenRomFSCurrentProcess();
|
ResultVal<FileSys::VirtualFile> OpenRomFSCurrentProcess();
|
||||||
ResultVal<FileSys::VirtualFile> OpenRomFS(u64 title_id, FileSys::StorageId storage_id,
|
ResultVal<FileSys::VirtualFile> OpenRomFS(u64 title_id, FileSys::StorageId storage_id,
|
||||||
FileSys::ContentRecordType type);
|
FileSys::ContentRecordType type);
|
||||||
|
|
|
@ -10,8 +10,10 @@
|
||||||
#include "core/file_sys/control_metadata.h"
|
#include "core/file_sys/control_metadata.h"
|
||||||
#include "core/file_sys/nca_metadata.h"
|
#include "core/file_sys/nca_metadata.h"
|
||||||
#include "core/file_sys/patch_manager.h"
|
#include "core/file_sys/patch_manager.h"
|
||||||
|
#include "core/file_sys/registered_cache.h"
|
||||||
#include "core/file_sys/submission_package.h"
|
#include "core/file_sys/submission_package.h"
|
||||||
#include "core/hle/kernel/process.h"
|
#include "core/hle/kernel/process.h"
|
||||||
|
#include "core/hle/service/filesystem/filesystem.h"
|
||||||
#include "core/loader/deconstructed_rom_directory.h"
|
#include "core/loader/deconstructed_rom_directory.h"
|
||||||
#include "core/loader/nca.h"
|
#include "core/loader/nca.h"
|
||||||
#include "core/loader/nsp.h"
|
#include "core/loader/nsp.h"
|
||||||
|
@ -91,6 +93,10 @@ ResultStatus AppLoader_NSP::Load(Kernel::Process& process) {
|
||||||
if (result != ResultStatus::Success)
|
if (result != ResultStatus::Success)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
|
FileSys::VirtualFile update_raw;
|
||||||
|
if (ReadUpdateRaw(update_raw) == ResultStatus::Success && update_raw != nullptr)
|
||||||
|
Service::FileSystem::SetPackedUpdate(std::move(update_raw));
|
||||||
|
|
||||||
is_loaded = true;
|
is_loaded = true;
|
||||||
|
|
||||||
return ResultStatus::Success;
|
return ResultStatus::Success;
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
#include "core/file_sys/romfs.h"
|
#include "core/file_sys/romfs.h"
|
||||||
#include "core/file_sys/submission_package.h"
|
#include "core/file_sys/submission_package.h"
|
||||||
#include "core/hle/kernel/process.h"
|
#include "core/hle/kernel/process.h"
|
||||||
|
#include "core/hle/service/filesystem/filesystem.h"
|
||||||
#include "core/loader/nca.h"
|
#include "core/loader/nca.h"
|
||||||
#include "core/loader/xci.h"
|
#include "core/loader/xci.h"
|
||||||
|
|
||||||
|
@ -66,6 +67,10 @@ ResultStatus AppLoader_XCI::Load(Kernel::Process& process) {
|
||||||
if (result != ResultStatus::Success)
|
if (result != ResultStatus::Success)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
|
FileSys::VirtualFile update_raw;
|
||||||
|
if (ReadUpdateRaw(update_raw) == ResultStatus::Success && update_raw != nullptr)
|
||||||
|
Service::FileSystem::SetPackedUpdate(std::move(update_raw));
|
||||||
|
|
||||||
is_loaded = true;
|
is_loaded = true;
|
||||||
|
|
||||||
return ResultStatus::Success;
|
return ResultStatus::Success;
|
||||||
|
|
|
@ -72,11 +72,10 @@ QString FormatPatchNameVersions(const FileSys::PatchManager& patch_manager,
|
||||||
auto ver = kv.second;
|
auto ver = kv.second;
|
||||||
|
|
||||||
// Display container name for packed updates
|
// Display container name for packed updates
|
||||||
if (ver == "PACKED" && kv.first == FileSys::PatchType::Update)
|
if (ver == "PACKED" && kv.first == "Update")
|
||||||
ver = Loader::GetFileTypeString(loader.GetFileType());
|
ver = Loader::GetFileTypeString(loader.GetFileType());
|
||||||
|
|
||||||
out.append(
|
out.append(fmt::format("{} ({})\n", kv.first, ver).c_str());
|
||||||
fmt::format("{} ({})\n", FileSys::FormatPatchTypeName(kv.first), ver).c_str());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue