1
0
Fork 0
forked from suyu/suyu

file_sys/card_image: Deduplicate casts within AddNCAFromPartition()

Makes for nicer reading.
This commit is contained in:
Lioncash 2019-06-10 23:18:17 -04:00
parent 81d361d9f8
commit 7bdef6106e
No known key found for this signature in database
GPG key ID: 4E3C3CC1031BA9C7

View file

@ -176,11 +176,14 @@ VirtualDir XCI::GetParentDirectory() const {
} }
Loader::ResultStatus XCI::AddNCAFromPartition(XCIPartition part) { Loader::ResultStatus XCI::AddNCAFromPartition(XCIPartition part) {
if (partitions[static_cast<std::size_t>(part)] == nullptr) { const auto partition_index = static_cast<std::size_t>(part);
const auto& partition = partitions[partition_index];
if (partition == nullptr) {
return Loader::ResultStatus::ErrorXCIMissingPartition; return Loader::ResultStatus::ErrorXCIMissingPartition;
} }
for (const VirtualFile& file : partitions[static_cast<std::size_t>(part)]->GetFiles()) { for (const VirtualFile& file : partition->GetFiles()) {
if (file->GetExtension() != "nca") { if (file->GetExtension() != "nca") {
continue; continue;
} }
@ -197,7 +200,7 @@ Loader::ResultStatus XCI::AddNCAFromPartition(XCIPartition part) {
} else { } else {
const u16 error_id = static_cast<u16>(nca->GetStatus()); const u16 error_id = static_cast<u16>(nca->GetStatus());
LOG_CRITICAL(Loader, "Could not load NCA {}/{}, failed with error code {:04X} ({})", LOG_CRITICAL(Loader, "Could not load NCA {}/{}, failed with error code {:04X} ({})",
partition_names[static_cast<std::size_t>(part)], nca->GetName(), error_id, partition_names[partition_index], nca->GetName(), error_id,
nca->GetStatus()); nca->GetStatus());
} }
} }