diff --git a/Source/Core/Core/IOS/ES/ES.h b/Source/Core/Core/IOS/ES/ES.h index e6287e6826..9695fd43c8 100644 --- a/Source/Core/Core/IOS/ES/ES.h +++ b/Source/Core/Core/IOS/ES/ES.h @@ -339,6 +339,10 @@ private: void FinishStaleImport(u64 title_id); void FinishAllStaleImports(); + std::string GetContentPath(u64 title_id, const IOS::ES::Content& content, + const IOS::ES::SharedContentMap& map = IOS::ES::SharedContentMap{ + Common::FROM_SESSION_ROOT}) const; + // TODO: remove these const DiscIO::NANDContentLoader& AccessContentDevice(u64 title_id); diff --git a/Source/Core/Core/IOS/ES/NandUtils.cpp b/Source/Core/Core/IOS/ES/NandUtils.cpp index a5afa0d571..06c6efdf29 100644 --- a/Source/Core/Core/IOS/ES/NandUtils.cpp +++ b/Source/Core/Core/IOS/ES/NandUtils.cpp @@ -168,21 +168,15 @@ std::vector ES::GetStoredContentsFromTMD(const IOS::ES::TMDRea if (!tmd.IsValid()) return {}; - const IOS::ES::SharedContentMap shared{Common::FROM_SESSION_ROOT}; + const IOS::ES::SharedContentMap map{Common::FROM_SESSION_ROOT}; const std::vector contents = tmd.GetContents(); std::vector stored_contents; std::copy_if(contents.begin(), contents.end(), std::back_inserter(stored_contents), - [&tmd, &shared](const auto& content) { - if (content.IsShared()) - { - const auto path = shared.GetFilenameFromSHA1(content.sha1); - return path && File::Exists(*path); - } - return File::Exists( - Common::GetTitleContentPath(tmd.GetTitleId(), Common::FROM_SESSION_ROOT) + - StringFromFormat("%08x.app", content.id)); + [this, &tmd, &map](const IOS::ES::Content& content) { + const std::string path = GetContentPath(tmd.GetTitleId(), content, map); + return !path.empty() && File::Exists(path); }); return stored_contents; @@ -303,6 +297,16 @@ void ES::FinishAllStaleImports() File::DeleteDirRecursively(import_dir); File::CreateDir(import_dir); } + +std::string ES::GetContentPath(const u64 title_id, const IOS::ES::Content& content, + const IOS::ES::SharedContentMap& content_map) const +{ + if (content.IsShared()) + return content_map.GetFilenameFromSHA1(content.sha1).value_or(""); + + return Common::GetTitleContentPath(title_id, Common::FROM_SESSION_ROOT) + + StringFromFormat("%08x.app", content.id); +} } // namespace Device } // namespace HLE } // namespace IOS