diff options
author | Joerg Bornemann <joerg.bornemann@qt.io> | 2018-04-30 14:48:54 +0200 |
---|---|---|
committer | Joerg Bornemann <joerg.bornemann@qt.io> | 2018-05-02 12:15:30 +0000 |
commit | a72ffb709f7d0ec54523d53181294981ad7bf0ec (patch) | |
tree | d1f668bc823fb06ade4f9acf03294d279cbcdb35 /src/lib/corelib/tools/fileinfo.cpp | |
parent | 704b5fa7e8cbe4248be775a40f05c571ad27bec2 (diff) | |
download | qbs-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.cpp | 18 |
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()) |