summaryrefslogtreecommitdiffstats
path: root/src/core/file_sys/registered_cache.cpp
diff options
context:
space:
mode:
authorZach Hilman <zachhilman@gmail.com>2018-08-11 21:39:09 +0200
committerZach Hilman <zachhilman@gmail.com>2018-08-12 04:50:48 +0200
commit893447b6b0f5068f3cc2111b5f21c3cff68002e2 (patch)
treef2451fcb2478243621b6952ca5b006f22f957022 /src/core/file_sys/registered_cache.cpp
parentnca_metadata: Remove unnecessary reference to base file (diff)
downloadyuzu-893447b6b0f5068f3cc2111b5f21c3cff68002e2.tar
yuzu-893447b6b0f5068f3cc2111b5f21c3cff68002e2.tar.gz
yuzu-893447b6b0f5068f3cc2111b5f21c3cff68002e2.tar.bz2
yuzu-893447b6b0f5068f3cc2111b5f21c3cff68002e2.tar.lz
yuzu-893447b6b0f5068f3cc2111b5f21c3cff68002e2.tar.xz
yuzu-893447b6b0f5068f3cc2111b5f21c3cff68002e2.tar.zst
yuzu-893447b6b0f5068f3cc2111b5f21c3cff68002e2.zip
Diffstat (limited to 'src/core/file_sys/registered_cache.cpp')
-rw-r--r--src/core/file_sys/registered_cache.cpp23
1 files changed, 16 insertions, 7 deletions
diff --git a/src/core/file_sys/registered_cache.cpp b/src/core/file_sys/registered_cache.cpp
index aaadb7463..20fec2391 100644
--- a/src/core/file_sys/registered_cache.cpp
+++ b/src/core/file_sys/registered_cache.cpp
@@ -23,13 +23,14 @@ bool operator<(const RegisteredCacheEntry& lhs, const RegisteredCacheEntry& rhs)
}
static bool FollowsTwoDigitDirFormat(std::string_view name) {
- static const std::regex two_digit_regex(
- "000000[0123456789abcdefABCDEF][0123456789abcdefABCDEF]");
+ static const std::regex two_digit_regex("000000[0-9A-F]{2}", std::regex_constants::ECMAScript |
+ std::regex_constants::icase);
return std::regex_match(name.begin(), name.end(), two_digit_regex);
}
static bool FollowsNcaIdFormat(std::string_view name) {
- static const std::regex nca_id_regex("[0123456789abcdefABCDEF]+.nca");
+ static const std::regex nca_id_regex("[0-9A-F]{32}.nca", std::regex_constants::ECMAScript |
+ std::regex_constants::icase);
return name.size() == 36 && std::regex_match(name.begin(), name.end(), nca_id_regex);
}
@@ -57,8 +58,9 @@ static std::string GetCNMTName(TitleType type, u64 title_id) {
};
auto index = static_cast<size_t>(type);
- if (index >= 0x80)
- index -= 0x80;
+ // If the index is after the jump in TitleType, subtract it out.
+ if (index >= static_cast<size_t>(TitleType::Application))
+ index -= static_cast<size_t>(TitleType::Application);
return fmt::format("{}_{:016x}.cnmt", TITLE_TYPE_NAMES[index], title_id);
}
@@ -120,9 +122,15 @@ VirtualFile RegisteredCache::OpenFileOrDirectoryConcat(const VirtualDir& dir,
VirtualFile RegisteredCache::GetFileAtID(NcaID id) const {
VirtualFile file;
+ // Try all four modes of file storage:
+ // (bit 1 = uppercase/lower, bit 0 = within a two-digit dir)
+ // 00: /000000**/{:032X}.nca
+ // 01: /{:032X}.nca
+ // 10: /000000**/{:032x}.nca
+ // 11: /{:032x}.nca
for (u8 i = 0; i < 4; ++i) {
- file = OpenFileOrDirectoryConcat(
- dir, GetRelativePathFromNcaID(id, (i & 0b10) == 0, (i & 0b01) == 0));
+ const auto path = GetRelativePathFromNcaID(id, (i & 0b10) == 0, (i & 0b01) == 0);
+ file = OpenFileOrDirectoryConcat(dir, path);
if (file != nullptr)
return file;
}
@@ -420,6 +428,7 @@ bool RegisteredCache::RawInstallNCA(std::shared_ptr<NCA> nca, const VfsCopyFunct
}
bool RegisteredCache::RawInstallYuzuMeta(const CNMT& cnmt) {
+ // Reasoning behind this method can be found in the comment for InstallEntry, NCA overload.
const auto dir = this->dir->CreateDirectoryRelative("yuzu_meta");
const auto filename = GetCNMTName(cnmt.GetType(), cnmt.GetTitleID());
if (dir->GetFile(filename) == nullptr) {