Allow directory path for config files.

This commit is contained in:
Themaister 2011-08-24 07:54:52 +02:00
parent eafd8d91d7
commit f827bb4cbd
2 changed files with 15 additions and 2 deletions

View File

@ -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.

15
ssnes.c
View File

@ -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);
}