From f827bb4cbd44917651a09efad2576ed9a171b6b8 Mon Sep 17 00:00:00 2001 From: Themaister Date: Wed, 24 Aug 2011 07:54:52 +0200 Subject: [PATCH] Allow directory path for config files. --- docs/ssnes.1 | 2 ++ ssnes.c | 15 +++++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/docs/ssnes.1 b/docs/ssnes.1 index 6df243f0e3..0b1c02f9ba 100644 --- a/docs/ssnes.1 +++ b/docs/ssnes.1 @@ -53,6 +53,8 @@ Always starts SSNES in fullscreen. Disregards settings in configuration file. Sets the configuration file path. \fBssnes\fR will use this path to load the configuration file. Should this not be defined, \fBssnes\fR will look in platform specific paths to attempt finding the config file. /etc/ssnes.cfg (when installed), or ssnes.cfg in the source tarball serves as a skeleton configuration file. +If PATH is a directory, SSNES will treat this as the config file directory, where the state file name will be inferred from the rom name (*.cfg). +When loading a rom from stdin, the path must be a full path, however. .IP Unix-like systems will look in $XDG_CONFIG_HOME/ssnes/ssnes.cfg first. Then it will try $HOME/.ssnes.cfg. Last, it will try /etc/ssnes.cfg. If no configuration is found, default settings will be assumed. A configuration file does not need to define every possible option, only those that should be overridden. diff --git a/ssnes.c b/ssnes.c index 7f5236b1cb..3fcd7ac4fd 100644 --- a/ssnes.c +++ b/ssnes.c @@ -682,6 +682,11 @@ static void parse_input(int argc, char *argv[]) fill_pathname_dir(g_extern.savestate_name, g_extern.basename, ".state", sizeof(g_extern.savestate_name)); SSNES_LOG("Redirecting save state to \"%s\".\n", g_extern.savestate_name); } + if (*g_extern.config_path && path_is_directory(g_extern.config_path)) + { + fill_pathname_dir(g_extern.config_path, g_extern.basename, ".cfg", sizeof(g_extern.config_path)); + SSNES_LOG("Redirecting config file to \"%s\".\n", g_extern.config_path); + } } else // Read ROM from stdin. { @@ -700,13 +705,19 @@ static void parse_input(int argc, char *argv[]) if (path_is_directory(g_extern.savefile_name_srm)) { - SSNES_ERR("Cannot specify directory for path argument (--save) when reading from from stdin.\n"); + SSNES_ERR("Cannot specify directory for path argument (--save) when reading from stdin.\n"); print_help(); exit(1); } else if (path_is_directory(g_extern.savestate_name)) { - SSNES_ERR("Cannot specify directory for path argument (--savestate) when reading from from stdin.\n"); + SSNES_ERR("Cannot specify directory for path argument (--savestate) when reading from stdin.\n"); + print_help(); + exit(1); + } + else if (path_is_directory(g_extern.config_path)) + { + SSNES_ERR("Cannot specify directory for config file (--config) when reading from stdin.\n"); print_help(); exit(1); }