forked from qt-creator/qt-creator
Utils: Add prefixRemoved to FilePath
Helper to create a prefix-cut FilePath. Change-Id: I4f827fb9975a38d9be794ab27bc103c7fd9ffd00 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -1949,6 +1949,13 @@ std::optional<FilePath> FilePath::tailRemoved(const QString &str) const
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::optional<FilePath> FilePath::prefixRemoved(const QString &str) const
|
||||||
|
{
|
||||||
|
if (pathView().startsWith(str))
|
||||||
|
return withNewPath(pathView().mid(str.size()).toString());
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
QDateTime FilePath::lastModified() const
|
QDateTime FilePath::lastModified() const
|
||||||
{
|
{
|
||||||
return fileAccess()->lastModified(*this);
|
return fileAccess()->lastModified(*this);
|
||||||
|
@@ -140,6 +140,7 @@ public:
|
|||||||
[[nodiscard]] FilePath pathAppended(const QString &str) const;
|
[[nodiscard]] FilePath pathAppended(const QString &str) const;
|
||||||
[[nodiscard]] FilePath stringAppended(const QString &str) const;
|
[[nodiscard]] FilePath stringAppended(const QString &str) const;
|
||||||
[[nodiscard]] std::optional<FilePath> tailRemoved(const QString &str) const;
|
[[nodiscard]] std::optional<FilePath> tailRemoved(const QString &str) const;
|
||||||
|
[[nodiscard]] std::optional<FilePath> prefixRemoved(const QString &str) const;
|
||||||
bool startsWith(const QString &s) const;
|
bool startsWith(const QString &s) const;
|
||||||
bool endsWith(const QString &s) const;
|
bool endsWith(const QString &s) const;
|
||||||
bool contains(const QString &s) const;
|
bool contains(const QString &s) const;
|
||||||
|
Reference in New Issue
Block a user