SettingsHandler: Namespace code under the Common namespace

Adds another file in Common to the Common namespace.
This commit is contained in:
Lioncash 2018-05-12 13:39:35 -04:00
parent bf0ee9f702
commit 5677e5d74a
4 changed files with 11 additions and 5 deletions

View File

@ -22,6 +22,8 @@
#include "Common/SettingsHandler.h" #include "Common/SettingsHandler.h"
#include "Common/Timer.h" #include "Common/Timer.h"
namespace Common
{
SettingsHandler::SettingsHandler() SettingsHandler::SettingsHandler()
{ {
Reset(); Reset();
@ -134,3 +136,4 @@ std::string SettingsHandler::GenerateSerialNumber()
stream << std::put_time(std::localtime(&t), "%j%H%M%S"); stream << std::put_time(std::localtime(&t), "%j%H%M%S");
return stream.str(); return stream.str();
} }
} // namespace Common

View File

@ -11,6 +11,8 @@
#include "Common/CommonTypes.h" #include "Common/CommonTypes.h"
namespace Common
{
class SettingsHandler class SettingsHandler
{ {
public: public:
@ -42,3 +44,4 @@ private:
u32 m_position, m_key; u32 m_position, m_key;
std::string decoded; std::string decoded;
}; };
} // namespace Common

View File

@ -223,7 +223,7 @@ bool CBoot::SetupWiiMemory()
auto entryPos = region_settings.find(SConfig::GetInstance().m_region); auto entryPos = region_settings.find(SConfig::GetInstance().m_region);
const RegionSetting& region_setting = entryPos->second; const RegionSetting& region_setting = entryPos->second;
SettingsHandler gen; Common::SettingsHandler gen;
std::string serno; std::string serno;
CreateSystemMenuTitleDirs(); CreateSystemMenuTitleDirs();
const std::string settings_file_path(Common::GetTitleDataPath(Titles::SYSTEM_MENU) + const std::string settings_file_path(Common::GetTitleDataPath(Titles::SYSTEM_MENU) +
@ -231,7 +231,7 @@ bool CBoot::SetupWiiMemory()
const auto fs = IOS::HLE::GetIOS()->GetFS(); const auto fs = IOS::HLE::GetIOS()->GetFS();
{ {
SettingsHandler::Buffer data; Common::SettingsHandler::Buffer data;
const auto file = fs->OpenFile(IOS::SYSMENU_UID, IOS::SYSMENU_GID, settings_file_path, const auto file = fs->OpenFile(IOS::SYSMENU_UID, IOS::SYSMENU_GID, settings_file_path,
IOS::HLE::FS::Mode::Read); IOS::HLE::FS::Mode::Read);
if (file && file->Read(data.data(), data.size())) if (file && file->Read(data.data(), data.size()))
@ -248,7 +248,7 @@ bool CBoot::SetupWiiMemory()
if (Core::WantsDeterminism()) if (Core::WantsDeterminism())
serno = "123456789"; serno = "123456789";
else else
serno = SettingsHandler::GenerateSerialNumber(); serno = Common::SettingsHandler::GenerateSerialNumber();
INFO_LOG(BOOT, "No previous serial number found, generated one instead: %s", serno.c_str()); INFO_LOG(BOOT, "No previous serial number found, generated one instead: %s", serno.c_str());
} }
else else

View File

@ -92,10 +92,10 @@ IPCCommandResult NetKDRequest::IOCtl(const IOCtlRequest& request)
const auto fs = m_ios.GetFS(); const auto fs = m_ios.GetFS();
if (const auto file = fs->OpenFile(PID_KD, PID_KD, settings_file_path, FS::Mode::Read)) if (const auto file = fs->OpenFile(PID_KD, PID_KD, settings_file_path, FS::Mode::Read))
{ {
SettingsHandler::Buffer data; Common::SettingsHandler::Buffer data;
if (file->Read(data.data(), data.size())) if (file->Read(data.data(), data.size()))
{ {
const SettingsHandler gen{std::move(data)}; const Common::SettingsHandler gen{std::move(data)};
area = gen.GetValue("AREA"); area = gen.GetValue("AREA");
model = gen.GetValue("MODEL"); model = gen.GetValue("MODEL");
} }