forked from qt-creator/qt-creator
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 <christian.stenger@qt.io>
This commit is contained in:
@@ -1384,6 +1384,26 @@ FilePath FilePath::onDevice(const FilePath &deviceTemplate) const
|
||||
return res;
|
||||
}
|
||||
|
||||
/*!
|
||||
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.
|
||||
|
||||
Reference in New Issue
Block a user