Services/AM: Add GetTitleMediaType

This commit is contained in:
shinyquagsire23 2017-11-14 14:57:44 -07:00
parent f55f4fc684
commit 1edbbf7f8c
2 changed files with 25 additions and 0 deletions

View file

@ -37,6 +37,10 @@
namespace Service {
namespace AM {
constexpr u16 PLATFORM_CTR = 0x0004;
constexpr u16 CATEGORY_SYSTEM = 0x0010;
constexpr u16 CATEGORY_DLP = 0x0001;
constexpr u8 VARIATION_SYSTEM = 0x02;
constexpr u32 TID_HIGH_UPDATE = 0x0004000E;
constexpr u32 TID_HIGH_DLC = 0x0004008C;
@ -263,6 +267,20 @@ private:
Service::FS::MediaType media_type;
};
Service::FS::MediaType GetTitleMediaType(u64 titleId) {
u16 platform = static_cast<u16>(titleId >> 48);
u16 category = static_cast<u16>((titleId >> 32) & 0xFFFF);
u8 variation = static_cast<u8>(titleId & 0xFF);
if (platform != PLATFORM_CTR)
return Service::FS::MediaType::NAND;
if (category & CATEGORY_SYSTEM || category & CATEGORY_DLP || variation & VARIATION_SYSTEM)
return Service::FS::MediaType::NAND;
return Service::FS::MediaType::SDMC;
}
std::string GetTitleMetadataPath(Service::FS::MediaType media_type, u64 tid, bool update) {
std::string content_path = GetTitlePath(media_type, tid) + "content/";

View file

@ -38,6 +38,13 @@ enum class CIAInstallState : u32 {
ContentWritten,
};
/**
* Get the mediatype for an installed title
* @param titleId the installed title ID
* @returns MediaType which the installed title will reside on
*/
Service::FS::MediaType GetTitleMediaType(u64 titleId);
/**
* Get the .tmd path for a title
* @param media_type the media the title exists on