diff options
author | hjk <[email protected]> | 2021-07-06 15:58:33 +0200 |
---|---|---|
committer | hjk <[email protected]> | 2021-07-07 07:22:30 +0000 |
commit | eb70e20453876ea82b4ec6bed1805eb62283b8dd (patch) | |
tree | bcc839a1324fc1d0f873e0b12caf4db071ebe13c /src/libs/utils | |
parent | 4eec360563f0433705608b6d4a3b41704575fbd8 (diff) |
Utils: Add a FilePath::environment
A hook into the system environment of the FilePath's device.
Change-Id: I274032f9e716f3cd8b2e4af2eca010b9805a4568
Reviewed-by: Christian Stenger <[email protected]>
Diffstat (limited to 'src/libs/utils')
-rw-r--r-- | src/libs/utils/fileutils.cpp | 10 | ||||
-rw-r--r-- | src/libs/utils/fileutils.h | 7 |
2 files changed, 16 insertions, 1 deletions
diff --git a/src/libs/utils/fileutils.cpp b/src/libs/utils/fileutils.cpp index e44faa5e087..a4704bf696d 100644 --- a/src/libs/utils/fileutils.cpp +++ b/src/libs/utils/fileutils.cpp @@ -1387,6 +1387,16 @@ FilePath FilePath::onDeviceSearchInPath() const return Environment::systemEnvironment().searchInPath(path()); } +Environment FilePath::deviceEnvironment() const +{ + if (needsDevice()) { + QTC_ASSERT(s_deviceHooks.environment, return {}); + return s_deviceHooks.environment(*this); + } + return Environment::systemEnvironment(); +} + + FilePath FilePath::pathAppended(const QString &path) const { FilePath fn = *this; diff --git a/src/libs/utils/fileutils.h b/src/libs/utils/fileutils.h index 0d8d48d0285..07792a7faca 100644 --- a/src/libs/utils/fileutils.h +++ b/src/libs/utils/fileutils.h @@ -40,7 +40,10 @@ #include <functional> #include <memory> -namespace Utils { class FilePath; } +namespace Utils { +class Environment; +class FilePath; +} // Utils QT_BEGIN_NAMESPACE class QDataStream; @@ -91,6 +94,7 @@ public: std::function<QDateTime(const FilePath &)> lastModified; std::function<QFile::Permissions(const FilePath &)> permissions; std::function<OsType(const FilePath &)> osType; + std::function<Environment(const FilePath &)> environment; }; class QTCREATOR_UTILS_EXPORT FilePath @@ -213,6 +217,7 @@ public: static void setDeviceFileHooks(const DeviceFileHooks &hooks); FilePath onDeviceSearchInPath() const; + Environment deviceEnvironment() const; private: friend class ::tst_fileutils; |