From a59f57d50467bd5dba1f28b8020278d6298babf7 Mon Sep 17 00:00:00 2001 From: archshift Date: Thu, 9 Oct 2014 19:43:40 -0700 Subject: Use config files to store whether SDMC is enabled or not Before, it used to use whether the directory actually existed. As a result, .citra-emu/sdmc was never auto-created (something quite confusing to me until I read through the logs). --- src/citra/config.cpp | 5 +++++ src/citra/config.h | 1 + src/citra/default_ini.h | 3 +++ src/citra_qt/config.cpp | 14 ++++++++++++++ src/citra_qt/config.h | 3 +++ src/core/file_sys/archive_sdmc.cpp | 10 ++++++++-- src/core/settings.h | 2 ++ 7 files changed, 36 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/citra/config.cpp b/src/citra/config.cpp index 1d5e9c717..03a0ce606 100644 --- a/src/citra/config.cpp +++ b/src/citra/config.cpp @@ -55,9 +55,14 @@ void Config::ReadControls() { Settings::values.pad_sright_key = glfw_config->GetInteger("Controls", "pad_sright", GLFW_KEY_RIGHT); } +void Config::ReadData() { + Settings::values.use_virtual_sd = glfw_config->GetBoolean("Data Storage", "use_virtual_sd", true); +} + void Config::Reload() { LoadINI(glfw_config, glfw_config_loc.c_str(), DefaultINI::glfw_config_file); ReadControls(); + ReadData(); } Config::~Config() { diff --git a/src/citra/config.h b/src/citra/config.h index de0570b42..c4fac2459 100644 --- a/src/citra/config.h +++ b/src/citra/config.h @@ -16,6 +16,7 @@ class Config { bool LoadINI(INIReader* config, const char* location, const std::string& default_contents="", bool retry=true); void ReadControls(); + void ReadData(); public: Config(); ~Config(); diff --git a/src/citra/default_ini.h b/src/citra/default_ini.h index 11b985e1b..e7e45f4a9 100644 --- a/src/citra/default_ini.h +++ b/src/citra/default_ini.h @@ -25,6 +25,9 @@ pad_sup = pad_sdown = pad_sleft = pad_sright = + +[Data Storage] +use_virtual_sd = )"; } diff --git a/src/citra_qt/config.cpp b/src/citra_qt/config.cpp index 1b116edc5..0c4f75a96 100644 --- a/src/citra_qt/config.cpp +++ b/src/citra_qt/config.cpp @@ -64,12 +64,26 @@ void Config::SaveControls() { qt_config->endGroup(); } +void Config::ReadData() { + qt_config->beginGroup("Data Storage"); + Settings::values.use_virtual_sd = qt_config->value("use_virtual_sd", true).toBool(); + qt_config->endGroup(); +} + +void Config::SaveData() { + qt_config->beginGroup("Data Storage"); + qt_config->setValue("use_virtual_sd", Settings::values.use_virtual_sd); + qt_config->endGroup(); +} + void Config::Reload() { ReadControls(); + ReadData(); } void Config::Save() { SaveControls(); + SaveData(); } Config::~Config() { diff --git a/src/citra_qt/config.h b/src/citra_qt/config.h index ae390be6b..74c9ff11d 100644 --- a/src/citra_qt/config.h +++ b/src/citra_qt/config.h @@ -14,6 +14,9 @@ class Config { void ReadControls(); void SaveControls(); + + void ReadData(); + void SaveData(); public: Config(); ~Config(); diff --git a/src/core/file_sys/archive_sdmc.cpp b/src/core/file_sys/archive_sdmc.cpp index 213923c02..0b647f7d0 100644 --- a/src/core/file_sys/archive_sdmc.cpp +++ b/src/core/file_sys/archive_sdmc.cpp @@ -10,6 +10,7 @@ #include "core/file_sys/archive_sdmc.h" #include "core/file_sys/directory_sdmc.h" #include "core/file_sys/file_sdmc.h" +#include "core/settings.h" //////////////////////////////////////////////////////////////////////////////////////////////////// // FileSys namespace @@ -29,8 +30,13 @@ Archive_SDMC::~Archive_SDMC() { * @return true if it initialized successfully */ bool Archive_SDMC::Initialize() { - if (!FileUtil::IsDirectory(mount_point)) { - WARN_LOG(FILESYS, "Directory %s not found, disabling SDMC.", mount_point.c_str()); + if (!Settings::values.use_virtual_sd) { + WARN_LOG(FILESYS, "SDMC disabled by config."); + return false; + } + + if (!FileUtil::CreateFullPath(mount_point)) { + WARN_LOG(FILESYS, "Unable to create SDMC path."); return false; } diff --git a/src/core/settings.h b/src/core/settings.h index a84c3d4b6..d586e2ef4 100644 --- a/src/core/settings.h +++ b/src/core/settings.h @@ -24,6 +24,8 @@ struct Values { int pad_sdown_key; int pad_sleft_key; int pad_sright_key; + + bool use_virtual_sd; } extern values; } -- cgit v1.2.3 From a7c7946867c0f36c5091c1cf89954ccce637d51a Mon Sep 17 00:00:00 2001 From: archshift Date: Thu, 9 Oct 2014 23:27:47 -0700 Subject: Common: Return from CreateFullPath early if the directory creation fails --- src/common/file_util.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/common/file_util.cpp b/src/common/file_util.cpp index 78a642599..9e40e87d4 100644 --- a/src/common/file_util.cpp +++ b/src/common/file_util.cpp @@ -190,8 +190,10 @@ bool CreateFullPath(const std::string &fullPath) // Include the '/' so the first call is CreateDir("/") rather than CreateDir("") std::string const subPath(fullPath.substr(0, position + 1)); - if (!FileUtil::IsDirectory(subPath)) - FileUtil::CreateDir(subPath); + if (!FileUtil::IsDirectory(subPath) && !FileUtil::CreateDir(subPath)) { + ERROR_LOG(COMMON, "CreateFullPath: directory creation failed"); + return false; + } // A safety check panicCounter--; -- cgit v1.2.3