aboutsummaryrefslogtreecommitdiffstats
path: root/src/libs/utils/fileutils.cpp
diff options
context:
space:
mode:
authorhjk <[email protected]>2021-06-07 15:47:06 +0200
committerhjk <[email protected]>2021-06-10 05:05:58 +0000
commit18245dcf1083a19e592254fd5e1337fcde1abf4a (patch)
tree73073ec628fc19cb6c30875e2190ec21ada973ad /src/libs/utils/fileutils.cpp
parent16a8a0848416eba881c4e81fbca075e5f94db8e5 (diff)
Utils/ProjectExplorer: Add IDevice::searchInPath
Change-Id: Ibc7cc7bd6bf3a7776681f7cd2fff051525b19f60 Reviewed-by: David Schulz <[email protected]>
Diffstat (limited to 'src/libs/utils/fileutils.cpp')
-rw-r--r--src/libs/utils/fileutils.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/libs/utils/fileutils.cpp b/src/libs/utils/fileutils.cpp
index d0ab78eaaba..a08f7ba98d6 100644
--- a/src/libs/utils/fileutils.cpp
+++ b/src/libs/utils/fileutils.cpp
@@ -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;