mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-04-02 05:27:41 -05:00
sys: Reset settings if it cannot be parsed anymore
This commit is contained in:
@@ -14,10 +14,12 @@ namespace hex {
|
||||
|
||||
namespace ContentRegistry::Settings {
|
||||
|
||||
constexpr auto SettingsFile = "settings.json";
|
||||
|
||||
void load() {
|
||||
bool loaded = false;
|
||||
for (const auto &dir : fs::getDefaultPaths(fs::ImHexPath::Config)) {
|
||||
std::ifstream settingsFile(dir / "settings.json");
|
||||
std::ifstream settingsFile(dir / SettingsFile);
|
||||
|
||||
if (settingsFile.good()) {
|
||||
settingsFile >> getSettingsData();
|
||||
@@ -32,7 +34,7 @@ namespace hex {
|
||||
|
||||
void store() {
|
||||
for (const auto &dir : fs::getDefaultPaths(fs::ImHexPath::Config)) {
|
||||
std::ofstream settingsFile(dir / "settings.json", std::ios::trunc);
|
||||
std::ofstream settingsFile(dir / SettingsFile, std::ios::trunc);
|
||||
|
||||
if (settingsFile.good()) {
|
||||
settingsFile << getSettingsData();
|
||||
@@ -41,6 +43,12 @@ namespace hex {
|
||||
}
|
||||
}
|
||||
|
||||
void clear() {
|
||||
for (const auto &dir : fs::getDefaultPaths(fs::ImHexPath::Config)) {
|
||||
hex::fs::remove(dir / SettingsFile);
|
||||
}
|
||||
}
|
||||
|
||||
static auto getCategoryEntry(const std::string &unlocalizedCategory) {
|
||||
auto &entries = getEntries();
|
||||
const size_t curSlot = entries.size();
|
||||
|
||||
Reference in New Issue
Block a user