forked from qt-creator/qt-creator
Utils: Fix FilePath::searchInPath remotely
Change-Id: I49bd7fd96427b55d28743eab277c72710a2ac6c0 Reviewed-by: hjk <hjk@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -140,13 +140,10 @@ static FilePath searchInDirectory(const QStringList &execs,
|
|||||||
if (directory.isEmpty() || alreadyChecked.count() == checkedCount)
|
if (directory.isEmpty() || alreadyChecked.count() == checkedCount)
|
||||||
return FilePath();
|
return FilePath();
|
||||||
|
|
||||||
const QString dir = directory.toString();
|
|
||||||
|
|
||||||
QFileInfo fi;
|
|
||||||
for (const QString &exec : execs) {
|
for (const QString &exec : execs) {
|
||||||
fi.setFile(dir, exec);
|
const FilePath filePath = directory.pathAppended(exec);
|
||||||
if (fi.isFile() && fi.isExecutable())
|
if (filePath.isExecutableFile())
|
||||||
return FilePath::fromString(fi.absoluteFilePath());
|
return filePath;
|
||||||
}
|
}
|
||||||
return FilePath();
|
return FilePath();
|
||||||
}
|
}
|
||||||
|
@@ -1172,7 +1172,7 @@ FilePath FilePath::withNewPath(const QString &newPath) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Searched a binary corresponding to this object in the PATH of
|
Search for a binary corresponding to this object in the PATH of
|
||||||
the device implied by this object's scheme and host.
|
the device implied by this object's scheme and host.
|
||||||
|
|
||||||
Example usage:
|
Example usage:
|
||||||
@@ -1186,25 +1186,26 @@ FilePath FilePath::searchInDirectories(const FilePaths &dirs) const
|
|||||||
{
|
{
|
||||||
if (isAbsolutePath())
|
if (isAbsolutePath())
|
||||||
return *this;
|
return *this;
|
||||||
// FIXME: Ramp down use.
|
return deviceEnvironment().searchInDirectories(path(), dirs);
|
||||||
QTC_ASSERT(!needsDevice(), return {});
|
|
||||||
return Environment::systemEnvironment().searchInDirectories(path(), dirs);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FilePath FilePath::searchInPath(const FilePaths &additionalDirs, PathAmending amending) const
|
FilePath FilePath::searchInPath(const FilePaths &additionalDirs, PathAmending amending) const
|
||||||
{
|
{
|
||||||
if (isAbsolutePath())
|
if (isAbsolutePath())
|
||||||
return *this;
|
return *this;
|
||||||
// FIXME: Ramp down use.
|
|
||||||
FilePaths directories = deviceEnvironment().path();
|
FilePaths directories = deviceEnvironment().path();
|
||||||
|
if (needsDevice()) {
|
||||||
|
directories = Utils::transform(directories, [this](const FilePath &path) {
|
||||||
|
return path.onDevice(*this);
|
||||||
|
});
|
||||||
|
}
|
||||||
if (!additionalDirs.isEmpty()) {
|
if (!additionalDirs.isEmpty()) {
|
||||||
if (amending == AppendToPath)
|
if (amending == AppendToPath)
|
||||||
directories.append(additionalDirs);
|
directories.append(additionalDirs);
|
||||||
else
|
else
|
||||||
directories = additionalDirs + directories;
|
directories = additionalDirs + directories;
|
||||||
}
|
}
|
||||||
QTC_ASSERT(!needsDevice(), return {});
|
return searchInDirectories(directories);
|
||||||
return Environment::systemEnvironment().searchInDirectories(path(), directories);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Environment FilePath::deviceEnvironment() const
|
Environment FilePath::deviceEnvironment() const
|
||||||
|
Reference in New Issue
Block a user