sys: Format settings file more prettily
This commit is contained in:
parent
f349aafc37
commit
b1e93fda4b
@ -1,6 +1,7 @@
|
|||||||
#include <hex/api/content_registry.hpp>
|
#include <hex/api/content_registry.hpp>
|
||||||
|
|
||||||
#include <hex/helpers/fs.hpp>
|
#include <hex/helpers/fs.hpp>
|
||||||
|
#include <hex/helpers/file.hpp>
|
||||||
#include <hex/helpers/logger.hpp>
|
#include <hex/helpers/logger.hpp>
|
||||||
|
|
||||||
#include <hex/ui/view.hpp>
|
#include <hex/ui/view.hpp>
|
||||||
@ -21,10 +22,10 @@ namespace hex {
|
|||||||
void load() {
|
void load() {
|
||||||
bool loaded = false;
|
bool loaded = false;
|
||||||
for (const auto &dir : fs::getDefaultPaths(fs::ImHexPath::Config)) {
|
for (const auto &dir : fs::getDefaultPaths(fs::ImHexPath::Config)) {
|
||||||
std::ifstream settingsFile(dir / SettingsFile);
|
fs::File file(dir / SettingsFile, fs::File::Mode::Read);
|
||||||
|
|
||||||
if (settingsFile.good()) {
|
if (file.isValid()) {
|
||||||
settingsFile >> getSettingsData();
|
getSettingsData() = nlohmann::json::parse(file.readString());
|
||||||
loaded = true;
|
loaded = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -36,10 +37,10 @@ namespace hex {
|
|||||||
|
|
||||||
void store() {
|
void store() {
|
||||||
for (const auto &dir : fs::getDefaultPaths(fs::ImHexPath::Config)) {
|
for (const auto &dir : fs::getDefaultPaths(fs::ImHexPath::Config)) {
|
||||||
std::ofstream settingsFile(dir / SettingsFile, std::ios::trunc);
|
fs::File file(dir / SettingsFile, fs::File::Mode::Create);
|
||||||
|
|
||||||
if (settingsFile.good()) {
|
if (file.isValid()) {
|
||||||
settingsFile << getSettingsData();
|
file.write(getSettingsData().dump(4));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user