mirror of
https://git.h3cjp.net/H3cJP/yuzu.git
synced 2024-11-14 11:42:48 +00:00
nro: Make bracing consistent
Makes the code more uniform, and also braces cases where the body of an unbraced conditional travels more than one line.
This commit is contained in:
parent
ac8133b9ee
commit
2b497e5830
|
@ -68,22 +68,27 @@ static_assert(sizeof(AssetHeader) == 0x38, "AssetHeader has incorrect size.");
|
||||||
|
|
||||||
AppLoader_NRO::AppLoader_NRO(FileSys::VirtualFile file) : AppLoader(file) {
|
AppLoader_NRO::AppLoader_NRO(FileSys::VirtualFile file) : AppLoader(file) {
|
||||||
NroHeader nro_header{};
|
NroHeader nro_header{};
|
||||||
if (file->ReadObject(&nro_header) != sizeof(NroHeader))
|
if (file->ReadObject(&nro_header) != sizeof(NroHeader)) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (file->GetSize() >= nro_header.file_size + sizeof(AssetHeader)) {
|
if (file->GetSize() >= nro_header.file_size + sizeof(AssetHeader)) {
|
||||||
u64 offset = nro_header.file_size;
|
const u64 offset = nro_header.file_size;
|
||||||
AssetHeader asset_header{};
|
AssetHeader asset_header{};
|
||||||
if (file->ReadObject(&asset_header, offset) != sizeof(AssetHeader))
|
if (file->ReadObject(&asset_header, offset) != sizeof(AssetHeader)) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (asset_header.format_version != 0)
|
if (asset_header.format_version != 0) {
|
||||||
LOG_WARNING(Loader,
|
LOG_WARNING(Loader,
|
||||||
"NRO Asset Header has format {}, currently supported format is 0. If "
|
"NRO Asset Header has format {}, currently supported format is 0. If "
|
||||||
"strange glitches occur with metadata, check NRO assets.",
|
"strange glitches occur with metadata, check NRO assets.",
|
||||||
asset_header.format_version);
|
asset_header.format_version);
|
||||||
if (asset_header.magic != Common::MakeMagic('A', 'S', 'E', 'T'))
|
}
|
||||||
|
|
||||||
|
if (asset_header.magic != Common::MakeMagic('A', 'S', 'E', 'T')) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (asset_header.nacp.size > 0) {
|
if (asset_header.nacp.size > 0) {
|
||||||
nacp = std::make_unique<FileSys::NACP>(std::make_shared<FileSys::OffsetVfsFile>(
|
nacp = std::make_unique<FileSys::NACP>(std::make_shared<FileSys::OffsetVfsFile>(
|
||||||
|
@ -130,8 +135,9 @@ bool AppLoader_NRO::LoadNro(FileSys::VirtualFile file, VAddr load_base) {
|
||||||
// Build program image
|
// Build program image
|
||||||
Kernel::SharedPtr<Kernel::CodeSet> codeset = Kernel::CodeSet::Create("");
|
Kernel::SharedPtr<Kernel::CodeSet> codeset = Kernel::CodeSet::Create("");
|
||||||
std::vector<u8> program_image = file->ReadBytes(PageAlignSize(nro_header.file_size));
|
std::vector<u8> program_image = file->ReadBytes(PageAlignSize(nro_header.file_size));
|
||||||
if (program_image.size() != PageAlignSize(nro_header.file_size))
|
if (program_image.size() != PageAlignSize(nro_header.file_size)) {
|
||||||
return {};
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
for (std::size_t i = 0; i < nro_header.segments.size(); ++i) {
|
for (std::size_t i = 0; i < nro_header.segments.size(); ++i) {
|
||||||
codeset->segments[i].addr = nro_header.segments[i].offset;
|
codeset->segments[i].addr = nro_header.segments[i].offset;
|
||||||
|
@ -187,29 +193,37 @@ ResultStatus AppLoader_NRO::Load(Kernel::SharedPtr<Kernel::Process>& process) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultStatus AppLoader_NRO::ReadIcon(std::vector<u8>& buffer) {
|
ResultStatus AppLoader_NRO::ReadIcon(std::vector<u8>& buffer) {
|
||||||
if (icon_data.empty())
|
if (icon_data.empty()) {
|
||||||
return ResultStatus::ErrorNotUsed;
|
return ResultStatus::ErrorNotUsed;
|
||||||
|
}
|
||||||
|
|
||||||
buffer = icon_data;
|
buffer = icon_data;
|
||||||
return ResultStatus::Success;
|
return ResultStatus::Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultStatus AppLoader_NRO::ReadProgramId(u64& out_program_id) {
|
ResultStatus AppLoader_NRO::ReadProgramId(u64& out_program_id) {
|
||||||
if (nacp == nullptr)
|
if (nacp == nullptr) {
|
||||||
return ResultStatus::ErrorNotUsed;
|
return ResultStatus::ErrorNotUsed;
|
||||||
|
}
|
||||||
|
|
||||||
out_program_id = nacp->GetTitleId();
|
out_program_id = nacp->GetTitleId();
|
||||||
return ResultStatus::Success;
|
return ResultStatus::Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultStatus AppLoader_NRO::ReadRomFS(FileSys::VirtualFile& dir) {
|
ResultStatus AppLoader_NRO::ReadRomFS(FileSys::VirtualFile& dir) {
|
||||||
if (romfs == nullptr)
|
if (romfs == nullptr) {
|
||||||
return ResultStatus::ErrorNotUsed;
|
return ResultStatus::ErrorNotUsed;
|
||||||
|
}
|
||||||
|
|
||||||
dir = romfs;
|
dir = romfs;
|
||||||
return ResultStatus::Success;
|
return ResultStatus::Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultStatus AppLoader_NRO::ReadTitle(std::string& title) {
|
ResultStatus AppLoader_NRO::ReadTitle(std::string& title) {
|
||||||
if (nacp == nullptr)
|
if (nacp == nullptr) {
|
||||||
return ResultStatus::ErrorNotUsed;
|
return ResultStatus::ErrorNotUsed;
|
||||||
|
}
|
||||||
|
|
||||||
title = nacp->GetApplicationName();
|
title = nacp->GetApplicationName();
|
||||||
return ResultStatus::Success;
|
return ResultStatus::Success;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue