summaryrefslogtreecommitdiff
path: root/src/lib/corelib/tools/fileinfo.cpp
diff options
context:
space:
mode:
authorJoerg Bornemann <joerg.bornemann@qt.io>2018-04-30 14:48:54 +0200
committerJoerg Bornemann <joerg.bornemann@qt.io>2018-05-02 12:15:30 +0000
commita72ffb709f7d0ec54523d53181294981ad7bf0ec (patch)
treed1f668bc823fb06ade4f9acf03294d279cbcdb35 /src/lib/corelib/tools/fileinfo.cpp
parent704b5fa7e8cbe4248be775a40f05c571ad27bec2 (diff)
downloadqbs-a72ffb709f7d0ec54523d53181294981ad7bf0ec.tar.gz
Add FileInfo.suffix and FileInfo.completeSuffix
[ChangeLog] Added FileInfo.suffix and FileInfo.completeSuffix. Change-Id: Ic74a2fcff2f3f1271fa60ac33b96a4c5a4d0e93d Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io> Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Diffstat (limited to 'src/lib/corelib/tools/fileinfo.cpp')
-rw-r--r--src/lib/corelib/tools/fileinfo.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/lib/corelib/tools/fileinfo.cpp b/src/lib/corelib/tools/fileinfo.cpp
index ebb0e5125..b8fa189ab 100644
--- a/src/lib/corelib/tools/fileinfo.cpp
+++ b/src/lib/corelib/tools/fileinfo.cpp
@@ -86,6 +86,24 @@ QString FileInfo::completeBaseName(const QString &fp)
return fn.mid(0, dot);
}
+QString FileInfo::suffix(const QString &fp)
+{
+ QString fn = fileName(fp);
+ int dot = fn.lastIndexOf(QLatin1Char('.'));
+ if (dot < 0)
+ return fn;
+ return fn.mid(dot + 1);
+}
+
+QString FileInfo::completeSuffix(const QString &fp)
+{
+ QString fn = fileName(fp);
+ int dot = fn.indexOf(QLatin1Char('.'));
+ if (dot < 0)
+ return fn;
+ return fn.mid(dot + 1);
+}
+
QString FileInfo::path(const QString &fp, HostOsInfo::HostOs hostOs)
{
if (fp.isEmpty())