IOS/ES: Add functions to get TMDs

This commit is contained in:
Léo Lam 2017-03-12 21:05:13 +01:00
parent 194b0ae36d
commit 0ed8d68192
2 changed files with 26 additions and 0 deletions

View File

@ -18,6 +18,29 @@ namespace IOS
{
namespace ES
{
static TMDReader FindTMD(u64 title_id, const std::string& tmd_path)
{
File::IOFile file(tmd_path, "rb");
if (!file)
return {};
std::vector<u8> tmd_bytes(file.GetSize());
if (!file.ReadBytes(tmd_bytes.data(), tmd_bytes.size()))
return {};
return TMDReader{std::move(tmd_bytes)};
}
TMDReader FindImportTMD(u64 title_id)
{
return FindTMD(title_id, Common::GetImportTitlePath(title_id) + "/content/title.tmd");
}
TMDReader FindInstalledTMD(u64 title_id)
{
return FindTMD(title_id, Common::GetTMDFileName(title_id, Common::FROM_SESSION_ROOT));
}
static bool IsValidPartOfTitleID(const std::string& string)
{
if (string.length() != 8)

View File

@ -13,6 +13,9 @@ namespace IOS
{
namespace ES
{
TMDReader FindImportTMD(u64 title_id);
TMDReader FindInstalledTMD(u64 title_id);
// Get installed titles (in /title) without checking for TMDs at all.
std::vector<u64> GetInstalledTitles();
// Get titles which are being imported (in /import) without checking for TMDs at all.