mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-08-19 16:59:13 +00:00
SettingsHandler: Migrate to new filesystem interface
Change SettingsHandler to take a buffer instead of assuming that the setting file to read is always on the host filesystem for more flexibility and make it possible to use the new filesystem interface.
This commit is contained in:
parent
6e9d0ff6de
commit
09d2afa91f
4 changed files with 52 additions and 46 deletions
|
@ -25,7 +25,9 @@
|
|||
#include "Core/HW/Memmap.h"
|
||||
#include "Core/IOS/ES/ES.h"
|
||||
#include "Core/IOS/ES/Formats.h"
|
||||
#include "Core/IOS/FS/FileSystem.h"
|
||||
#include "Core/IOS/IOS.h"
|
||||
#include "Core/IOS/Uids.h"
|
||||
#include "Core/PowerPC/PowerPC.h"
|
||||
|
||||
#include "DiscIO/Enums.h"
|
||||
|
@ -225,15 +227,22 @@ bool CBoot::SetupWiiMemory()
|
|||
|
||||
SettingsHandler gen;
|
||||
std::string serno;
|
||||
const std::string settings_file_path(
|
||||
Common::GetTitleDataPath(Titles::SYSTEM_MENU, Common::FROM_SESSION_ROOT) + "/" WII_SETTING);
|
||||
if (File::Exists(settings_file_path) && gen.Open(settings_file_path))
|
||||
{
|
||||
serno = gen.GetValue("SERNO");
|
||||
gen.Reset();
|
||||
const std::string settings_file_path(Common::GetTitleDataPath(Titles::SYSTEM_MENU) +
|
||||
"/" WII_SETTING);
|
||||
|
||||
File::Delete(settings_file_path);
|
||||
const auto fs = IOS::HLE::GetIOS()->GetFS();
|
||||
{
|
||||
SettingsHandler::Buffer data;
|
||||
const auto file = fs->OpenFile(IOS::SYSMENU_UID, IOS::SYSMENU_GID, settings_file_path,
|
||||
IOS::HLE::FS::Mode::Read);
|
||||
if (file && file->Read(data.data(), data.size()))
|
||||
{
|
||||
gen.SetBytes(std::move(data));
|
||||
serno = gen.GetValue("SERNO");
|
||||
gen.Reset();
|
||||
}
|
||||
}
|
||||
fs->Delete(IOS::SYSMENU_UID, IOS::SYSMENU_GID, settings_file_path);
|
||||
|
||||
if (serno.empty() || serno == "000000000")
|
||||
{
|
||||
|
@ -258,14 +267,17 @@ bool CBoot::SetupWiiMemory()
|
|||
gen.AddSetting("VIDEO", region_setting.video);
|
||||
gen.AddSetting("GAME", region_setting.game);
|
||||
|
||||
if (!gen.Save(settings_file_path))
|
||||
constexpr IOS::HLE::FS::Mode rw_mode = IOS::HLE::FS::Mode::ReadWrite;
|
||||
const auto settings_file = fs->CreateAndOpenFile(IOS::SYSMENU_UID, IOS::SYSMENU_GID,
|
||||
settings_file_path, rw_mode, rw_mode, rw_mode);
|
||||
if (!settings_file || !settings_file->Write(gen.GetBytes().data(), gen.GetBytes().size()))
|
||||
{
|
||||
PanicAlertT("SetupWiiMemory: Can't create setting.txt file");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Write the 256 byte setting.txt to memory.
|
||||
Memory::CopyToEmu(0x3800, gen.GetData(), SettingsHandler::SETTINGS_SIZE);
|
||||
Memory::CopyToEmu(0x3800, gen.GetBytes().data(), gen.GetBytes().size());
|
||||
|
||||
INFO_LOG(BOOT, "Setup Wii Memory...");
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue