sdl: by default; check ${fceux_dir}/cfg.d/ for any files and loads the configuration in alphabetical order. useful for applying a specific configuration

This commit is contained in:
punkrockguy318 2012-03-06 06:37:10 +00:00
parent 06c8230c88
commit 7d6a4b00d2
3 changed files with 32 additions and 4 deletions

View File

@ -1,5 +1,4 @@
06-mar-2012 - prg - supports loading of configuration files in $FCEUXDIR/cfg.d/*
18-feb-2012 - AnS - PATTERNS menu, loading data from "tools\taseditor_patterns.txt" 18-feb-2012 - AnS - PATTERNS menu, loading data from "tools\taseditor_patterns.txt"
18-feb-2012 - AnS - "Use pattern" checkbox in Recorder; Config->ColumnSet Pattern skips Lag 18-feb-2012 - AnS - "Use pattern" checkbox in Recorder; Config->ColumnSet Pattern skips Lag
18-feb-2012 - AnS - Taseditor: "Frame#" lights when Alt key is being held, not entering menu by Alt 18-feb-2012 - AnS - Taseditor: "Frame#" lights when Alt key is being held, not entering menu by Alt

View File

@ -3,6 +3,7 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <dirent.h>
#include "../../types.h" #include "../../types.h"
#include "configSys.h" #include "configSys.h"
@ -558,6 +559,33 @@ Config::parse(int argc,
return error; return error;
} }
// try to read cfg.d/*
std::string cfgd_dir_name = _dir + "/" + "cfg.d/";
DIR *d;
struct dirent *dir;
d = opendir(cfgd_dir_name.c_str());
if (d)
{
while ((dir = readdir(d)) != NULL)
{
// dont load "." or ".."
if(strcmp(dir->d_name, ".") == 0 || strcmp(dir->d_name, "..") == 0)
{
continue;
}
// TODO 0 = good -1 = bad
std::string fname = cfgd_dir_name + dir->d_name;
printf("Loading configuration file at %s\n", fname.c_str());
if (_loadFile(fname.c_str()) != 0)
{
printf("Failed to parse configuration at %s\n", fname.c_str());
}
}
closedir(d);
}
// parse the arguments // parse the arguments
return _parseArgs(argc, argv); return _parseArgs(argc, argv);
} }

View File

@ -56,7 +56,7 @@ LoadCPalette(const std::string &file)
static void static void
CreateDirs(const std::string &dir) CreateDirs(const std::string &dir)
{ {
char *subs[7]={"fcs","snaps","gameinfo","sav","cheats","movies"}; char *subs[8]={"fcs","snaps","gameinfo","sav","cheats","movies","cfg.d"};
std::string subdir; std::string subdir;
int x; int x;
@ -105,7 +105,8 @@ GetBaseDirectory(std::string &dir)
} }
} }
// returns a config structure with default options
// also creates config base directory (ie: /home/user/.fceux as well as subdirs
Config * Config *
InitConfig() InitConfig()
{ {