diff options
author | hjk <[email protected]> | 2021-07-14 13:01:28 +0200 |
---|---|---|
committer | hjk <[email protected]> | 2021-07-16 11:13:14 +0000 |
commit | d06c670504e6a3fb6c39f07a424a5cfdb4661073 (patch) | |
tree | 50a6d99b8f65f92143f4dca58a0cf1fd06315d5f /src/libs/utils/fileutils.cpp | |
parent | 842770b6b57d1326b23a83e99451ad4a3cde5f74 (diff) |
Utils: Introduce a FilePath::withNewPath() convenience method
It's effectively the mirrored version of onDevice() with an
equally odd name which is a bit more straightforward to use
in some cases.
Change-Id: I0cfedeb58871a857c93144e2a0d734bad1bcd887
Reviewed-by: Christian Stenger <[email protected]>
Diffstat (limited to 'src/libs/utils/fileutils.cpp')
-rw-r--r-- | src/libs/utils/fileutils.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/libs/utils/fileutils.cpp b/src/libs/utils/fileutils.cpp index 22589c9ed34..6465b44495f 100644 --- a/src/libs/utils/fileutils.cpp +++ b/src/libs/utils/fileutils.cpp @@ -1385,6 +1385,26 @@ FilePath FilePath::onDevice(const FilePath &deviceTemplate) const } /*! + Returns a FilePath with local path \a newPath on the same device + as the current object. + + Example usage: + \code + devicePath = FilePath::fromString("docker://123/tmp"); + newPath = devicePath.withNewPath("/bin/ls"); + assert(realDir == FilePath::fromUrl("docker://123/bin/ls")) + \endcode +*/ +FilePath FilePath::withNewPath(const QString &newPath) const +{ + FilePath res; + res.m_data = newPath; + res.m_host = m_host; + res.m_scheme = m_scheme; + return res; +} + +/*! Searched a binary corresponding to this object in the PATH of the device implied by this object's scheme and host. |