mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-16 02:03:07 -07:00
Improve detection of file extension string
This commit is contained in:
parent
17fa615bd3
commit
15a249eb54
2 changed files with 13 additions and 9 deletions
|
@ -55,6 +55,7 @@
|
|||
#include <QDirIterator>
|
||||
#include <QFile>
|
||||
#include <QFileInfo>
|
||||
#include <QMimeDatabase>
|
||||
#include <QStorageInfo>
|
||||
#include <QRegularExpression>
|
||||
|
||||
|
@ -76,9 +77,14 @@ QString Utils::Fs::toUniformPath(const QString &path)
|
|||
*/
|
||||
QString Utils::Fs::fileExtension(const QString &filename)
|
||||
{
|
||||
const QString ext = QString(filename).remove(QB_EXT);
|
||||
const int pointIndex = ext.lastIndexOf('.');
|
||||
return (pointIndex >= 0) ? ext.mid(pointIndex + 1) : QString();
|
||||
const QString name = filename.endsWith(QB_EXT)
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
|
||||
? filename.chopped(QB_EXT.length())
|
||||
#else
|
||||
? filename.left(filename.length() - QB_EXT.length())
|
||||
#endif
|
||||
: filename;
|
||||
return QMimeDatabase().suffixForFileName(name);
|
||||
}
|
||||
|
||||
QString Utils::Fs::fileName(const QString &filePath)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue