WiiUtils: Allow reusing existing IOS/WAD instance

This commit is contained in:
Léo Lam
2017-10-01 15:07:59 +02:00
parent 6a03a24822
commit dd5c468c63
2 changed files with 16 additions and 7 deletions

View File

@ -46,7 +46,7 @@
namespace WiiUtils namespace WiiUtils
{ {
static bool InstallWAD(IOS::HLE::Kernel& ios, const DiscIO::WiiWAD& wad) static bool ImportWAD(IOS::HLE::Kernel& ios, const DiscIO::WiiWAD& wad)
{ {
if (!wad.IsValid()) if (!wad.IsValid())
{ {
@ -109,11 +109,8 @@ static bool InstallWAD(IOS::HLE::Kernel& ios, const DiscIO::WiiWAD& wad)
return true; return true;
} }
bool InstallWAD(const std::string& wad_path) bool InstallWAD(IOS::HLE::Kernel& ios, const DiscIO::WiiWAD& wad)
{ {
IOS::HLE::Kernel ios;
const DiscIO::WiiWAD wad{wad_path};
if (!wad.GetTMD().IsValid()) if (!wad.GetTMD().IsValid())
return false; return false;
@ -131,12 +128,18 @@ bool InstallWAD(const std::string& wad_path)
return false; return false;
} }
const bool result = InstallWAD(ios, wad); const bool result = ImportWAD(ios, wad);
DiscIO::NANDContentManager::Access().ClearCache(); DiscIO::NANDContentManager::Access().ClearCache();
return result; return result;
} }
bool InstallWAD(const std::string& wad_path)
{
IOS::HLE::Kernel ios;
return InstallWAD(ios, DiscIO::WiiWAD{wad_path});
}
// Common functionality for system updaters. // Common functionality for system updaters.
class SystemUpdater class SystemUpdater
{ {
@ -685,7 +688,7 @@ UpdateResult DiscSystemUpdater::ProcessEntry(u32 type, std::bitset<32> attrs,
return UpdateResult::DiscReadFailed; return UpdateResult::DiscReadFailed;
} }
const DiscIO::WiiWAD wad{std::move(blob)}; const DiscIO::WiiWAD wad{std::move(blob)};
return InstallWAD(m_ios, wad) ? UpdateResult::Succeeded : UpdateResult::ImportFailed; return ImportWAD(m_ios, wad) ? UpdateResult::Succeeded : UpdateResult::ImportFailed;
} }
UpdateResult DoOnlineUpdate(UpdateCallback update_callback, const std::string& region) UpdateResult DoOnlineUpdate(UpdateCallback update_callback, const std::string& region)

View File

@ -13,6 +13,10 @@
// Small utility functions for common Wii related tasks. // Small utility functions for common Wii related tasks.
namespace DiscIO
{
class WiiWAD;
}
namespace IOS namespace IOS
{ {
namespace HLE namespace HLE
@ -23,6 +27,8 @@ class Kernel;
namespace WiiUtils namespace WiiUtils
{ {
bool InstallWAD(IOS::HLE::Kernel& ios, const DiscIO::WiiWAD& wad);
// Same as the above, but constructs a temporary IOS and WiiWAD instance for importing.
bool InstallWAD(const std::string& wad_path); bool InstallWAD(const std::string& wad_path);
enum class UpdateResult enum class UpdateResult