summaryrefslogtreecommitdiff
path: root/Source/Core/Common/SettingsHandler.cpp
diff options
context:
space:
mode:
authorLéo Lam <leo@innovatetechnologi.es>2018-05-09 20:40:56 +0200
committerLéo Lam <leo@innovatetechnologi.es>2018-05-10 21:35:27 +0200
commit09d2afa91f7781c84c25e989d916957200e63eca (patch)
treed3e37925ace03fe17d15c26704c1176b65a91f4f /Source/Core/Common/SettingsHandler.cpp
parent6e9d0ff6de961b211d3d010c3633f2d415eb850f (diff)
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.
Diffstat (limited to 'Source/Core/Common/SettingsHandler.cpp')
-rw-r--r--Source/Core/Common/SettingsHandler.cpp27
1 files changed, 8 insertions, 19 deletions
diff --git a/Source/Core/Common/SettingsHandler.cpp b/Source/Core/Common/SettingsHandler.cpp
index 8a0240939b..7663959a20 100644
--- a/Source/Core/Common/SettingsHandler.cpp
+++ b/Source/Core/Common/SettingsHandler.cpp
@@ -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)
{
- Reset();
-
- File::IOFile file{settings_file_path, "rb"};
- if (!file.ReadBytes(m_buffer.data(), m_buffer.size()))
- return false;
-
- Decrypt();
- return true;
+ SetBytes(std::move(buffer));
}
-bool SettingsHandler::Save(const std::string& destination_file_path) const
+const SettingsHandler::Buffer& SettingsHandler::GetBytes() 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());
+ return m_buffer;
}
-const u8* SettingsHandler::GetData() const
+void SettingsHandler::SetBytes(SettingsHandler::Buffer&& buffer)
{
- return m_buffer.data();
+ Reset();
+ m_buffer = std::move(buffer);
+ Decrypt();
}
const std::string SettingsHandler::GetValue(const std::string& key)