mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-03-10 19:47:40 +01:00
IOS/ES: Refactor GetTitles into a utility function
This commit is contained in:
parent
1525396ecf
commit
52e8486b7c
@ -911,7 +911,7 @@ static std::vector<u64> GetInstalledTitles()
|
|||||||
|
|
||||||
// The /title directory contains one directory per title type, and each of them contains
|
// The /title directory contains one directory per title type, and each of them contains
|
||||||
// a directory per title (where the name is the low 32 bits of the title ID in %08x format).
|
// a directory per title (where the name is the low 32 bits of the title ID in %08x format).
|
||||||
const auto& entries = File::ScanDirectoryTree(titles_dir, true);
|
const auto entries = File::ScanDirectoryTree(titles_dir, true);
|
||||||
for (const File::FSTEntry& title_type : entries.children)
|
for (const File::FSTEntry& title_type : entries.children)
|
||||||
{
|
{
|
||||||
if (!title_type.isDirectory || !IsValidPartOfTitleID(title_type.virtualName))
|
if (!title_type.isDirectory || !IsValidPartOfTitleID(title_type.virtualName))
|
||||||
@ -948,7 +948,7 @@ static std::vector<u64> GetTitlesWithTickets()
|
|||||||
|
|
||||||
// The /ticket directory contains one directory per title type, and each of them contains
|
// The /ticket directory contains one directory per title type, and each of them contains
|
||||||
// one ticket per title (where the name is the low 32 bits of the title ID in %08x format).
|
// one ticket per title (where the name is the low 32 bits of the title ID in %08x format).
|
||||||
const auto& entries = File::ScanDirectoryTree(titles_dir, true);
|
const auto entries = File::ScanDirectoryTree(titles_dir, true);
|
||||||
for (const File::FSTEntry& title_type : entries.children)
|
for (const File::FSTEntry& title_type : entries.children)
|
||||||
{
|
{
|
||||||
if (!title_type.isDirectory || !IsValidPartOfTitleID(title_type.virtualName))
|
if (!title_type.isDirectory || !IsValidPartOfTitleID(title_type.virtualName))
|
||||||
@ -975,36 +975,42 @@ static std::vector<u64> GetTitlesWithTickets()
|
|||||||
return title_ids;
|
return title_ids;
|
||||||
}
|
}
|
||||||
|
|
||||||
IPCCommandResult ES::GetTitleCount(const IOCtlVRequest& request)
|
IPCCommandResult ES::GetTitleCount(const std::vector<u64>& titles, const IOCtlVRequest& request)
|
||||||
{
|
{
|
||||||
if (!request.HasNumberOfValidVectors(0, 1) || request.io_vectors[0].size != 4)
|
if (!request.HasNumberOfValidVectors(0, 1) || request.io_vectors[0].size != 4)
|
||||||
return GetDefaultReply(ES_PARAMETER_SIZE_OR_ALIGNMENT);
|
return GetDefaultReply(ES_PARAMETER_SIZE_OR_ALIGNMENT);
|
||||||
|
|
||||||
const std::vector<u64> titles = GetInstalledTitles();
|
|
||||||
|
|
||||||
Memory::Write_U32(static_cast<u32>(titles.size()), request.io_vectors[0].address);
|
Memory::Write_U32(static_cast<u32>(titles.size()), request.io_vectors[0].address);
|
||||||
|
|
||||||
INFO_LOG(IOS_ES, "GetTitleCount: %zu titles", titles.size());
|
|
||||||
|
|
||||||
return GetDefaultReply(IPC_SUCCESS);
|
return GetDefaultReply(IPC_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
IPCCommandResult ES::GetTitles(const IOCtlVRequest& request)
|
IPCCommandResult ES::GetTitles(const std::vector<u64>& titles, const IOCtlVRequest& request)
|
||||||
{
|
{
|
||||||
if (!request.HasNumberOfValidVectors(1, 1))
|
if (!request.HasNumberOfValidVectors(1, 1))
|
||||||
return GetDefaultReply(ES_PARAMETER_SIZE_OR_ALIGNMENT);
|
return GetDefaultReply(ES_PARAMETER_SIZE_OR_ALIGNMENT);
|
||||||
|
|
||||||
const std::vector<u64> titles = GetInstalledTitles();
|
|
||||||
|
|
||||||
const size_t max_count = Memory::Read_U32(request.in_vectors[0].address);
|
const size_t max_count = Memory::Read_U32(request.in_vectors[0].address);
|
||||||
for (size_t i = 0; i < std::min(max_count, titles.size()); i++)
|
for (size_t i = 0; i < std::min(max_count, titles.size()); i++)
|
||||||
{
|
{
|
||||||
Memory::Write_U64(titles[i], request.io_vectors[0].address + static_cast<u32>(i) * 8);
|
Memory::Write_U64(titles[i], request.io_vectors[0].address + static_cast<u32>(i) * sizeof(u64));
|
||||||
INFO_LOG(IOS_ES, " title %016" PRIx64, titles[i]);
|
INFO_LOG(IOS_ES, " title %016" PRIx64, titles[i]);
|
||||||
}
|
}
|
||||||
return GetDefaultReply(IPC_SUCCESS);
|
return GetDefaultReply(IPC_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IPCCommandResult ES::GetTitleCount(const IOCtlVRequest& request)
|
||||||
|
{
|
||||||
|
const std::vector<u64> titles = GetInstalledTitles();
|
||||||
|
INFO_LOG(IOS_ES, "GetTitleCount: %zu titles", titles.size());
|
||||||
|
return GetTitleCount(titles, request);
|
||||||
|
}
|
||||||
|
|
||||||
|
IPCCommandResult ES::GetTitles(const IOCtlVRequest& request)
|
||||||
|
{
|
||||||
|
return GetTitles(GetInstalledTitles(), request);
|
||||||
|
}
|
||||||
|
|
||||||
IPCCommandResult ES::GetViewCount(const IOCtlVRequest& request)
|
IPCCommandResult ES::GetViewCount(const IOCtlVRequest& request)
|
||||||
{
|
{
|
||||||
if (!request.HasNumberOfValidVectors(1, 1))
|
if (!request.HasNumberOfValidVectors(1, 1))
|
||||||
@ -1571,30 +1577,14 @@ IPCCommandResult ES::DIGetTicketView(const IOCtlVRequest& request)
|
|||||||
|
|
||||||
IPCCommandResult ES::GetOwnedTitleCount(const IOCtlVRequest& request)
|
IPCCommandResult ES::GetOwnedTitleCount(const IOCtlVRequest& request)
|
||||||
{
|
{
|
||||||
if (!request.HasNumberOfValidVectors(0, 1))
|
|
||||||
return GetDefaultReply(ES_PARAMETER_SIZE_OR_ALIGNMENT);
|
|
||||||
|
|
||||||
const std::vector<u64> titles = GetTitlesWithTickets();
|
const std::vector<u64> titles = GetTitlesWithTickets();
|
||||||
Memory::Write_U32(static_cast<u32>(titles.size()), request.io_vectors[0].address);
|
|
||||||
|
|
||||||
INFO_LOG(IOS_ES, "GetOwnedTitleCount: %zu titles", titles.size());
|
INFO_LOG(IOS_ES, "GetOwnedTitleCount: %zu titles", titles.size());
|
||||||
return GetDefaultReply(IPC_SUCCESS);
|
return GetTitleCount(titles, request);
|
||||||
}
|
}
|
||||||
|
|
||||||
IPCCommandResult ES::GetOwnedTitles(const IOCtlVRequest& request)
|
IPCCommandResult ES::GetOwnedTitles(const IOCtlVRequest& request)
|
||||||
{
|
{
|
||||||
if (!request.HasNumberOfValidVectors(1, 1))
|
return GetTitles(GetTitlesWithTickets(), request);
|
||||||
return GetDefaultReply(ES_PARAMETER_SIZE_OR_ALIGNMENT);
|
|
||||||
|
|
||||||
const std::vector<u64> titles = GetTitlesWithTickets();
|
|
||||||
|
|
||||||
const size_t max_count = Memory::Read_U32(request.in_vectors[0].address);
|
|
||||||
for (size_t i = 0; i < std::min(max_count, titles.size()); i++)
|
|
||||||
{
|
|
||||||
Memory::Write_U64(titles[i], request.io_vectors[0].address + static_cast<u32>(i) * 8);
|
|
||||||
INFO_LOG(IOS_ES, " title %016" PRIx64, titles[i]);
|
|
||||||
}
|
|
||||||
return GetDefaultReply(IPC_SUCCESS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const DiscIO::CNANDContentLoader& ES::AccessContentDevice(u64 title_id)
|
const DiscIO::CNANDContentLoader& ES::AccessContentDevice(u64 title_id)
|
||||||
|
@ -168,6 +168,8 @@ private:
|
|||||||
IPCCommandResult GetTitleID(const IOCtlVRequest& request);
|
IPCCommandResult GetTitleID(const IOCtlVRequest& request);
|
||||||
IPCCommandResult SetUID(const IOCtlVRequest& request);
|
IPCCommandResult SetUID(const IOCtlVRequest& request);
|
||||||
|
|
||||||
|
IPCCommandResult GetTitleCount(const std::vector<u64>& titles, const IOCtlVRequest& request);
|
||||||
|
IPCCommandResult GetTitles(const std::vector<u64>& titles, const IOCtlVRequest& request);
|
||||||
IPCCommandResult GetOwnedTitleCount(const IOCtlVRequest& request);
|
IPCCommandResult GetOwnedTitleCount(const IOCtlVRequest& request);
|
||||||
IPCCommandResult GetOwnedTitles(const IOCtlVRequest& request);
|
IPCCommandResult GetOwnedTitles(const IOCtlVRequest& request);
|
||||||
IPCCommandResult GetTitleCount(const IOCtlVRequest& request);
|
IPCCommandResult GetTitleCount(const IOCtlVRequest& request);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user