Commit 4f6eb4a5 authored by Kevin Funk's avatar Kevin Funk Committed by Kevin Funk
Browse files

Simplify code, use QStandardPaths::findExecutable


Change-Id: I9f02c81114c913fd9c1056cede12ec8a344683f7
Reviewed-by: default avatarContinuous Integration (KDAB) <build@kdab.com>
Reviewed-by: default avatarBrett Stottlemyer <bstottle@ford.com>
Showing with 12 additions and 20 deletions
......@@ -42,22 +42,18 @@
#include <QtTest/QtTest>
#include <QMetaType>
#include <QProcess>
#include <QStandardPaths>
namespace {
QString findExecutable(const QString &executableName, const QStringList &pathHints)
QString findExecutable(const QString &executableName, const QStringList &paths)
{
foreach (const auto &pathHint, pathHints) {
#ifdef Q_OS_WIN
const QString executablePath = pathHint + executableName + ".exe";
#else
const QString executablePath = pathHint + executableName;
#endif
if (QFileInfo::exists(executablePath))
return executablePath;
const auto path = QStandardPaths::findExecutable(executableName, paths);
if (!path.isEmpty()) {
return path;
}
qWarning() << "Could not find executable:" << executableName << "in any of" << pathHints;
qWarning() << "Could not find executable:" << executableName << "in any of" << paths;
return QString();
}
......
......@@ -42,22 +42,18 @@
#include <QtTest/QtTest>
#include <QMetaType>
#include <QProcess>
#include <QStandardPaths>
namespace {
QString findExecutable(const QString &executableName, const QStringList &pathHints)
QString findExecutable(const QString &executableName, const QStringList &paths)
{
foreach (const auto &pathHint, pathHints) {
#ifdef Q_OS_WIN
const QString executablePath = pathHint + executableName + ".exe";
#else
const QString executablePath = pathHint + executableName;
#endif
if (QFileInfo::exists(executablePath))
return executablePath;
const auto path = QStandardPaths::findExecutable(executableName, paths);
if (!path.isEmpty()) {
return path;
}
qWarning() << "Could not find executable:" << executableName << "in any of" << pathHints;
qWarning() << "Could not find executable:" << executableName << "in any of" << paths;
return QString();
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment