WiiRoot: Move content manipulation to separate functions
{Initialize,Shutdown}WiiRoot should only be responsible for setting the SESSION_WII_ROOT or managing the temporary NAND directory. Move all the content manipulation out of these functions to ensure separation of concerns and call them after/before WiiRoot init/shutdown to make sure they operate on the correct root.
This commit is contained in:
parent
f0c5b76186
commit
5f567b38fe
|
@ -54,11 +54,13 @@ void Init()
|
|||
Core::InitializeWiiRoot(Core::WantsDeterminism());
|
||||
IOS::Init();
|
||||
IOS::HLE::Init(); // Depends on Memory
|
||||
Core::InitializeWiiFileSystemContents();
|
||||
}
|
||||
}
|
||||
|
||||
void Shutdown()
|
||||
{
|
||||
Core::CleanUpWiiFileSystemContents();
|
||||
// IOS should always be shut down regardless of bWii because it can be running in GC mode (MIOS).
|
||||
IOS::HLE::Shutdown(); // Depends on Memory
|
||||
IOS::Shutdown();
|
||||
|
|
|
@ -61,14 +61,8 @@ void InitializeWiiRoot(bool use_temporary)
|
|||
ERROR_LOG(IOS_FS, "Could not create temporary directory");
|
||||
return;
|
||||
}
|
||||
File::CopyDir(File::GetSysDirectory() + WII_USER_DIR, s_temp_wii_root);
|
||||
WARN_LOG(IOS_FS, "Using temporary directory %s for minimal Wii FS", s_temp_wii_root.c_str());
|
||||
File::SetUserPath(D_SESSION_WIIROOT_IDX, s_temp_wii_root);
|
||||
// Generate a SYSCONF with default settings for the temporary Wii NAND.
|
||||
SysConf sysconf{IOS::HLE::Kernel{}.GetFS()};
|
||||
sysconf.Save();
|
||||
|
||||
InitializeDeterministicWiiSaves();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -80,12 +74,36 @@ void ShutdownWiiRoot()
|
|||
{
|
||||
if (!s_temp_wii_root.empty())
|
||||
{
|
||||
File::DeleteDirRecursively(s_temp_wii_root);
|
||||
s_temp_wii_root.clear();
|
||||
}
|
||||
}
|
||||
|
||||
void InitializeWiiFileSystemContents()
|
||||
{
|
||||
if (s_temp_wii_root.empty())
|
||||
return;
|
||||
|
||||
File::CopyDir(File::GetSysDirectory() + WII_USER_DIR, s_temp_wii_root);
|
||||
|
||||
// Generate a SYSCONF with default settings for the temporary Wii NAND.
|
||||
SysConf sysconf{IOS::HLE::GetIOS()->GetFS()};
|
||||
sysconf.Save();
|
||||
|
||||
InitializeDeterministicWiiSaves();
|
||||
}
|
||||
|
||||
void CleanUpWiiFileSystemContents()
|
||||
{
|
||||
if (s_temp_wii_root.empty())
|
||||
return;
|
||||
|
||||
const u64 title_id = SConfig::GetInstance().GetTitleID();
|
||||
std::string save_path = Common::GetTitleDataPath(title_id, Common::FROM_SESSION_ROOT);
|
||||
std::string user_save_path = Common::GetTitleDataPath(title_id, Common::FROM_CONFIGURED_ROOT);
|
||||
std::string user_backup_path = File::GetUserPath(D_BACKUP_IDX) +
|
||||
StringFromFormat("%08x/%08x/", static_cast<u32>(title_id >> 32),
|
||||
static_cast<u32>(title_id));
|
||||
std::string user_backup_path =
|
||||
File::GetUserPath(D_BACKUP_IDX) +
|
||||
StringFromFormat("%08x/%08x/", static_cast<u32>(title_id >> 32), static_cast<u32>(title_id));
|
||||
if (File::Exists(save_path + "/banner.bin") && SConfig::GetInstance().bEnableMemcardSdWriting)
|
||||
{
|
||||
// Backup the existing save just in case it's still needed.
|
||||
|
@ -99,8 +117,5 @@ void ShutdownWiiRoot()
|
|||
File::CopyDir(save_path, user_save_path);
|
||||
File::DeleteDirRecursively(save_path);
|
||||
}
|
||||
File::DeleteDirRecursively(s_temp_wii_root);
|
||||
s_temp_wii_root.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace Core
|
||||
|
|
|
@ -8,4 +8,8 @@ namespace Core
|
|||
{
|
||||
void InitializeWiiRoot(bool use_temporary);
|
||||
void ShutdownWiiRoot();
|
||||
|
||||
// Initialize or clean up the filesystem contents.
|
||||
void InitializeWiiFileSystemContents();
|
||||
void CleanUpWiiFileSystemContents();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue