Compare commits

...

2 commits

Author SHA1 Message Date
PhilaPhan80
3cd6d4bba5
Merge feab8293e5 into 4a064a2130 2024-04-27 16:02:51 +02:00
PhilaPhan80
feab8293e5 Ignore filenames when loading systems 2021-08-11 21:12:24 -04:00
4 changed files with 40 additions and 1 deletions

View file

@ -248,6 +248,10 @@ All systems must be contained within the <systemList> tag.-->
You MUST include the period at the start of the extension! It's also case sensitive. -->
<extension>.smc .sfc .SMC .SFC</extension>
<!-- A list of filenames to ignore, delimited by any of the whitespace characters (", \r\n\t").
You MUST wrap each filename in double quotes (since some filenames contain spaces). Not case sensitive. -->
<ignore>"filename1.bin" "filename2.iso" "filename3.zip"</ignore>
<!-- The shell command executed when a game is selected. A few special tags are replaced if found in a command, like %ROM% (see below). -->
<command>snesemulator %ROM%</command>
<!-- This example would run the bash command "snesemulator /home/user/roms/snes/Super\ Mario\ World.sfc". -->

View file

@ -44,6 +44,8 @@ CollectionSystemManager::CollectionSystemManager(Window* window) : mWindow(windo
mCollectionEnvData->mStartPath = "";
std::vector<std::string> exts;
mCollectionEnvData->mSearchExtensions = exts;
std::vector<std::string> ignores;
mCollectionEnvData->mFilesToIgnore = ignores;
mCollectionEnvData->mLaunchCommand = "";
std::vector<PlatformIds::PlatformId> allPlatformIds;
allPlatformIds.push_back(PlatformIds::PLATFORM_IGNORE);

View file

@ -102,7 +102,12 @@ void SystemData::populateFolder(FileData* folder)
// skip hidden files and folders
if(!showHidden && Utils::FileSystem::isHidden(filePath))
continue;
// skip ignored files and folders
std::string fileName = Utils::String::toLower(Utils::FileSystem::getFileName(filePath));
if(std::find(mEnvData->mFilesToIgnore.cbegin(), mEnvData->mFilesToIgnore.cend(), fileName) != mEnvData->mFilesToIgnore.cend())
continue;
//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:
extension = Utils::FileSystem::getExtension(filePath);
@ -192,6 +197,27 @@ SystemData* SystemData::loadSystem(pugi::xml_node system)
extensions.push_back(xt);
}
list.clear();
list = readList(system.child("ignore").text().get());
std::vector<std::string> ignores;
for (auto ignore = list.cbegin(); ignore != list.cend(); ignore++)
{
std::string ig = Utils::String::toLower(*ignore);
ig = Utils::String::replace(ig, "\"", "");
if (std::find(ignores.begin(), ignores.end(), ig) == ignores.end())
ignores.push_back(ig);
}
list.clear();
cmd = system.child("command").text().get();
// platform id list
@ -244,6 +270,7 @@ SystemData* SystemData::loadSystem(pugi::xml_node system)
SystemEnvironmentData* envData = new SystemEnvironmentData;
envData->mStartPath = path;
envData->mSearchExtensions = extensions;
envData->mFilesToIgnore = ignores;
envData->mLaunchCommand = cmd;
envData->mPlatformIds = platformIds;
@ -414,6 +441,10 @@ void SystemData::writeExampleConfig(const std::string& path)
" You MUST include the period at the start of the extension! It's also case sensitive. -->\n"
" <extension>.nes .NES</extension>\n"
"\n"
" <!-- A list of filenames to ignore, delimited by any of the whitespace characters (\", \\r\\n\\t\").\n"
" You MUST wrap each filename in double quotes (since some filenames contain spaces). Not case sensitive. -->\n"
" <ignore>\"filename1.bin\" \"filename2.iso\" \"filename3.zip\"</ignore>\n"
"\n"
" <!-- The shell command executed when a game is selected. A few special tags are replaced if found in a command:\n"
" %ROM% is replaced by a bash-special-character-escaped absolute path to the ROM.\n"
" %BASENAME% is replaced by the \"base\" name of the ROM. For example, \"/foo/bar.rom\" would have a basename of \"bar\". Useful for MAME.\n"

View file

@ -20,6 +20,7 @@ struct SystemEnvironmentData
{
std::string mStartPath;
std::vector<std::string> mSearchExtensions;
std::vector<std::string> mFilesToIgnore;
std::string mLaunchCommand;
std::vector<PlatformIds::PlatformId> mPlatformIds;
};
@ -35,6 +36,7 @@ public:
inline const std::string& getFullName() const { return mFullName; }
inline const std::string& getStartPath() const { return mEnvData->mStartPath; }
inline const std::vector<std::string>& getExtensions() const { return mEnvData->mSearchExtensions; }
inline const std::vector<std::string>& getFilesToIgnore() const { return mEnvData->mFilesToIgnore; }
inline const std::string& getThemeFolder() const { return mThemeFolder; }
inline SystemEnvironmentData* getSystemEnvData() const { return mEnvData; }
inline const std::vector<PlatformIds::PlatformId>& getPlatformIds() const { return mEnvData->mPlatformIds; }