summaryrefslogtreecommitdiff
path: root/src/core/file_sys
diff options
context:
space:
mode:
authorGravatar Lioncash2018-08-15 23:16:11 -0400
committerGravatar Lioncash2018-08-15 23:24:00 -0400
commitb39cd70cd4a78903506d987080fe5e4a0e990f2d (patch)
tree64b90ace1c02e926a94d4b6dfa37377503dbca26 /src/core/file_sys
parentMerge pull request #1005 from DarkLordZach/registered-fmt (diff)
downloadyuzu-b39cd70cd4a78903506d987080fe5e4a0e990f2d.tar.gz
yuzu-b39cd70cd4a78903506d987080fe5e4a0e990f2d.tar.xz
yuzu-b39cd70cd4a78903506d987080fe5e4a0e990f2d.zip
common: Namespace hex_util.h/.cpp
It's in the common code, so it should be under the Common namespace like everything else.
Diffstat (limited to 'src/core/file_sys')
-rw-r--r--src/core/file_sys/registered_cache.cpp18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/core/file_sys/registered_cache.cpp b/src/core/file_sys/registered_cache.cpp
index a5e935f64..d25eeee34 100644
--- a/src/core/file_sys/registered_cache.cpp
+++ b/src/core/file_sys/registered_cache.cpp
@@ -37,11 +37,12 @@ static bool FollowsNcaIdFormat(std::string_view name) {
37static std::string GetRelativePathFromNcaID(const std::array<u8, 16>& nca_id, bool second_hex_upper, 37static std::string GetRelativePathFromNcaID(const std::array<u8, 16>& nca_id, bool second_hex_upper,
38 bool within_two_digit) { 38 bool within_two_digit) {
39 if (!within_two_digit) 39 if (!within_two_digit)
40 return fmt::format("/{}.nca", HexArrayToString(nca_id, second_hex_upper)); 40 return fmt::format("/{}.nca", Common::HexArrayToString(nca_id, second_hex_upper));
41 41
42 Core::Crypto::SHA256Hash hash{}; 42 Core::Crypto::SHA256Hash hash{};
43 mbedtls_sha256(nca_id.data(), nca_id.size(), hash.data(), 0); 43 mbedtls_sha256(nca_id.data(), nca_id.size(), hash.data(), 0);
44 return fmt::format("/000000{:02X}/{}.nca", hash[0], HexArrayToString(nca_id, second_hex_upper)); 44 return fmt::format("/000000{:02X}/{}.nca", hash[0],
45 Common::HexArrayToString(nca_id, second_hex_upper));
45} 46}
46 47
47static std::string GetCNMTName(TitleType type, u64 title_id) { 48static std::string GetCNMTName(TitleType type, u64 title_id) {
@@ -170,7 +171,7 @@ std::vector<NcaID> RegisteredCache::AccumulateFiles() const {
170 std::vector<NcaID> ids; 171 std::vector<NcaID> ids;
171 for (const auto& d2_dir : dir->GetSubdirectories()) { 172 for (const auto& d2_dir : dir->GetSubdirectories()) {
172 if (FollowsNcaIdFormat(d2_dir->GetName())) { 173 if (FollowsNcaIdFormat(d2_dir->GetName())) {
173 ids.push_back(HexStringToArray<0x10, true>(d2_dir->GetName().substr(0, 0x20))); 174 ids.push_back(Common::HexStringToArray<0x10, true>(d2_dir->GetName().substr(0, 0x20)));
174 continue; 175 continue;
175 } 176 }
176 177
@@ -181,20 +182,21 @@ std::vector<NcaID> RegisteredCache::AccumulateFiles() const {
181 if (!FollowsNcaIdFormat(nca_dir->GetName())) 182 if (!FollowsNcaIdFormat(nca_dir->GetName()))
182 continue; 183 continue;
183 184
184 ids.push_back(HexStringToArray<0x10, true>(nca_dir->GetName().substr(0, 0x20))); 185 ids.push_back(Common::HexStringToArray<0x10, true>(nca_dir->GetName().substr(0, 0x20)));
185 } 186 }
186 187
187 for (const auto& nca_file : d2_dir->GetFiles()) { 188 for (const auto& nca_file : d2_dir->GetFiles()) {
188 if (!FollowsNcaIdFormat(nca_file->GetName())) 189 if (!FollowsNcaIdFormat(nca_file->GetName()))
189 continue; 190 continue;
190 191
191 ids.push_back(HexStringToArray<0x10, true>(nca_file->GetName().substr(0, 0x20))); 192 ids.push_back(
193 Common::HexStringToArray<0x10, true>(nca_file->GetName().substr(0, 0x20)));
192 } 194 }
193 } 195 }
194 196
195 for (const auto& d2_file : dir->GetFiles()) { 197 for (const auto& d2_file : dir->GetFiles()) {
196 if (FollowsNcaIdFormat(d2_file->GetName())) 198 if (FollowsNcaIdFormat(d2_file->GetName()))
197 ids.push_back(HexStringToArray<0x10, true>(d2_file->GetName().substr(0, 0x20))); 199 ids.push_back(Common::HexStringToArray<0x10, true>(d2_file->GetName().substr(0, 0x20)));
198 } 200 }
199 return ids; 201 return ids;
200} 202}
@@ -339,7 +341,7 @@ std::vector<RegisteredCacheEntry> RegisteredCache::ListEntriesFilter(
339} 341}
340 342
341static std::shared_ptr<NCA> GetNCAFromXCIForID(std::shared_ptr<XCI> xci, const NcaID& id) { 343static std::shared_ptr<NCA> GetNCAFromXCIForID(std::shared_ptr<XCI> xci, const NcaID& id) {
342 const auto filename = fmt::format("{}.nca", HexArrayToString(id, false)); 344 const auto filename = fmt::format("{}.nca", Common::HexArrayToString(id, false));
343 const auto iter = 345 const auto iter =
344 std::find_if(xci->GetNCAs().begin(), xci->GetNCAs().end(), 346 std::find_if(xci->GetNCAs().begin(), xci->GetNCAs().end(),
345 [&filename](std::shared_ptr<NCA> nca) { return nca->GetName() == filename; }); 347 [&filename](std::shared_ptr<NCA> nca) { return nca->GetName() == filename; });
@@ -361,7 +363,7 @@ InstallResult RegisteredCache::InstallEntry(std::shared_ptr<XCI> xci, bool overw
361 363
362 // Install Metadata File 364 // Install Metadata File
363 const auto meta_id_raw = (*meta_iter)->GetName().substr(0, 32); 365 const auto meta_id_raw = (*meta_iter)->GetName().substr(0, 32);
364 const auto meta_id = HexStringToArray<16>(meta_id_raw); 366 const auto meta_id = Common::HexStringToArray<16>(meta_id_raw);
365 367
366 const auto res = RawInstallNCA(*meta_iter, copy, overwrite_if_exists, meta_id); 368 const auto res = RawInstallNCA(*meta_iter, copy, overwrite_if_exists, meta_id);
367 if (res != InstallResult::Success) 369 if (res != InstallResult::Success)