From c8bffb01531addda9f345c30d614500650ca82a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Lam?= Date: Sun, 14 May 2017 00:15:12 +0200 Subject: Reuse the IOS code for WAD installation * Less code and logic duplication. * Fixes a bug with the data dir not being created, steps being done in the wrong order. --- Source/Core/DiscIO/NANDContentLoader.cpp | 68 -------------------------------- 1 file changed, 68 deletions(-) (limited to 'Source/Core/DiscIO/NANDContentLoader.cpp') diff --git a/Source/Core/DiscIO/NANDContentLoader.cpp b/Source/Core/DiscIO/NANDContentLoader.cpp index 4e7f6f12ba..e6aca0ce79 100644 --- a/Source/Core/DiscIO/NANDContentLoader.cpp +++ b/Source/Core/DiscIO/NANDContentLoader.cpp @@ -246,74 +246,6 @@ void CNANDContentManager::ClearCache() m_map.clear(); } -u64 CNANDContentManager::Install_WiiWAD(const std::string& filename) -{ - if (filename.find(".wad") == std::string::npos) - return 0; - const CNANDContentLoader& content_loader = GetNANDLoader(filename); - if (content_loader.IsValid() == false) - return 0; - - const u64 title_id = content_loader.GetTMD().GetTitleId(); - - // copy WAD's TMD header and contents to content directory - - std::string content_path(Common::GetTitleContentPath(title_id, Common::FROM_CONFIGURED_ROOT)); - std::string tmd_filename(Common::GetTMDFileName(title_id, Common::FROM_CONFIGURED_ROOT)); - File::CreateFullPath(tmd_filename); - - File::IOFile tmd_file(tmd_filename, "wb"); - if (!tmd_file) - { - PanicAlertT("WAD installation failed: error creating %s", tmd_filename.c_str()); - return 0; - } - - const auto& raw_tmd = content_loader.GetTMD().GetRawTMD(); - tmd_file.WriteBytes(raw_tmd.data(), raw_tmd.size()); - - IOS::ES::SharedContentMap shared_content{Common::FromWhichRoot::FROM_CONFIGURED_ROOT}; - for (const auto& content : content_loader.GetContent()) - { - std::string app_filename; - if (content.m_metadata.IsShared()) - app_filename = shared_content.AddSharedContent(content.m_metadata.sha1); - else - app_filename = StringFromFormat("%s%08x.app", content_path.c_str(), content.m_metadata.id); - - if (!File::Exists(app_filename)) - { - File::CreateFullPath(app_filename); - File::IOFile app_file(app_filename, "wb"); - if (!app_file) - { - PanicAlertT("WAD installation failed: error creating %s", app_filename.c_str()); - return 0; - } - - app_file.WriteBytes(content.m_Data->Get().data(), content.m_metadata.size); - } - else - { - INFO_LOG(DISCIO, "Content %s already exists.", app_filename.c_str()); - } - } - - // Extract and copy WAD's ticket to ticket directory - if (!AddTicket(content_loader.GetTicket())) - { - PanicAlertT("WAD installation failed: error creating ticket"); - return 0; - } - - IOS::ES::UIDSys uid_sys{Common::FromWhichRoot::FROM_CONFIGURED_ROOT}; - uid_sys.GetOrInsertUIDForTitle(title_id); - - ClearCache(); - - return title_id; -} - bool AddTicket(const IOS::ES::TicketReader& signed_ticket) { if (!signed_ticket.IsValid()) -- cgit v1.2.3