summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authorLeo Lam <leolino.lam@gmail.com>2017-06-03 18:40:52 +0200
committerGitHub <noreply@github.com>2017-06-03 18:40:52 +0200
commit6d38f153d6376d7e22de08fa474163bb74a2a58c (patch)
tree843160b6d605f8aecb074ee30f67a107b0031bcf /Source/Core
parent0ff8e2b36f95653cf524cbf23ba6c2f69b201e0d (diff)
parent9d52ab5144655950a152f09a179da1ae8bb4c4e5 (diff)
Merge pull request #5515 from leoetlino/import-ticket
IOS/ES: Move ImportTicket write function
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/Core/IOS/ES/TitleManagement.cpp20
-rw-r--r--Source/Core/DiscIO/NANDContentLoader.cpp20
-rw-r--r--Source/Core/DiscIO/NANDContentLoader.h1
3 files changed, 18 insertions, 23 deletions
diff --git a/Source/Core/Core/IOS/ES/TitleManagement.cpp b/Source/Core/Core/IOS/ES/TitleManagement.cpp
index 1bfd229a96..505b4b869a 100644
--- a/Source/Core/Core/IOS/ES/TitleManagement.cpp
+++ b/Source/Core/Core/IOS/ES/TitleManagement.cpp
@@ -30,6 +30,21 @@ namespace HLE
{
namespace Device
{
+static ReturnCode WriteTicket(const IOS::ES::TicketReader& ticket)
+{
+ const u64 title_id = ticket.GetTitleId();
+
+ const std::string ticket_path = Common::GetTicketFileName(title_id, Common::FROM_SESSION_ROOT);
+ File::CreateFullPath(ticket_path);
+
+ File::IOFile ticket_file(ticket_path, "wb");
+ if (!ticket_file)
+ return ES_EIO;
+
+ const std::vector<u8>& raw_ticket = ticket.GetRawTicket();
+ return ticket_file.WriteBytes(raw_ticket.data(), raw_ticket.size()) ? IPC_SUCCESS : ES_EIO;
+}
+
ReturnCode ES::ImportTicket(const std::vector<u8>& ticket_bytes)
{
IOS::ES::TicketReader ticket{ticket_bytes};
@@ -54,8 +69,9 @@ ReturnCode ES::ImportTicket(const std::vector<u8>& ticket_bytes)
}
}
- if (!DiscIO::AddTicket(ticket))
- return ES_EIO;
+ const ReturnCode write_ret = WriteTicket(ticket);
+ if (write_ret != IPC_SUCCESS)
+ return write_ret;
INFO_LOG(IOS_ES, "ImportTicket: Imported ticket for title %016" PRIx64, ticket.GetTitleId());
return IPC_SUCCESS;
diff --git a/Source/Core/DiscIO/NANDContentLoader.cpp b/Source/Core/DiscIO/NANDContentLoader.cpp
index e9700ac1e2..c1a806006d 100644
--- a/Source/Core/DiscIO/NANDContentLoader.cpp
+++ b/Source/Core/DiscIO/NANDContentLoader.cpp
@@ -248,26 +248,6 @@ void CNANDContentManager::ClearCache()
m_map.clear();
}
-bool AddTicket(const IOS::ES::TicketReader& signed_ticket)
-{
- if (!signed_ticket.IsValid())
- {
- return false;
- }
-
- u64 title_id = signed_ticket.GetTitleId();
-
- std::string ticket_filename = Common::GetTicketFileName(title_id, Common::FROM_CONFIGURED_ROOT);
- File::CreateFullPath(ticket_filename);
-
- File::IOFile ticket_file(ticket_filename, "wb");
- if (!ticket_file)
- return false;
-
- const std::vector<u8>& raw_ticket = signed_ticket.GetRawTicket();
- return ticket_file.WriteBytes(raw_ticket.data(), raw_ticket.size());
-}
-
IOS::ES::TicketReader FindSignedTicket(u64 title_id)
{
std::string ticket_filename = Common::GetTicketFileName(title_id, Common::FROM_CONFIGURED_ROOT);
diff --git a/Source/Core/DiscIO/NANDContentLoader.h b/Source/Core/DiscIO/NANDContentLoader.h
index 7dee6b488c..de4157cd39 100644
--- a/Source/Core/DiscIO/NANDContentLoader.h
+++ b/Source/Core/DiscIO/NANDContentLoader.h
@@ -24,7 +24,6 @@ namespace DiscIO
enum class Region;
// TODO: move some of these to Core/IOS/ES.
-bool AddTicket(const IOS::ES::TicketReader& signed_ticket);
IOS::ES::TicketReader FindSignedTicket(u64 title_id);
class CNANDContentData