rbutilqt: Simplify Utils::findExecutable() using QStandardPaths

rockbox-gerrit-noreply--- via rockbox-cvs <[email protected]> Tue, 7 Jul 2026 21:16:14 -0400
Newsgroups gmane.comp.systems.archos.rockbox.cvs
Message-ID <[email protected]>
commit f62e29f311928f9c0cf793dd055fc74073538733
Author: Vencislav Atanasov <[email protected]>
Date:   Tue Jul 7 23:35:43 2026 +0300

    rbutilqt: Simplify Utils::findExecutable() using QStandardPaths
    
    Co-authored-by: Qwen3.7-Plus
    Change-Id: I8f6f4003ebc7b9a4a8139f5dd4dfca3ae6cff273

diff --git a/utils/rbutilqt/base/utils.cpp b/utils/rbutilqt/base/utils.cpp
index 566782205d..1174e8e63a 100644
--- a/utils/rbutilqt/base/utils.cpp
+++ b/utils/rbutilqt/base/utils.cpp
@@ -30,6 +30,7 @@
 #include <QtCore>
 #include <QDebug>
 #include <QStorageInfo>
+#include <QStandardPaths>
 #include <QDirIterator>
 #include <cstdlib>
 #include <stdio.h>
@@ -259,26 +260,10 @@ qulonglong Utils::filesystemSize(QString path, enum Utils::Size type)
 //! \brief searches for a Executable in the Environement Path
 QString Utils::findExecutable(QString name)
 {
-    //try autodetect tts
-#if defined(Q_OS_LINUX) || defined(Q_OS_MACOS) || defined(Q_OS_OPENBSD)
-    QStringList path = QString(getenv("PATH")).split(":", Qt::SkipEmptyParts);
-#elif defined(Q_OS_WIN)
-    QStringList path = QString(getenv("PATH")).split(";", Qt::SkipEmptyParts);
-#endif
-    LOG_INFO() << "system path:" << path;
-    for(int i = 0; i < path.size(); i++)
-    {
-        QString executable = QDir::fromNativeSeparators(path.at(i)) + "/" + name;
-#if defined(Q_OS_WIN)
-        executable += ".exe";
-        QStringList ex = executable.split("\"", Qt::SkipEmptyParts);
-        executable = ex.join("");
-#endif
-        if(QFileInfo(executable).isExecutable())
-        {
-            LOG_INFO() << "findExecutable: found" << executable;
-            return QDir::toNativeSeparators(executable);
-        }
+    QString executable = QStandardPaths::findExecutable(name);
+    if (!executable.isEmpty()) {
+        LOG_INFO() << "findExecutable: found" << executable;
+        return QDir::toNativeSeparators(executable);
     }
     LOG_INFO() << "findExecutable: could not find" << name;
     return "";
-- 
rockbox-cvs mailing list
[email protected]
https://lists.haxx.se/mailman/listinfo/rockbox-cvs