forked from qt-creator/qt-creator
Utils: Introduce a FilePath::chopped() convenience function
Change-Id: I5fd813af83d58e62e026b3764d3d4378429c2162 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io> Reviewed-by: Dominik Holland <dominik.holland@qt.io>
This commit is contained in:
@@ -1575,6 +1575,23 @@ FilePath FilePath::withNewMappedPath(const FilePath &newPath) const
|
||||
return res;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns a path with the \a n characters of the local path removed.
|
||||
Example usage:
|
||||
\code
|
||||
backup = FilePath("/tmp/example.txt.backup");
|
||||
real = backup.chopped(7);
|
||||
assert(real == FilePath("/tmp/example.txt"))
|
||||
\endcode
|
||||
*/
|
||||
|
||||
FilePath FilePath::chopped(int n) const
|
||||
{
|
||||
FilePath res;
|
||||
res.setParts(scheme(), host(), path().chopped(n));
|
||||
return res;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns a FilePath with local path \a newPath on the same device
|
||||
as the current object.
|
||||
|
||||
Reference in New Issue
Block a user