Utils/ProjectExplorer: Add IDevice::searchInPath

Change-Id: Ibc7cc7bd6bf3a7776681f7cd2fff051525b19f60
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
hjk
2021-06-07 15:47:06 +02:00
parent 16a8a08484
commit 18245dcf10
7 changed files with 55 additions and 0 deletions

View File

@@ -28,6 +28,7 @@
#include "algorithm.h"
#include "commandline.h"
#include "environment.h"
#include "qtcassert.h"
#include <QDataStream>
@@ -1277,6 +1278,26 @@ FilePath FilePath::onDevice(const FilePath &deviceTemplate) const
return res;
}
/*!
Searched a binary corresponding to this object in the PATH of
the device implied by this object's scheme and host.
Example usage:
\code
binary = FilePath::fromUrl("docker://123/./make);
fullPath = binary.onDeviceSearchInPath();
assert(fullPath == FilePath::fromUrl("docker://123/usr/bin/make"))
\endcode
*/
FilePath FilePath::onDeviceSearchInPath() const
{
if (needsDevice()) {
QTC_ASSERT(s_deviceHooks.searchInPath, return {});
return s_deviceHooks.searchInPath(*this);
}
return Environment::systemEnvironment().searchInPath(path());
}
FilePath FilePath::pathAppended(const QString &path) const
{
FilePath fn = *this;