Merge pull request #133 from archshift/sdmc-enabled
Use config files to store whether SDMC is enabled or not, auto-create SDMC dir.
This commit is contained in:
commit
ce8390ac03
8 changed files with 40 additions and 4 deletions
|
@ -55,9 +55,14 @@ void Config::ReadControls() {
|
||||||
Settings::values.pad_sright_key = glfw_config->GetInteger("Controls", "pad_sright", GLFW_KEY_RIGHT);
|
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() {
|
void Config::Reload() {
|
||||||
LoadINI(glfw_config, glfw_config_loc.c_str(), DefaultINI::glfw_config_file);
|
LoadINI(glfw_config, glfw_config_loc.c_str(), DefaultINI::glfw_config_file);
|
||||||
ReadControls();
|
ReadControls();
|
||||||
|
ReadData();
|
||||||
}
|
}
|
||||||
|
|
||||||
Config::~Config() {
|
Config::~Config() {
|
||||||
|
|
|
@ -16,6 +16,7 @@ class Config {
|
||||||
|
|
||||||
bool LoadINI(INIReader* config, const char* location, const std::string& default_contents="", bool retry=true);
|
bool LoadINI(INIReader* config, const char* location, const std::string& default_contents="", bool retry=true);
|
||||||
void ReadControls();
|
void ReadControls();
|
||||||
|
void ReadData();
|
||||||
public:
|
public:
|
||||||
Config();
|
Config();
|
||||||
~Config();
|
~Config();
|
||||||
|
|
|
@ -25,6 +25,9 @@ pad_sup =
|
||||||
pad_sdown =
|
pad_sdown =
|
||||||
pad_sleft =
|
pad_sleft =
|
||||||
pad_sright =
|
pad_sright =
|
||||||
|
|
||||||
|
[Data Storage]
|
||||||
|
use_virtual_sd =
|
||||||
)";
|
)";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,12 +64,26 @@ void Config::SaveControls() {
|
||||||
qt_config->endGroup();
|
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() {
|
void Config::Reload() {
|
||||||
ReadControls();
|
ReadControls();
|
||||||
|
ReadData();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Config::Save() {
|
void Config::Save() {
|
||||||
SaveControls();
|
SaveControls();
|
||||||
|
SaveData();
|
||||||
}
|
}
|
||||||
|
|
||||||
Config::~Config() {
|
Config::~Config() {
|
||||||
|
|
|
@ -14,6 +14,9 @@ class Config {
|
||||||
|
|
||||||
void ReadControls();
|
void ReadControls();
|
||||||
void SaveControls();
|
void SaveControls();
|
||||||
|
|
||||||
|
void ReadData();
|
||||||
|
void SaveData();
|
||||||
public:
|
public:
|
||||||
Config();
|
Config();
|
||||||
~Config();
|
~Config();
|
||||||
|
|
|
@ -191,8 +191,10 @@ bool CreateFullPath(const std::string &fullPath)
|
||||||
|
|
||||||
// Include the '/' so the first call is CreateDir("/") rather than CreateDir("")
|
// Include the '/' so the first call is CreateDir("/") rather than CreateDir("")
|
||||||
std::string const subPath(fullPath.substr(0, position + 1));
|
std::string const subPath(fullPath.substr(0, position + 1));
|
||||||
if (!FileUtil::IsDirectory(subPath))
|
if (!FileUtil::IsDirectory(subPath) && !FileUtil::CreateDir(subPath)) {
|
||||||
FileUtil::CreateDir(subPath);
|
ERROR_LOG(COMMON, "CreateFullPath: directory creation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// A safety check
|
// A safety check
|
||||||
panicCounter--;
|
panicCounter--;
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#include "core/file_sys/archive_sdmc.h"
|
#include "core/file_sys/archive_sdmc.h"
|
||||||
#include "core/file_sys/directory_sdmc.h"
|
#include "core/file_sys/directory_sdmc.h"
|
||||||
#include "core/file_sys/file_sdmc.h"
|
#include "core/file_sys/file_sdmc.h"
|
||||||
|
#include "core/settings.h"
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// FileSys namespace
|
// FileSys namespace
|
||||||
|
@ -29,8 +30,13 @@ Archive_SDMC::~Archive_SDMC() {
|
||||||
* @return true if it initialized successfully
|
* @return true if it initialized successfully
|
||||||
*/
|
*/
|
||||||
bool Archive_SDMC::Initialize() {
|
bool Archive_SDMC::Initialize() {
|
||||||
if (!FileUtil::IsDirectory(mount_point)) {
|
if (!Settings::values.use_virtual_sd) {
|
||||||
WARN_LOG(FILESYS, "Directory %s not found, disabling SDMC.", mount_point.c_str());
|
WARN_LOG(FILESYS, "SDMC disabled by config.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!FileUtil::CreateFullPath(mount_point)) {
|
||||||
|
WARN_LOG(FILESYS, "Unable to create SDMC path.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,8 @@ struct Values {
|
||||||
int pad_sdown_key;
|
int pad_sdown_key;
|
||||||
int pad_sleft_key;
|
int pad_sleft_key;
|
||||||
int pad_sright_key;
|
int pad_sright_key;
|
||||||
|
|
||||||
|
bool use_virtual_sd;
|
||||||
} extern values;
|
} extern values;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue