From 969ab8aeb02995498ee2e2c821ef0cf5e6d541b5 Mon Sep 17 00:00:00 2001 From: Peter Veenstra Date: Sun, 9 May 2010 07:52:01 +0000 Subject: [PATCH] Add -userconf to force loading of user specific configfile. Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@3598 --- src/gui/sdlmain.cpp | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/gui/sdlmain.cpp b/src/gui/sdlmain.cpp index 974eed26..6bbc24c3 100644 --- a/src/gui/sdlmain.cpp +++ b/src/gui/sdlmain.cpp @@ -1791,7 +1791,28 @@ int main(int argc, char* argv[]) { /* Parse configuration files */ std::string config_file,config_path; bool parsed_anyconfigfile = false; - //First Parse -conf switches + //First Parse -userconf + if(control->cmdline->FindExist("-userconf",true)){ + config_file.clear(); + Cross::GetPlatformConfigDir(config_path); + Cross::GetPlatformConfigName(config_file); + config_path += config_file; + if(control->ParseConfigFile(config_path.c_str())) parsed_anyconfigfile = true; + if(!parsed_anyconfigfile) { + //Try to create the userlevel configfile. + config_file.clear(); + Cross::CreatePlatformConfigDir(config_path); + Cross::GetPlatformConfigName(config_file); + config_path += config_file; + if(control->PrintConfig(config_path.c_str())) { + LOG_MSG("CONFIG: Generating default configuration.\nWriting it to %s",config_path.c_str()); + //Load them as well. Makes relative paths much easier + if(control->ParseConfigFile(config_path.c_str())) parsed_anyconfigfile = true; + } + } + } + + //Second parse -conf entries while(control->cmdline->FindString("-conf",config_file,true)) if (control->ParseConfigFile(config_file.c_str())) parsed_anyconfigfile = true;