summaryrefslogtreecommitdiff
path: root/src/citra/config.cpp
diff options
context:
space:
mode:
authorGravatar MerryMage2016-03-02 12:49:30 +0000
committerGravatar MerryMage2016-03-02 14:25:06 +0000
commit48366b1071a7e6ee367435b78845b429c0c9c31f (patch)
treeea8830afe35efaed11cc820c83ab798fe5a9af36 /src/citra/config.cpp
parentDependencies: Remove GLFW, Add SDL2 (diff)
downloadyuzu-48366b1071a7e6ee367435b78845b429c0c9c31f.tar.gz
yuzu-48366b1071a7e6ee367435b78845b429c0c9c31f.tar.xz
yuzu-48366b1071a7e6ee367435b78845b429c0c9c31f.zip
Config: Use unique_ptr instead of raw pointer
Diffstat (limited to 'src/citra/config.cpp')
-rw-r--r--src/citra/config.cpp18
1 files changed, 8 insertions, 10 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}