Added support for lists of file extensions, delimited by a space.

This commit is contained in:
Aloshi 2012-09-08 13:17:36 -05:00
parent e479746bcb
commit 5786ecae7c
4 changed files with 33 additions and 10 deletions

View file

@ -21,7 +21,8 @@ There are also a few libraries already on the RPi (located in /opt/vc/, like the
Configuring Configuring
=========== ===========
When first run, an example systems configuration file will be created at $HOME/.emulationstation/es_systems.cfg. This example has some comments explaining how to write the configuration file, and an example RetroArch launch command. Keep in mind you can define more than one system! Just use all the variables again. **~/.emulationstation/es_systems.cfg:**
When first run, an example systems configuration file will be created at $HOME/.emulationstation/es_systems.cfg. This example has some comments explaining how to write the configuration file, and an example RetroArch launch command. Keep in mind you can define more than one system! Just use all the variables again. Also, you can use multiple extensions - just separate them with a space, e.g.: ".nes .NES .bin".
If an SDL Joystick is detected at startup, and $HOME/.emulationstation/es_input.cfg is nonexistant, an Input Configuration screen will appear instead of the game list. This should be pretty self-explanatory. If you want to reconfigure, just delete $HOME/.emulationstation/es_input.cfg. If an SDL Joystick is detected at startup, and $HOME/.emulationstation/es_input.cfg is nonexistant, an Input Configuration screen will appear instead of the game list. This should be pretty self-explanatory. If you want to reconfigure, just delete $HOME/.emulationstation/es_input.cfg.

View file

@ -1,3 +1,7 @@
September 8
-Added support for multiple filetypes for systems - just separate them with a space.
-Updated example systems config to include example for multiple filetypes and be a little clearer.
September 7 September 7
-Tiling is now much faster. -Tiling is now much faster.
-Added --draw-framerate and --help/-h command-line parameters. -Added --draw-framerate and --help/-h command-line parameters.

View file

@ -117,11 +117,29 @@ void SystemData::populateFolder(FolderData* folder)
else else
folder->pushFileData(newFolder); folder->pushFileData(newFolder);
}else{ }else{
if(filePath.extension().string() == mSearchExtension) //this is a little complicated because we allow a list of extensions to be defined (delimited with a space)
//we first get the extension of the file itself:
std::string extension = filePath.extension().string();
std::string chkExt;
size_t extPos = 0;
do {
//now we loop through every extension in the list
size_t cpos = extPos;
extPos = mSearchExtension.find(" ", extPos);
chkExt = mSearchExtension.substr(cpos, ((extPos == std::string::npos) ? mSearchExtension.length() - cpos: extPos - cpos));
//if it matches, add it
if(chkExt == mSearchExtension)
{ {
GameData* newGame = new GameData(this, filePath.string(), filePath.stem().string()); GameData* newGame = new GameData(this, filePath.string(), filePath.stem().string());
folder->pushFileData(newGame); folder->pushFileData(newGame);
break;
}else if(extPos != std::string::npos) //if not, add one to the "next position" marker to skip the space when reading the next extension
{
extPos++;
} }
} while(extPos != std::string::npos && chkExt != "");
} }
} }
} }
@ -225,13 +243,13 @@ void SystemData::writeExampleConfig()
file << "# A sample system might look like this:" << std::endl; file << "# A sample system might look like this:" << std::endl;
file << "#NAME=Nintendo Entertainment System" << std::endl; file << "#NAME=Nintendo Entertainment System" << std::endl;
file << "#PATH=~/ROMs/nes/" << std::endl; file << "#PATH=~/ROMs/nes/" << std::endl;
file << "#EXTENSION=.nes" << std::endl; file << "#EXTENSION=.nes .NES" << std::endl;
file << "#COMMAND=retroarch -L ~/cores/libretro-fceumm.so %ROM%" << std::endl << std::endl; file << "#COMMAND=retroarch -L ~/cores/libretro-fceumm.so %ROM%" << std::endl << std::endl;
file << "#NAME is just a name to identify the system." << std::endl; file << "#NAME is just a name to identify the system." << std::endl;
file << "#PATH is the path to start the recursive search for ROMs in. ~ will be expanded into the $HOME variable." << std::endl; file << "#PATH is the path to start the recursive search for ROMs in. ~ will be expanded into the $HOME variable." << std::endl;
file << "#EXTENSION is the exact extension to search for. You MUST include the period, and it must be exact - no regex or wildcard support (sorry!)." << std::endl; file << "#EXTENSION is a list of extensions to search for, separated by spaces. You MUST include the period, and it must be exact - it's case sensitive, and no wildcards." << std::endl;
file << "#COMMAND is the shell command to execute when a game is selected. %ROM% will be replaced with the path to the ROM." << std::endl << std::endl; file << "#COMMAND is the shell command to execute when a game is selected. %ROM% will be replaced with the (bash special-character escaped) path to the ROM." << std::endl << std::endl;
file << "#Now try your own!" << std::endl; file << "#Now try your own!" << std::endl;
file << "NAME=" << std::endl; file << "NAME=" << std::endl;

View file

@ -85,7 +85,7 @@ GameData* createGameFromPath(std::string gameAbsPath, SystemData* system)
//find gameName //find gameName
std::string gameName = gamePath.substr(separator + 1, gamePath.find(system->getExtension(), separator) - separator - 1); std::string gameName = gamePath.substr(separator + 1, gamePath.find(".", separator) - separator - 1);
GameData* game = new GameData(system, gameAbsPath, gameName); GameData* game = new GameData(system, gameAbsPath, gameName);
folder->pushFileData(game); folder->pushFileData(game);