diff --git a/GAMELISTS.md b/GAMELISTS.md index 7064a27ca3..ac5196be84 100644 --- a/GAMELISTS.md +++ b/GAMELISTS.md @@ -75,7 +75,8 @@ Things to be Aware Of * If a value matches the default for a particular piece of metadata, ES will not write it to the gamelist.xml (for example, if `genre` isn't specified, ES won't write an empty genre tag; if `players` is 1, ES won't write a `players` tag). -* A `game` can actually point to a folder/directory if the the folder has a matching extension. +* A `game` can actually point to a folder/directory if the the folder has a matching extension. It shows up as a game in ES. +When launch this, if there is a file with the same name as the folder in that folder, that file will be passed to the command as `%ROM%`. Otherwise, just the directory path is passed. * `folder` metadata will only be used if a game is found inside of that folder. diff --git a/es-app/src/FileData.cpp b/es-app/src/FileData.cpp index 1aa4f0f076..5de1d5dd61 100644 --- a/es-app/src/FileData.cpp +++ b/es-app/src/FileData.cpp @@ -287,9 +287,17 @@ void FileData::launchGame(Window* window) std::string command = mEnvData->mLaunchCommand; - const std::string rom = Utils::FileSystem::getEscapedPath(getPath()); - const std::string basename = Utils::FileSystem::getStem(getPath()); - const std::string rom_raw = Utils::FileSystem::getPreferredPath(getPath()); + std::string path = getPath(); + if(Utils::FileSystem::isDirectory(path)) + { + const std::string path2 = Utils::FileSystem::resolveRelativePath(Utils::FileSystem::getFileName(path), path, false, true); + if(Utils::FileSystem::isRegularFile(path2)) + path = path2; + } + + const std::string rom = Utils::FileSystem::getEscapedPath(path); + const std::string basename = Utils::FileSystem::getStem(path); + const std::string rom_raw = Utils::FileSystem::getPreferredPath(path); const std::string name = getName(); command = Utils::String::replace(command, "%ROM%", rom);