With the new setting filename_skip_regex, which

contains a regular expression, files can be
excluded from the games list again. A typical
use case is the exclusion of all disks except
the first one in multidisk games.
This commit is contained in:
Erik Kunze 2021-09-20 15:30:12 +02:00
parent 3b1fdf06bd
commit a768c2a76a
4 changed files with 23 additions and 6 deletions

View File

@ -16,6 +16,7 @@
****************************************************************************/
#include <dirent.h>
#include <unistd.h>
#include <regex>
#include "ListGenerator.hpp"
#include "cache.hpp"
#include "channel/channels.h"
@ -32,8 +33,10 @@ GameTDB gameTDB;
Config romNamesDB;
string platformName;
string pluginsDataDir;
std::regex fileNameSkipRegex;
void ListGenerator::Init(const char *settingsDir, const char *Language, const char *plgnsDataDir)
void ListGenerator::Init(const char *settingsDir, const char *Language,
const char *plgnsDataDir, const std::string& fileNameSkipPattern)
{
if(settingsDir != NULL)
{
@ -42,6 +45,10 @@ void ListGenerator::Init(const char *settingsDir, const char *Language, const ch
}
if(Language != NULL) gameTDB_Language = Language;
if(plgnsDataDir != NULL) pluginsDataDir = fmt("%s", plgnsDataDir);
fileNameSkipRegex = std::regex(fileNameSkipPattern,
std::regex_constants::extended |
std::regex_constants::icase);
}
void ListGenerator::Clear(void)
@ -253,12 +260,16 @@ static void Add_Plugin_Game(char *FullPath)
{
/* Get roms's title without the extra ()'s or []'s */
string ShortName = m_plugin.GetRomName(FullPath);
//gprintf("fullName=%s, shortName=%s\n", FullPath, ShortName.c_str());
//gprintf("Add_Plugin_Game: fullName=%s, shortName=%s\n", FullPath, ShortName.c_str());
/* only add disc 1 of multi disc games */
const char *RomFilename = strrchr(FullPath, '/') + 1;
if((strstr(RomFilename, "disc") != NULL || strstr(RomFilename, "disk") != NULL) && strstr(RomFilename, ".d1") == NULL)
if (std::regex_search(std::string(FullPath), fileNameSkipRegex))
{
//gprintf("Add_Plugin_Game: skipping '%s'\n", FullPath);
return;
}
/* get rom's ID */
string romID = "";

View File

@ -29,11 +29,15 @@
#include "gui/GameTDB.hpp"
#include "plugin/plugin.hpp"
#define CONFIG_FILENAME_SKIP_DOMAIN "PLUGINS"
#define CONFIG_FILENAME_SKIP_KEY "filename_skip_regex"
#define CONFIG_FILENAME_SKIP_DEFAULT "((dis[ck]|tape|side|track)[ _-]?[b-z2-9])"
class ListGenerator : public std::vector<dir_discHdr>
{
public:
void createSFList(u8 maxBtns, Config &m_sourceMenuCfg, const string& sourceDir);
void Init(const char *settingsDir, const char *Language, const char *plgnsDataDir);
void Init(const char *settingsDir, const char *Language, const char *plgnsDataDir, const std::string& fileNameSkipPattern);
void Clear();
void ParseScummvmINI(Config &ini, const char *Device, const char *datadir, const char *platform, const string& DBName, bool UpdateCache);
void CreateRomList(Config &platform_cfg, const string& romsDir, const vector<string>& FileTypes, const string& DBName, bool UpdateCache);

View File

@ -407,7 +407,8 @@ bool CMenu::init(bool usb_mounted)
}
/* Init gametdb and custom titles for game list making */
m_cacheList.Init(m_settingsDir.c_str(), m_loc.getString(m_curLanguage, "gametdb_code", "EN").c_str(), m_pluginDataDir.c_str());
m_cacheList.Init(m_settingsDir.c_str(), m_loc.getString(m_curLanguage, "gametdb_code", "EN").c_str(), m_pluginDataDir.c_str(),
m_cfg.getString(CONFIG_FILENAME_SKIP_DOMAIN,CONFIG_FILENAME_SKIP_KEY,CONFIG_FILENAME_SKIP_DEFAULT));
/* Init the onscreen pointer */
m_aa = 3;

View File

@ -174,7 +174,8 @@ int CMenu::_configAdv(void)
_hideConfigAdv();
if(m_curLanguage != prevLanguage)
{
m_cacheList.Init(m_settingsDir.c_str(), m_loc.getString(m_curLanguage, "gametdb_code", "EN").c_str(), m_pluginDataDir.c_str());
m_cacheList.Init(m_settingsDir.c_str(), m_loc.getString(m_curLanguage, "gametdb_code", "EN").c_str(), m_pluginDataDir.c_str(),
m_cfg.getString(CONFIG_FILENAME_SKIP_DOMAIN,CONFIG_FILENAME_SKIP_KEY,CONFIG_FILENAME_SKIP_DEFAULT));
fsop_deleteFolder(m_listCacheDir.c_str());// delete cache lists folder and remake it so all lists update.
fsop_MakeFolder(m_listCacheDir.c_str());
m_refreshGameList = true;