More detailed error messages when encrypted titles fail to launch

This commit is contained in:
Exzap 2023-09-27 12:38:51 +02:00
parent 5ad57bb0c9
commit f6c3c96d94
5 changed files with 81 additions and 15 deletions

View file

@ -77,6 +77,7 @@ TitleInfo::TitleInfo(const fs::path& path, std::string_view subPath)
if (!path.has_filename())
{
m_isValid = false;
SetInvalidReason(InvalidReason::BAD_PATH_OR_INACCESSIBLE);
return;
}
m_isValid = true;
@ -269,6 +270,7 @@ bool TitleInfo::DetectFormat(const fs::path& path, fs::path& pathOut, TitleDataF
return true;
}
}
SetInvalidReason(InvalidReason::UNKNOWN_FORMAT);
return false;
}
@ -321,6 +323,12 @@ uint64 TitleInfo::GetUID()
return m_uid;
}
void TitleInfo::SetInvalidReason(InvalidReason reason)
{
if(m_invalidReason == InvalidReason::NONE)
m_invalidReason = reason; // only update reason when it hasn't been set before
}
std::mutex sZArchivePoolMtx;
std::map<fs::path, std::pair<uint32, ZArchiveReader*>> sZArchivePool;
@ -382,21 +390,29 @@ bool TitleInfo::Mount(std::string_view virtualPath, std::string_view subfolder,
if (!r)
{
cemuLog_log(LogType::Force, "Failed to mount {} to {}", virtualPath, subfolder);
SetInvalidReason(InvalidReason::BAD_PATH_OR_INACCESSIBLE);
return false;
}
}
else if (m_titleFormat == TitleDataFormat::WUD || m_titleFormat == TitleDataFormat::NUS)
{
FSTVolume::ErrorCode fstError;
if (m_mountpoints.empty())
{
cemu_assert_debug(!m_wudVolume);
if(m_titleFormat == TitleDataFormat::WUD)
m_wudVolume = FSTVolume::OpenFromDiscImage(m_fullPath); // open wud/wux
m_wudVolume = FSTVolume::OpenFromDiscImage(m_fullPath, &fstError); // open wud/wux
else
m_wudVolume = FSTVolume::OpenFromContentFolder(m_fullPath.parent_path()); // open from .app files directory, the path points to /title.tmd
m_wudVolume = FSTVolume::OpenFromContentFolder(m_fullPath.parent_path(), &fstError); // open from .app files directory, the path points to /title.tmd
}
if (!m_wudVolume)
{
if (fstError == FSTVolume::ErrorCode::DISC_KEY_MISSING)
SetInvalidReason(InvalidReason::NO_DISC_KEY);
else if (fstError == FSTVolume::ErrorCode::TITLE_TIK_MISSING)
SetInvalidReason(InvalidReason::NO_TITLE_TIK);
return false;
}
bool r = FSCDeviceWUD_Mount(virtualPath, subfolder, m_wudVolume, mountPriority);
cemu_assert_debug(r);
if (!r)
@ -518,6 +534,7 @@ bool TitleInfo::ParseXmlInfo()
m_parsedAppXml = nullptr;
m_parsedCosXml = nullptr;
m_isValid = false;
SetInvalidReason(InvalidReason::MISSING_XML_FILES);
return false;
}
m_isValid = true;