From 167bfddafadb843236c0fa683cf97eaffaa5ea1a Mon Sep 17 00:00:00 2001 From: Zach Hilman Date: Thu, 9 Aug 2018 23:10:32 -0400 Subject: file_sys: Comply to style guidelines --- src/core/file_sys/registered_cache.cpp | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'src/core/file_sys/registered_cache.cpp') diff --git a/src/core/file_sys/registered_cache.cpp b/src/core/file_sys/registered_cache.cpp index 766fef254..3e7706171 100644 --- a/src/core/file_sys/registered_cache.cpp +++ b/src/core/file_sys/registered_cache.cpp @@ -23,13 +23,13 @@ bool operator<(const RegisteredCacheEntry& lhs, const RegisteredCacheEntry& rhs) } static bool FollowsTwoDigitDirFormat(std::string_view name) { - const static std::regex two_digit_regex( + static const std::regex two_digit_regex( "000000[0123456789abcdefABCDEF][0123456789abcdefABCDEF]"); return std::regex_match(name.begin(), name.end(), two_digit_regex); } static bool FollowsNcaIdFormat(std::string_view name) { - const static std::regex nca_id_regex("[0123456789abcdefABCDEF]+.nca"); + static const std::regex nca_id_regex("[0123456789abcdefABCDEF]+.nca"); return name.size() == 36 && std::regex_match(name.begin(), name.end(), nca_id_regex); } @@ -56,7 +56,7 @@ static std::string GetCNMTName(TitleType type, u64 title_id) { "" ///< Currently unknown 'DeltaTitle' }; - size_t index = static_cast(type); + auto index = static_cast(type); if (index >= 0x80) index -= 0x80; return fmt::format("{}_{:016x}.cnmt", TITLE_TYPE_NAMES[index], title_id); @@ -90,15 +90,15 @@ VirtualFile RegisteredCache::OpenFileOrDirectoryConcat(const VirtualDir& dir, VirtualFile file = nullptr; const auto files = nca_dir->GetFiles(); - if (files.size() == 1 && files[0]->GetName() == "00") + if (files.size() == 1 && files[0]->GetName() == "00") { file = files[0]; - else { + } else { std::vector concat; for (u8 i = 0; i < 0x10; ++i) { auto next = nca_dir->GetFile(fmt::format("{:02X}", i)); - if (next != nullptr) + if (next != nullptr) { concat.push_back(std::move(next)); - else { + } else { next = nca_dir->GetFile(fmt::format("{:02x}", i)); if (next != nullptr) concat.push_back(std::move(next)); @@ -146,7 +146,8 @@ boost::optional RegisteredCache::GetNcaIDFromMetadata(u64 title_id, return boost::make_optional(iter->nca_id); } -void RegisteredCache::AccumulateFiles(std::vector& ids) const { +std::vector RegisteredCache::AccumulateFiles() const { + std::vector ids; for (const auto& d2_dir : dir->GetSubdirectories()) { if (FollowsNcaIdFormat(d2_dir->GetName())) { ids.push_back(HexStringToArray<0x10, true>(d2_dir->GetName().substr(0, 0x20))); @@ -175,6 +176,7 @@ void RegisteredCache::AccumulateFiles(std::vector& ids) const { if (FollowsNcaIdFormat(d2_file->GetName())) ids.push_back(HexStringToArray<0x10, true>(d2_file->GetName().substr(0, 0x20))); } + return ids; } void RegisteredCache::ProcessFiles(const std::vector& ids) { @@ -185,8 +187,9 @@ void RegisteredCache::ProcessFiles(const std::vector& ids) { continue; const auto nca = std::make_shared(parser(file, id)); if (nca->GetStatus() != Loader::ResultStatus::Success || - nca->GetType() != NCAContentType::Meta) + nca->GetType() != NCAContentType::Meta) { continue; + } const auto section0 = nca->GetSubdirectories()[0]; @@ -218,8 +221,7 @@ void RegisteredCache::AccumulateYuzuMeta() { void RegisteredCache::Refresh() { if (dir == nullptr) return; - std::vector ids; - AccumulateFiles(ids); + const auto ids = AccumulateFiles(); ProcessFiles(ids); AccumulateYuzuMeta(); } -- cgit v1.2.3