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:
hjk
2023-12-22 09:39:13 +01:00
parent 60d1838220
commit c56bd22afd
2 changed files with 18 additions and 0 deletions

View File

@@ -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.