mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-25 15:45:38 +00:00
Added proper support for interpreting directories as files.
This commit is contained in:
parent
3e28bacdcf
commit
daf66c4b60
|
@ -298,15 +298,22 @@ bool SystemData::populateFolder(FileData* folder)
|
|||
// We first get the extension of the file itself:
|
||||
extension = Utils::FileSystem::getExtension(filePath);
|
||||
|
||||
// FYI, folders *can* also match the extension and be added as games.
|
||||
// This is mostly just to support higan.
|
||||
// See issue #75: https://github.com/Aloshi/EmulationStation/issues/75
|
||||
|
||||
isGame = false;
|
||||
if (std::find(mEnvData->mSearchExtensions.cbegin(), mEnvData->mSearchExtensions.cend(),
|
||||
extension) != mEnvData->mSearchExtensions.cend()) {
|
||||
FileData* newGame = new FileData(GAME, filePath, mEnvData, this);
|
||||
|
||||
// If adding a configured file extension to a directory it will get interpreted as
|
||||
// a regular file. This is useful for some emulators that can get directories passed
|
||||
// to them as command line parameters instead of regular files. In these instances
|
||||
// we remove the extension from the metadata name so it does not show up in the
|
||||
// gamelists and similar.
|
||||
if (Utils::FileSystem::isDirectory(filePath)) {
|
||||
const std::string folderName = newGame->metadata.get("name");
|
||||
newGame->metadata.set(
|
||||
"name", folderName.substr(0, folderName.length() - extension.length()));
|
||||
}
|
||||
|
||||
// Prevent new arcade assets from being added.
|
||||
if (!newGame->isArcadeAsset()) {
|
||||
folder->addChild(newGame);
|
||||
|
|
|
@ -385,6 +385,11 @@ void GuiGamelistOptions::openMetaDataEd()
|
|||
LOG(LogInfo) << "Deleting the media files and gamelist.xml entry for the folder \""
|
||||
<< file->getFullPath() << "\"";
|
||||
}
|
||||
else if (file->getType() == GAME && Utils::FileSystem::isDirectory(file->getFullPath())) {
|
||||
LOG(LogInfo) << "Deleting the media files and gamelist.xml entry for the "
|
||||
"file-interpreted folder \""
|
||||
<< file->getFullPath() << "\"";
|
||||
}
|
||||
else {
|
||||
LOG(LogInfo) << "Deleting the media files and gamelist.xml entry for the file \""
|
||||
<< file->getFullPath() << "\"";
|
||||
|
@ -408,6 +413,11 @@ void GuiGamelistOptions::openMetaDataEd()
|
|||
file->metadata.set(it->key, it->defaultValue);
|
||||
}
|
||||
|
||||
// For the special case where a directory has a supported file extension and is therefore
|
||||
// interpreted as a file, don't include the extension in the metadata name.
|
||||
if (file->getType() == GAME && Utils::FileSystem::isDirectory(file->getFullPath()))
|
||||
file->metadata.set("name", Utils::FileSystem::getStem(file->metadata.get("name")));
|
||||
|
||||
// Update all collections where the game is present.
|
||||
if (file->getType() == GAME)
|
||||
CollectionSystemsManager::get()->refreshCollectionSystems(file, true);
|
||||
|
|
|
@ -429,11 +429,19 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window,
|
|||
// If the user has entered a blank game name, then set the name to the ROM
|
||||
// filename (minus the extension).
|
||||
if (currentKey == "name" && newVal == "") {
|
||||
if (scraperParams.game->isArcadeGame())
|
||||
if (scraperParams.game->isArcadeGame()) {
|
||||
ed->setValue(MameNames::getInstance().getCleanName(
|
||||
scraperParams.game->getCleanName()));
|
||||
}
|
||||
else {
|
||||
// For the special case where a directory has a supported file extension
|
||||
// and is therefore interpreted as a file, exclude the extension.
|
||||
if (scraperParams.game->getType() == GAME &&
|
||||
Utils::FileSystem::isDirectory(scraperParams.game->getFullPath()))
|
||||
ed->setValue(Utils::FileSystem::getStem(gamePath));
|
||||
else
|
||||
ed->setValue(gamePath);
|
||||
}
|
||||
if (gamePath == originalValue)
|
||||
ed->setColor(DEFAULT_TEXTCOLOR);
|
||||
else
|
||||
|
@ -546,7 +554,9 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window,
|
|||
clearSelfBtnFunc));
|
||||
}
|
||||
|
||||
if (mDeleteGameFunc) {
|
||||
// For the special case where a directory has a supported file extension and is therefore
|
||||
// interpreted as a file, don't add the delete button.
|
||||
if (mDeleteGameFunc && !Utils::FileSystem::isDirectory(scraperParams.game->getPath())) {
|
||||
auto deleteFilesAndSelf = [&] {
|
||||
mDeleteGameFunc();
|
||||
delete this;
|
||||
|
|
|
@ -823,12 +823,22 @@ void GuiScraperSearch::openInputScreen(ScraperSearchParams& params)
|
|||
// in case the scraper is set to TheGamesDB and it's an arcade game. This is
|
||||
// required as TheGamesDB does not support searches using the short MAME names.
|
||||
if (params.game->isArcadeGame() &&
|
||||
Settings::getInstance()->getString("Scraper") == "thegamesdb")
|
||||
Settings::getInstance()->getString("Scraper") == "thegamesdb") {
|
||||
searchString = MameNames::getInstance().getCleanName(params.game->getCleanName());
|
||||
else
|
||||
}
|
||||
else {
|
||||
if (params.game->getType() == GAME &&
|
||||
Utils::FileSystem::isDirectory(params.game->getFullPath())) {
|
||||
// For the special case where a directory has a supported file extension and is
|
||||
// therefore interpreted as a file, exclude the extension from the search.
|
||||
searchString = Utils::FileSystem::getStem(params.game->getCleanName());
|
||||
}
|
||||
else {
|
||||
searchString = params.game->getCleanName();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
searchString = params.nameOverride;
|
||||
}
|
||||
|
|
|
@ -156,12 +156,23 @@ void thegamesdb_generate_json_scraper_requests(
|
|||
// If not searching based on the metadata name, then check whether it's an
|
||||
// arcade game and if so expand to the full game name. This is required as
|
||||
// TheGamesDB has issues with searching using the short MAME names.
|
||||
if (params.game->isArcadeGame())
|
||||
if (params.game->isArcadeGame()) {
|
||||
cleanName = MameNames::getInstance().getCleanName(params.game->getCleanName());
|
||||
else
|
||||
}
|
||||
else {
|
||||
if (params.game->getType() == GAME &&
|
||||
Utils::FileSystem::isDirectory(params.game->getFullPath())) {
|
||||
// For the special case where a directory has a supported file extension
|
||||
// and is therefore interpreted as a file, exclude the extension from the
|
||||
// search.
|
||||
cleanName = Utils::FileSystem::getStem(params.game->getCleanName());
|
||||
}
|
||||
else {
|
||||
cleanName = params.game->getCleanName();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Trim leading and trailing whitespaces.
|
||||
cleanName = Utils::String::trim(cleanName);
|
||||
|
|
|
@ -181,11 +181,24 @@ void screenscraper_generate_scraper_requests(const ScraperSearchParams& params,
|
|||
ssConfig.isArcadeSystem = false;
|
||||
|
||||
if (params.nameOverride == "") {
|
||||
if (Settings::getInstance()->getBool("ScraperSearchMetadataName"))
|
||||
if (Settings::getInstance()->getBool("ScraperSearchMetadataName")) {
|
||||
path = ssConfig.getGameSearchUrl(
|
||||
Utils::String::removeParenthesis(params.game->metadata.get("name")));
|
||||
else
|
||||
path = ssConfig.getGameSearchUrl(params.game->getCleanName());
|
||||
}
|
||||
else {
|
||||
std::string cleanName;
|
||||
if (params.game->getType() == GAME &&
|
||||
Utils::FileSystem::isDirectory(params.game->getFullPath())) {
|
||||
// For the special case where a directory has a supported file extension and is
|
||||
// therefore interpreted as a file, exclude the extension from the search.
|
||||
cleanName = Utils::FileSystem::getStem(params.game->getCleanName());
|
||||
}
|
||||
else {
|
||||
cleanName = params.game->getCleanName();
|
||||
}
|
||||
|
||||
path = ssConfig.getGameSearchUrl(cleanName);
|
||||
}
|
||||
}
|
||||
else {
|
||||
path = ssConfig.getGameSearchUrl(params.nameOverride);
|
||||
|
|
Loading…
Reference in a new issue