diff options
author | David Schulz <[email protected]> | 2021-06-04 07:59:00 +0200 |
---|---|---|
committer | David Schulz <[email protected]> | 2021-06-04 07:07:07 +0000 |
commit | 5ec611b68e3e910b609ed8e72fd87cd45b86fb3a (patch) | |
tree | abebac1ec610a0b2f0d1ba6ebdc556f1e561ab5c /src/libs/utils/fileutils.cpp | |
parent | 5544fd35c4d695cfc12dc6b245a2b75290aea63e (diff) |
Utils: add FilePath::completeBaseName
Removing some FilePath::toFileInfo() calls again.
Change-Id: I6610beebf2c30754fde525b71f4c4a34ceb5e30b
Reviewed-by: hjk <[email protected]>
Diffstat (limited to 'src/libs/utils/fileutils.cpp')
-rw-r--r-- | src/libs/utils/fileutils.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/libs/utils/fileutils.cpp b/src/libs/utils/fileutils.cpp index cea4d1ec862..34ecb6d58a8 100644 --- a/src/libs/utils/fileutils.cpp +++ b/src/libs/utils/fileutils.cpp @@ -761,12 +761,28 @@ QString FilePath::fileNameWithPathComponents(int pathComponents) const return m_data; } +/// \returns the base name of the file without the path. +/// +/// The base name consists of all characters in the file up to +/// (but not including) the first '.' character. + QString FilePath::baseName() const { const QString &name = fileName(); return name.left(name.indexOf('.')); } +/// \returns the complete base name of the file without the path. +/// +/// The complete base name consists of all characters in the file up to +/// (but not including) the last '.' character + +QString FilePath::completeBaseName() const +{ + const QString &name = fileName(); + return name.left(name.lastIndexOf('.')); +} + void FilePath::setScheme(const QString &scheme) { QTC_CHECK(!scheme.contains('/')); |