forked from qt-creator/qt-creator
Utils: add FilePath::(complete)suffix
The same as FilePath::(complete)baseName avoid some toFileInfo. Change-Id: Id1901ce2a4bef675215a9e020280df1c846df405 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -787,6 +787,34 @@ QString FilePath::completeBaseName() const
|
||||
return name.left(name.lastIndexOf('.'));
|
||||
}
|
||||
|
||||
/// \returns the suffix (extension) of the file.
|
||||
///
|
||||
/// The suffix consists of all characters in the file after
|
||||
/// (but not including) the last '.'.
|
||||
|
||||
QString FilePath::suffix() const
|
||||
{
|
||||
const QString &name = fileName();
|
||||
const int index = name.lastIndexOf('.');
|
||||
if (index >= 0)
|
||||
return name.mid(index + 1);
|
||||
return {};
|
||||
}
|
||||
|
||||
/// \returns the complete suffix (extension) of the file.
|
||||
///
|
||||
/// The complete suffix consists of all characters in the file after
|
||||
/// (but not including) the first '.'.
|
||||
|
||||
QString FilePath::completeSuffix() const
|
||||
{
|
||||
const QString &name = fileName();
|
||||
const int index = name.indexOf('.');
|
||||
if (index >= 0)
|
||||
return name.mid(index + 1);
|
||||
return {};
|
||||
}
|
||||
|
||||
void FilePath::setScheme(const QString &scheme)
|
||||
{
|
||||
QTC_CHECK(!scheme.contains('/'));
|
||||
|
||||
Reference in New Issue
Block a user