From 077c6abf3e5346559cf115a595ab262083b250bf Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Sun, 28 Aug 2022 12:06:03 +0200 Subject: [PATCH] (Unix) Updated the .desktop file parser to handle some non-standard shortcut files. --- es-app/src/FileData.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/es-app/src/FileData.cpp b/es-app/src/FileData.cpp index 71167af4a..7647a7001 100644 --- a/es-app/src/FileData.cpp +++ b/es-app/src/FileData.cpp @@ -1448,6 +1448,13 @@ void FileData::launchGame() std::ifstream desktopFileStream; desktopFileStream.open(Utils::String::replace(romPath, "\\", "")); for (std::string line; getline(desktopFileStream, line);) { + // Some non-standard .desktop files add a leading line such as + // "#!/usr/bin/env xdg-open" and some lines may also be indented by + // whitespace characters. So we need to handle such oddities in order + // to parse and run these files. + line = Utils::String::trim(line); + if (line.substr(0, 2) == "#!") + continue; if (line.find("[Desktop Entry]") != std::string::npos) validFile = true; if (line.substr(0, 5) == "Exec=") {