ASSERT_OK(ncmOpenContentMetaDatabase(&contentMetaDatabase,m_destStorageId),"Failed to open content meta database");
ASSERT_OK(ncmContentMetaDatabaseSet(&contentMetaDatabase,&contentMetaKey,(NcmContentMetaHeader*)installContentMetaBuf.GetData(),installContentMetaBuf.GetSize()),"Failed to set content records");
ASSERT_OK(ncmContentMetaDatabaseCommit(&contentMetaDatabase),"Failed to commit content records");
ASSERT_OK(nsListApplicationRecordContentMeta(0,baseTitleId,contentStorageBuf.get(),contentStorageBufSize,&entriesRead),"Failed to list application record content meta");
if(entriesRead!=contentMetaCount)
{
throwstd::runtime_error("Mismatch between entries read and content meta count");
// Replace the existing application records with our own
try
{
nsDeleteApplicationRecord(baseTitleId);
}
catch(...){}
printf("Pushing application record...\n");
ASSERT_OK(nsPushApplicationRecord(baseTitleId,0x3,storageRecords.data(),storageRecords.size()*sizeof(ContentStorageRecord)),"Failed to push application record");
ASSERT_OK(ncmOpenContentMetaDatabase(&contentMetaDatabase,m_destStorageId),"Failed to open content meta database");
ASSERT_OK(ncmContentMetaDatabaseGetLatestContentMetaKey(&contentMetaDatabase,&latestApplicationContentMetaKey,baseTitleId),"Failed to get latest application content meta key");
try
{
ASSERT_OK(ncmContentMetaDatabaseGetLatestContentMetaKey(&contentMetaDatabase,&latestPatchContentMetaKey,updateTitleId),"Failed to get latest patch content meta key");
}
catch(std::exception&e)
{
hasUpdate=false;
}
u64appContentRecordSize;
u64appContentRecordSizeRead;
ASSERT_OK(ncmContentMetaDatabaseGetSize(&contentMetaDatabase,&appContentRecordSize,&latestApplicationContentMetaKey),"Failed to get application content record size");
ASSERT_OK(ncmContentMetaDatabaseGet(&contentMetaDatabase,&latestApplicationContentMetaKey,&appContentRecordSizeRead,(NcmContentMetaHeader*)appContentRecordBuf.get(),appContentRecordSizeRead),"Failed to get app content record size");
ASSERT_OK(ncmContentMetaDatabaseGetSize(&contentMetaDatabase,&patchContentRecordsSize,&latestPatchContentMetaKey),"Failed to get patch content record size");
ASSERT_OK(ncmContentMetaDatabaseGet(&contentMetaDatabase,&latestPatchContentMetaKey,&patchContentRecordSizeRead,(NcmContentMetaHeader*)patchContentRecordBuf.get(),patchContentRecordsSize),"Failed to get patch content record size");
printf("No update records found, or an error occurred.\n");
}
autoappRecordBuf=std::make_unique<u8[]>(0x100);
u32numEntriesRead;
ASSERT_OK(nsListApplicationRecordContentMeta(0,baseTitleId,appRecordBuf.get(),0x100,&numEntriesRead),"Failed to list application record content meta");