summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Lioncash2018-12-01 23:50:10 -0500
committerGravatar Lioncash2018-12-01 23:50:13 -0500
commitefbcff0af0b9eadf7dc1e07a75c5886469903ddd (patch)
tree74aeeab2f298da0e8073d9e7d5435efd9b59827c /src
parentFix debug build (diff)
downloadyuzu-efbcff0af0b9eadf7dc1e07a75c5886469903ddd.tar.gz
yuzu-efbcff0af0b9eadf7dc1e07a75c5886469903ddd.tar.xz
yuzu-efbcff0af0b9eadf7dc1e07a75c5886469903ddd.zip
file_sys/registered_cache: Eliminate variable shadowing
Also inverts if statements where applicable to allow unindenting code a little bit.
Diffstat (limited to 'src')
-rw-r--r--src/core/file_sys/registered_cache.cpp53
1 files changed, 26 insertions, 27 deletions
diff --git a/src/core/file_sys/registered_cache.cpp b/src/core/file_sys/registered_cache.cpp
index 07c3af64a..128199063 100644
--- a/src/core/file_sys/registered_cache.cpp
+++ b/src/core/file_sys/registered_cache.cpp
@@ -107,42 +107,41 @@ static ContentRecordType GetCRTypeFromNCAType(NCAContentType type) {
107VirtualFile RegisteredCache::OpenFileOrDirectoryConcat(const VirtualDir& dir, 107VirtualFile RegisteredCache::OpenFileOrDirectoryConcat(const VirtualDir& dir,
108 std::string_view path) const { 108 std::string_view path) const {
109 const auto file = dir->GetFileRelative(path); 109 const auto file = dir->GetFileRelative(path);
110 if (file != nullptr) 110 if (file != nullptr) {
111 return file; 111 return file;
112 }
112 113
113 const auto nca_dir = dir->GetDirectoryRelative(path); 114 const auto nca_dir = dir->GetDirectoryRelative(path);
114 if (nca_dir != nullptr) { 115 if (nca_dir == nullptr) {
115 const auto nca_dir = dir->GetDirectoryRelative(path); 116 return nullptr;
116 VirtualFile file = nullptr; 117 }
117 118
118 const auto files = nca_dir->GetFiles(); 119 const auto files = nca_dir->GetFiles();
119 if (files.size() == 1 && files[0]->GetName() == "00") { 120 if (files.size() == 1 && files[0]->GetName() == "00") {
120 file = files[0]; 121 return files[0];
122 }
123
124 std::vector<VirtualFile> concat;
125 // Since the files are a two-digit hex number, max is FF.
126 for (std::size_t i = 0; i < 0x100; ++i) {
127 auto next = nca_dir->GetFile(fmt::format("{:02X}", i));
128 if (next != nullptr) {
129 concat.push_back(std::move(next));
121 } else { 130 } else {
122 std::vector<VirtualFile> concat; 131 next = nca_dir->GetFile(fmt::format("{:02x}", i));
123 // Since the files are a two-digit hex number, max is FF. 132 if (next != nullptr) {
124 for (std::size_t i = 0; i < 0x100; ++i) { 133 concat.push_back(std::move(next));
125 auto next = nca_dir->GetFile(fmt::format("{:02X}", i)); 134 } else {
126 if (next != nullptr) { 135 break;
127 concat.push_back(std::move(next));
128 } else {
129 next = nca_dir->GetFile(fmt::format("{:02x}", i));
130 if (next != nullptr)
131 concat.push_back(std::move(next));
132 else
133 break;
134 }
135 } 136 }
136
137 if (concat.empty())
138 return nullptr;
139
140 file = ConcatenatedVfsFile::MakeConcatenatedFile(concat, concat.front()->GetName());
141 } 137 }
138 }
142 139
143 return file; 140 if (concat.empty()) {
141 return nullptr;
144 } 142 }
145 return nullptr; 143
144 return ConcatenatedVfsFile::MakeConcatenatedFile(concat, concat.front()->GetName());
146} 145}
147 146
148VirtualFile RegisteredCache::GetFileAtID(NcaID id) const { 147VirtualFile RegisteredCache::GetFileAtID(NcaID id) const {