summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/citra/config.cpp18
-rw-r--r--src/citra/config.h8
2 files changed, 12 insertions, 14 deletions
diff --git a/src/citra/config.cpp b/src/citra/config.cpp
index 91c0df425..9034b188e 100644
--- a/src/citra/config.cpp
+++ b/src/citra/config.cpp
@@ -10,6 +10,7 @@
10 10
11#include "common/file_util.h" 11#include "common/file_util.h"
12#include "common/logging/log.h" 12#include "common/logging/log.h"
13#include "common/make_unique.h"
13 14
14#include "core/settings.h" 15#include "core/settings.h"
15 16
@@ -18,20 +19,21 @@
18Config::Config() { 19Config::Config() {
19 // TODO: Don't hardcode the path; let the frontend decide where to put the config files. 20 // TODO: Don't hardcode the path; let the frontend decide where to put the config files.
20 sdl2_config_loc = FileUtil::GetUserPath(D_CONFIG_IDX) + "sdl2-config.ini"; 21 sdl2_config_loc = FileUtil::GetUserPath(D_CONFIG_IDX) + "sdl2-config.ini";
21 sdl2_config = new INIReader(sdl2_config_loc); 22 sdl2_config = Common::make_unique<INIReader>(sdl2_config_loc);
22 23
23 Reload(); 24 Reload();
24} 25}
25 26
26bool Config::LoadINI(INIReader* config, const char* location, const std::string& default_contents, bool retry) { 27bool Config::LoadINI(const std::string& default_contents, bool retry) {
27 if (config->ParseError() < 0) { 28 const char* location = this->sdl2_config_loc.c_str();
29 if (sdl2_config->ParseError() < 0) {
28 if (retry) { 30 if (retry) {
29 LOG_WARNING(Config, "Failed to load %s. Creating file from defaults...", location); 31 LOG_WARNING(Config, "Failed to load %s. Creating file from defaults...", location);
30 FileUtil::CreateFullPath(location); 32 FileUtil::CreateFullPath(location);
31 FileUtil::WriteStringToFile(true, default_contents, location); 33 FileUtil::WriteStringToFile(true, default_contents, location);
32 *config = INIReader(location); // Reopen file 34 sdl2_config = Common::make_unique<INIReader>(location); // Reopen file
33 35
34 return LoadINI(config, location, default_contents, false); 36 return LoadINI(default_contents, false);
35 } 37 }
36 LOG_ERROR(Config, "Failed."); 38 LOG_ERROR(Config, "Failed.");
37 return false; 39 return false;
@@ -82,10 +84,6 @@ void Config::ReadValues() {
82} 84}
83 85
84void Config::Reload() { 86void Config::Reload() {
85 LoadINI(sdl2_config, sdl2_config_loc.c_str(), DefaultINI::sdl2_config_file); 87 LoadINI(DefaultINI::sdl2_config_file);
86 ReadValues(); 88 ReadValues();
87} 89}
88
89Config::~Config() {
90 delete sdl2_config;
91}
diff --git a/src/citra/config.h b/src/citra/config.h
index d87ef7883..52a478146 100644
--- a/src/citra/config.h
+++ b/src/citra/config.h
@@ -4,19 +4,19 @@
4 4
5#pragma once 5#pragma once
6 6
7#include <memory>
7#include <string> 8#include <string>
8 9
9class INIReader; 10#include <inih/cpp/INIReader.h>
10 11
11class Config { 12class Config {
12 INIReader* sdl2_config; 13 std::unique_ptr<INIReader> sdl2_config;
13 std::string sdl2_config_loc; 14 std::string sdl2_config_loc;
14 15
15 bool LoadINI(INIReader* config, const char* location, const std::string& default_contents="", bool retry=true); 16 bool LoadINI(const std::string& default_contents="", bool retry=true);
16 void ReadValues(); 17 void ReadValues();
17public: 18public:
18 Config(); 19 Config();
19 ~Config();
20 20
21 void Reload(); 21 void Reload();
22}; 22};