mirror of
https://github.com/yuzu-emu/yuzu.git
synced 2024-08-23 16:57:19 +02:00
file_sys/registered_cache: Eliminate variable shadowing
Also inverts if statements where applicable to allow unindenting code a little bit.
This commit is contained in:
parent
e88cdcc912
commit
efbcff0af0
@ -107,42 +107,41 @@ static ContentRecordType GetCRTypeFromNCAType(NCAContentType type) {
|
|||||||
VirtualFile RegisteredCache::OpenFileOrDirectoryConcat(const VirtualDir& dir,
|
VirtualFile RegisteredCache::OpenFileOrDirectoryConcat(const VirtualDir& dir,
|
||||||
std::string_view path) const {
|
std::string_view path) const {
|
||||||
const auto file = dir->GetFileRelative(path);
|
const auto file = dir->GetFileRelative(path);
|
||||||
if (file != nullptr)
|
if (file != nullptr) {
|
||||||
return file;
|
|
||||||
|
|
||||||
const auto nca_dir = dir->GetDirectoryRelative(path);
|
|
||||||
if (nca_dir != nullptr) {
|
|
||||||
const auto nca_dir = dir->GetDirectoryRelative(path);
|
|
||||||
VirtualFile file = nullptr;
|
|
||||||
|
|
||||||
const auto files = nca_dir->GetFiles();
|
|
||||||
if (files.size() == 1 && files[0]->GetName() == "00") {
|
|
||||||
file = files[0];
|
|
||||||
} else {
|
|
||||||
std::vector<VirtualFile> concat;
|
|
||||||
// Since the files are a two-digit hex number, max is FF.
|
|
||||||
for (std::size_t i = 0; i < 0x100; ++i) {
|
|
||||||
auto next = nca_dir->GetFile(fmt::format("{:02X}", i));
|
|
||||||
if (next != nullptr) {
|
|
||||||
concat.push_back(std::move(next));
|
|
||||||
} else {
|
|
||||||
next = nca_dir->GetFile(fmt::format("{:02x}", i));
|
|
||||||
if (next != nullptr)
|
|
||||||
concat.push_back(std::move(next));
|
|
||||||
else
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (concat.empty())
|
|
||||||
return nullptr;
|
|
||||||
|
|
||||||
file = ConcatenatedVfsFile::MakeConcatenatedFile(concat, concat.front()->GetName());
|
|
||||||
}
|
|
||||||
|
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
return nullptr;
|
|
||||||
|
const auto nca_dir = dir->GetDirectoryRelative(path);
|
||||||
|
if (nca_dir == nullptr) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto files = nca_dir->GetFiles();
|
||||||
|
if (files.size() == 1 && files[0]->GetName() == "00") {
|
||||||
|
return files[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<VirtualFile> concat;
|
||||||
|
// Since the files are a two-digit hex number, max is FF.
|
||||||
|
for (std::size_t i = 0; i < 0x100; ++i) {
|
||||||
|
auto next = nca_dir->GetFile(fmt::format("{:02X}", i));
|
||||||
|
if (next != nullptr) {
|
||||||
|
concat.push_back(std::move(next));
|
||||||
|
} else {
|
||||||
|
next = nca_dir->GetFile(fmt::format("{:02x}", i));
|
||||||
|
if (next != nullptr) {
|
||||||
|
concat.push_back(std::move(next));
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (concat.empty()) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ConcatenatedVfsFile::MakeConcatenatedFile(concat, concat.front()->GetName());
|
||||||
}
|
}
|
||||||
|
|
||||||
VirtualFile RegisteredCache::GetFileAtID(NcaID id) const {
|
VirtualFile RegisteredCache::GetFileAtID(NcaID id) const {
|
||||||
|
Loading…
Reference in New Issue
Block a user