Other: Bridge must now be in the same folder as bridge-gui.

This commit is contained in:
Xavier Michelon
2022-07-28 14:58:18 +02:00
committed by Jakub
parent fd8abc168d
commit 5113d52444

View File

@ -32,8 +32,6 @@ QString const exeSuffix;
#endif
QString const exeName = "bridge" + exeSuffix; ///< The bridge executable file name.
QString const devDir = "cmd/Desktop-Bridge"; ///< The folder typically containg the bridge executable in a developer's environment.
int const maxExeUpwardSeekingDepth = 5; ///< The maximum number of parent folder that will searched when trying to locate the bridge executable.
}
@ -45,23 +43,8 @@ int const maxExeUpwardSeekingDepth = 5; ///< The maximum number of parent folder
//****************************************************************************************************************************************************
QString BridgeMonitor::locateBridgeExe()
{
QString const currentDir = QDir::current().absolutePath();
QString const exeDir = QCoreApplication::applicationDirPath();
QStringList dirs = {currentDir, exeDir};
for (int i = 0; i <= maxExeUpwardSeekingDepth; ++i)
{
dirs.append(currentDir + QString("../").repeated(i) + devDir);
dirs.append(exeDir + QString("../").repeated(i) + devDir);
}
for (QString const &dir: dirs)
{
QFileInfo const fileInfo(QDir(dir).absoluteFilePath(exeName));
if (fileInfo.exists() && fileInfo.isFile() && fileInfo.isExecutable())
return fileInfo.absoluteFilePath();
}
return QString();
QFileInfo const fileInfo(QDir(QCoreApplication::applicationDirPath()).absoluteFilePath(exeName));
return (fileInfo.exists() && fileInfo.isFile() && fileInfo.isExecutable()) ? fileInfo.absoluteFilePath() : QString();
}