|
|
@ -281,14 +281,14 @@ NcaID PlaceholderCache::Generate() {
|
|
|
|
return out;
|
|
|
|
return out;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
VirtualFile RegisteredCache::OpenFileOrDirectoryConcat(const VirtualDir& dir,
|
|
|
|
VirtualFile RegisteredCache::OpenFileOrDirectoryConcat(const VirtualDir& open_dir,
|
|
|
|
std::string_view path) const {
|
|
|
|
std::string_view path) const {
|
|
|
|
const auto file = dir->GetFileRelative(path);
|
|
|
|
const auto file = open_dir->GetFileRelative(path);
|
|
|
|
if (file != nullptr) {
|
|
|
|
if (file != nullptr) {
|
|
|
|
return file;
|
|
|
|
return file;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const auto nca_dir = dir->GetDirectoryRelative(path);
|
|
|
|
const auto nca_dir = open_dir->GetDirectoryRelative(path);
|
|
|
|
if (nca_dir == nullptr) {
|
|
|
|
if (nca_dir == nullptr) {
|
|
|
|
return nullptr;
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -431,13 +431,15 @@ void RegisteredCache::ProcessFiles(const std::vector<NcaID>& ids) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void RegisteredCache::AccumulateYuzuMeta() {
|
|
|
|
void RegisteredCache::AccumulateYuzuMeta() {
|
|
|
|
const auto dir = this->dir->GetSubdirectory("yuzu_meta");
|
|
|
|
const auto meta_dir = dir->GetSubdirectory("yuzu_meta");
|
|
|
|
if (dir == nullptr)
|
|
|
|
if (meta_dir == nullptr) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for (const auto& file : dir->GetFiles()) {
|
|
|
|
for (const auto& file : meta_dir->GetFiles()) {
|
|
|
|
if (file->GetExtension() != "cnmt")
|
|
|
|
if (file->GetExtension() != "cnmt") {
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
CNMT cnmt(file);
|
|
|
|
CNMT cnmt(file);
|
|
|
|
yuzu_meta.insert_or_assign(cnmt.GetTitleID(), std::move(cnmt));
|
|
|
|
yuzu_meta.insert_or_assign(cnmt.GetTitleID(), std::move(cnmt));
|
|
|
@ -445,8 +447,10 @@ void RegisteredCache::AccumulateYuzuMeta() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void RegisteredCache::Refresh() {
|
|
|
|
void RegisteredCache::Refresh() {
|
|
|
|
if (dir == nullptr)
|
|
|
|
if (dir == nullptr) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const auto ids = AccumulateFiles();
|
|
|
|
const auto ids = AccumulateFiles();
|
|
|
|
ProcessFiles(ids);
|
|
|
|
ProcessFiles(ids);
|
|
|
|
AccumulateYuzuMeta();
|
|
|
|
AccumulateYuzuMeta();
|
|
|
@ -566,7 +570,7 @@ InstallResult RegisteredCache::InstallEntry(const NSP& nsp, bool overwrite_if_ex
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const auto meta_id_raw = (*meta_iter)->GetName().substr(0, 32);
|
|
|
|
const auto meta_id_raw = (*meta_iter)->GetName().substr(0, 32);
|
|
|
|
const auto meta_id = Common::HexStringToArray<16>(meta_id_raw);
|
|
|
|
const auto meta_id_data = Common::HexStringToArray<16>(meta_id_raw);
|
|
|
|
|
|
|
|
|
|
|
|
if ((*meta_iter)->GetSubdirectories().empty()) {
|
|
|
|
if ((*meta_iter)->GetSubdirectories().empty()) {
|
|
|
|
LOG_ERROR(Loader,
|
|
|
|
LOG_ERROR(Loader,
|
|
|
@ -591,7 +595,7 @@ InstallResult RegisteredCache::InstallEntry(const NSP& nsp, bool overwrite_if_ex
|
|
|
|
const auto result = RemoveExistingEntry(title_id);
|
|
|
|
const auto result = RemoveExistingEntry(title_id);
|
|
|
|
|
|
|
|
|
|
|
|
// Install Metadata File
|
|
|
|
// Install Metadata File
|
|
|
|
const auto res = RawInstallNCA(**meta_iter, copy, overwrite_if_exists, meta_id);
|
|
|
|
const auto res = RawInstallNCA(**meta_iter, copy, overwrite_if_exists, meta_id_data);
|
|
|
|
if (res != InstallResult::Success) {
|
|
|
|
if (res != InstallResult::Success) {
|
|
|
|
return res;
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -741,15 +745,15 @@ InstallResult RegisteredCache::RawInstallNCA(const NCA& nca, const VfsCopyFuncti
|
|
|
|
|
|
|
|
|
|
|
|
bool RegisteredCache::RawInstallYuzuMeta(const CNMT& cnmt) {
|
|
|
|
bool RegisteredCache::RawInstallYuzuMeta(const CNMT& cnmt) {
|
|
|
|
// Reasoning behind this method can be found in the comment for InstallEntry, NCA overload.
|
|
|
|
// Reasoning behind this method can be found in the comment for InstallEntry, NCA overload.
|
|
|
|
const auto dir = this->dir->CreateDirectoryRelative("yuzu_meta");
|
|
|
|
const auto meta_dir = dir->CreateDirectoryRelative("yuzu_meta");
|
|
|
|
const auto filename = GetCNMTName(cnmt.GetType(), cnmt.GetTitleID());
|
|
|
|
const auto filename = GetCNMTName(cnmt.GetType(), cnmt.GetTitleID());
|
|
|
|
if (dir->GetFile(filename) == nullptr) {
|
|
|
|
if (meta_dir->GetFile(filename) == nullptr) {
|
|
|
|
auto out = dir->CreateFile(filename);
|
|
|
|
auto out = meta_dir->CreateFile(filename);
|
|
|
|
const auto buffer = cnmt.Serialize();
|
|
|
|
const auto buffer = cnmt.Serialize();
|
|
|
|
out->Resize(buffer.size());
|
|
|
|
out->Resize(buffer.size());
|
|
|
|
out->WriteBytes(buffer);
|
|
|
|
out->WriteBytes(buffer);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
auto out = dir->GetFile(filename);
|
|
|
|
auto out = meta_dir->GetFile(filename);
|
|
|
|
CNMT old_cnmt(out);
|
|
|
|
CNMT old_cnmt(out);
|
|
|
|
// Returns true on change
|
|
|
|
// Returns true on change
|
|
|
|
if (old_cnmt.UnionRecords(cnmt)) {
|
|
|
|
if (old_cnmt.UnionRecords(cnmt)) {
|
|
|
|