mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-04-26 06:18:32 +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
|
@ -19,8 +19,6 @@
|
|||
#endif
|
||||
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Common/File.h"
|
||||
#include "Common/FileUtil.h"
|
||||
#include "Common/SettingsHandler.h"
|
||||
#include "Common/Timer.h"
|
||||
|
||||
|
@ -29,30 +27,21 @@ SettingsHandler::SettingsHandler()
|
|||
Reset();
|
||||
}
|
||||
|
||||
bool SettingsHandler::Open(const std::string& settings_file_path)
|
||||
SettingsHandler::SettingsHandler(Buffer&& buffer)
|
||||
{
|
||||
SetBytes(std::move(buffer));
|
||||
}
|
||||
|
||||
const SettingsHandler::Buffer& SettingsHandler::GetBytes() const
|
||||
{
|
||||
return m_buffer;
|
||||
}
|
||||
|
||||
void SettingsHandler::SetBytes(SettingsHandler::Buffer&& buffer)
|
||||
{
|
||||
Reset();
|
||||
|
||||
File::IOFile file{settings_file_path, "rb"};
|
||||
if (!file.ReadBytes(m_buffer.data(), m_buffer.size()))
|
||||
return false;
|
||||
|
||||
m_buffer = std::move(buffer);
|
||||
Decrypt();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SettingsHandler::Save(const std::string& destination_file_path) const
|
||||
{
|
||||
if (!File::CreateFullPath(destination_file_path))
|
||||
return false;
|
||||
|
||||
File::IOFile file{destination_file_path, "wb"};
|
||||
return file.WriteBytes(m_buffer.data(), m_buffer.size());
|
||||
}
|
||||
|
||||
const u8* SettingsHandler::GetData() const
|
||||
{
|
||||
return m_buffer.data();
|
||||
}
|
||||
|
||||
const std::string SettingsHandler::GetValue(const std::string& key)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue