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)
|
||||
return FilePath();
|
||||
|
||||
const QString dir = directory.toString();
|
||||
|
||||
QFileInfo fi;
|
||||
for (const QString &exec : execs) {
|
||||
fi.setFile(dir, exec);
|
||||
if (fi.isFile() && fi.isExecutable())
|
||||
return FilePath::fromString(fi.absoluteFilePath());
|
||||
const FilePath filePath = directory.pathAppended(exec);
|
||||
if (filePath.isExecutableFile())
|
||||
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.
|
||||
|
||||
Example usage:
|
||||
@@ -1186,25 +1186,26 @@ FilePath FilePath::searchInDirectories(const FilePaths &dirs) const
|
||||
{
|
||||
if (isAbsolutePath())
|
||||
return *this;
|
||||
// FIXME: Ramp down use.
|
||||
QTC_ASSERT(!needsDevice(), return {});
|
||||
return Environment::systemEnvironment().searchInDirectories(path(), dirs);
|
||||
return deviceEnvironment().searchInDirectories(path(), dirs);
|
||||
}
|
||||
|
||||
FilePath FilePath::searchInPath(const FilePaths &additionalDirs, PathAmending amending) const
|
||||
{
|
||||
if (isAbsolutePath())
|
||||
return *this;
|
||||
// FIXME: Ramp down use.
|
||||
FilePaths directories = deviceEnvironment().path();
|
||||
if (needsDevice()) {
|
||||
directories = Utils::transform(directories, [this](const FilePath &path) {
|
||||
return path.onDevice(*this);
|
||||
});
|
||||
}
|
||||
if (!additionalDirs.isEmpty()) {
|
||||
if (amending == AppendToPath)
|
||||
directories.append(additionalDirs);
|
||||
else
|
||||
directories = additionalDirs + directories;
|
||||
}
|
||||
QTC_ASSERT(!needsDevice(), return {});
|
||||
return Environment::systemEnvironment().searchInDirectories(path(), directories);
|
||||
return searchInDirectories(directories);
|
||||
}
|
||||
|
||||
Environment FilePath::deviceEnvironment() const
|
||||
|
Reference in New Issue
Block a user