| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/corelib/mimetypes/qmimedatabase.cpp |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | namespace { namespace Q_QGS_staticQMimeDatabase { typedef QMimeDatabasePrivate Type; QBasicAtomicInt guard = { QtGlobalStatic::Uninitialized }; __attribute__((visibility("hidden"))) inline Type *innerFunction() { struct HolderBase { ~HolderBase() noexcept { if (guard.load() == QtGlobalStatic::Initialized
executed 4 times by 4 tests: }guard.store(QtGlobalStatic::Destroyed);Executed by:
executed 4 times by 4 tests: }; static struct Holder : public HolderBase { Type value; Holder() noexcept(noexcept(Type ())) : value () { guard.store(QtGlobalStatic::Initialized); } } holder; returnend of blockExecuted by:
executed 351 times by 3 tests: &holder.value;return &holder.value;Executed by:
executed 351 times by 3 tests: } } } static QGlobalStatic<QMimeDatabasePrivate, Q_QGS_staticQMimeDatabase::innerFunction, Q_QGS_staticQMimeDatabase::guard> staticQMimeDatabase;return &holder.value;Executed by:
| 0-351 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | QMimeDatabasePrivate *QMimeDatabasePrivate::instance() | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | return executed 206 times by 2 tests: staticQMimeDatabase();return staticQMimeDatabase();Executed by:
executed 206 times by 2 tests: return staticQMimeDatabase();Executed by:
| 206 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | QMimeDatabasePrivate::QMimeDatabasePrivate() | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | : m_provider(0), m_defaultMimeType(QLatin1String("application/octet-stream")) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | } executed 4 times by 3 tests: end of blockExecuted by:
| 4 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | QMimeDatabasePrivate::~QMimeDatabasePrivate() | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | delete m_provider; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | m_provider = 0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | } executed 4 times by 4 tests: end of blockExecuted by:
| 4 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | QMimeProviderBase *QMimeDatabasePrivate::provider() | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | if (!m_provider
| 4-9124 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | QMimeProviderBase *binaryProvider = new QMimeBinaryProvider(this); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | if (binaryProvider->isValid()
| 2 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | m_provider = binaryProvider; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | } executed 2 times by 2 tests: else {end of blockExecuted by:
| 2 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | delete binaryProvider; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | m_provider = new QMimeXMLProvider(this); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | } executed 2 times by 2 tests: end of blockExecuted by:
| 2 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | return executed 9128 times by 3 tests: m_provider;return m_provider;Executed by:
executed 9128 times by 3 tests: return m_provider;Executed by:
| 9128 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | void QMimeDatabasePrivate::setProvider(QMimeProviderBase *theProvider) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | delete m_provider; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | m_provider = theProvider; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | QMimeType QMimeDatabasePrivate::mimeTypeForName(const QString &nameOrAlias) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | return executed 4303 times by 2 tests: provider()->mimeTypeForName(provider()->resolveAlias(nameOrAlias));return provider()->mimeTypeForName(provider()->resolveAlias(nameOrAlias));Executed by:
executed 4303 times by 2 tests: return provider()->mimeTypeForName(provider()->resolveAlias(nameOrAlias));Executed by:
| 4303 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | QStringList QMimeDatabasePrivate::mimeTypeForFileName(const QString &fileName, QString *foundSuffix) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | if (fileName.endsWith(QLatin1Char('/'))
| 4-192 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | return executed 4 times by 1 test: QStringList() << QLatin1String("inode/directory");return QStringList() << QLatin1String("inode/directory");Executed by:
executed 4 times by 1 test: return QStringList() << QLatin1String("inode/directory");Executed by:
| 4 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | const QStringList matchingMimeTypes = provider()->findByFileName(QFileInfo(fileName).fileName(), foundSuffix); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | return executed 192 times by 1 test: matchingMimeTypes;return matchingMimeTypes;Executed by:
executed 192 times by 1 test: return matchingMimeTypes;Executed by:
| 192 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | static inline bool isTextFile(const QByteArray &data) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | static const char bigEndianBOM[] = "\xFE\xFF"; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | static const char littleEndianBOM[] = "\xFF\xFE"; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | if (data.startsWith(bigEndianBOM)
| 0-18 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | return never executed: true;return true;never executed: return true; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | const char *p = data.constData(); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | const char *e = p + qMin(32, data.size()); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | for ( ; p < e
| 12-138 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | if ((
| 0-132 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | return executed 6 times by 1 test: false;return false;Executed by:
executed 6 times by 1 test: return false;Executed by:
| 6 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | } executed 132 times by 1 test: end of blockExecuted by:
| 132 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | return executed 12 times by 1 test: true;return true;Executed by:
executed 12 times by 1 test: return true;Executed by:
| 12 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | QMimeType QMimeDatabasePrivate::findByData(const QByteArray &data, int *accuracyPtr) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | if (data.isEmpty()
| 0-64 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | *accuracyPtr = 100; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | return never executed: mimeTypeForName(QLatin1String("application/x-zerosize"));return mimeTypeForName(QLatin1String("application/x-zerosize"));never executed: return mimeTypeForName(QLatin1String("application/x-zerosize")); | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | *accuracyPtr = 0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | QMimeType candidate = provider()->findByMagic(data, accuracyPtr); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | if (candidate.isValid()
| 18-46 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | return executed 46 times by 1 test: candidate;return candidate;Executed by:
executed 46 times by 1 test: return candidate;Executed by:
| 46 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | if (isTextFile(data)
| 6-12 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | *accuracyPtr = 5; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | return executed 12 times by 1 test: mimeTypeForName(QLatin1String("text/plain"));return mimeTypeForName(QLatin1String("text/plain"));Executed by:
executed 12 times by 1 test: return mimeTypeForName(QLatin1String("text/plain"));Executed by:
| 12 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | return executed 6 times by 1 test: mimeTypeForName(defaultMimeType());return mimeTypeForName(defaultMimeType());Executed by:
executed 6 times by 1 test: return mimeTypeForName(defaultMimeType());Executed by:
| 6 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | QMimeType QMimeDatabasePrivate::mimeTypeForFileNameAndData(const QString &fileName, QIODevice *device, int *accuracyPtr) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | *accuracyPtr = 0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | QStringList candidatesByName = mimeTypeForFileName(fileName); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | if (candidatesByName.count() == 1
| 26-32 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | *accuracyPtr = 100; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | const QMimeType mime = mimeTypeForName(candidatesByName.at(0)); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | if (mime.isValid()
| 0-26 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | return executed 26 times by 1 test: mime;return mime;Executed by:
executed 26 times by 1 test: return mime;Executed by:
| 26 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | candidatesByName.clear(); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | if (device->isOpen()
| 6-26 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | const QByteArray data = device->peek(16384); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | int magicAccuracy = 0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | QMimeType candidateByData(findByData(data, &magicAccuracy)); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | if (candidateByData.isValid()
| 0-26 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | const QString sniffedMime = candidateByData.name(); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(candidatesByName)>::type> _container_((candidatesByName)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (const QString &m = *_container_.i; _container_.control; _container_.control = 0) { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | if (inherits(m, sniffedMime)
| 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | *accuracyPtr = 100; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | return never executed: mimeTypeForName(m);return mimeTypeForName(m);never executed: return mimeTypeForName(m); | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | *accuracyPtr = magicAccuracy; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | return executed 26 times by 1 test: candidateByData;return candidateByData;Executed by:
executed 26 times by 1 test: return candidateByData;Executed by:
| 26 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | if (candidatesByName.count() > 1
| 0-6 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | *accuracyPtr = 20; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | candidatesByName.sort(); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | const QMimeType mime = mimeTypeForName(candidatesByName.at(0)); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | if (mime.isValid()
| 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | return never executed: mime;return mime;never executed: return mime; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | return executed 6 times by 1 test: mimeTypeForName(defaultMimeType());return mimeTypeForName(defaultMimeType());Executed by:
executed 6 times by 1 test: return mimeTypeForName(defaultMimeType());Executed by:
| 6 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | QList<QMimeType> QMimeDatabasePrivate::allMimeTypes() | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | return executed 10 times by 1 test: provider()->allMimeTypes();return provider()->allMimeTypes();Executed by:
executed 10 times by 1 test: return provider()->allMimeTypes();Executed by:
| 10 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | bool QMimeDatabasePrivate::inherits(const QString &mime, const QString &parent) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | const QString resolvedParent = provider()->resolveAlias(parent); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | QStack<QString> toCheck; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | toCheck.push(mime); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | while (!toCheck.isEmpty()
| 4-116 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | const QString current = toCheck.pop(); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | if (current == resolvedParent
| 48-68 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | return executed 48 times by 1 test: true;return true;Executed by:
executed 48 times by 1 test: return true;Executed by:
| 48 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(provider()->parents(current))>::type> _container_((provider()->parents(current))); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (const QString &par = *_container_.i; _container_.control; _container_.control = 0) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | toCheck.push(par); executed 68 times by 1 test: toCheck.push(par);Executed by:
| 68 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | } executed 68 times by 1 test: end of blockExecuted by:
| 68 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | return executed 4 times by 1 test: false;return false;Executed by:
executed 4 times by 1 test: return false;Executed by:
| 4 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | QMimeDatabase::QMimeDatabase() : | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | d(staticQMimeDatabase()) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | } executed 145 times by 2 tests: end of blockExecuted by:
| 145 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | QMimeDatabase::~QMimeDatabase() | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | d = 0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | } executed 145 times by 2 tests: end of blockExecuted by:
| 145 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | QMimeType QMimeDatabase::mimeTypeForName(const QString &nameOrAlias) const | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | QMutexLocker locker(&d->mutex); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | return executed 4121 times by 2 tests: d->mimeTypeForName(nameOrAlias);return d->mimeTypeForName(nameOrAlias);Executed by:
executed 4121 times by 2 tests: return d->mimeTypeForName(nameOrAlias);Executed by:
| 4121 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | QMimeType QMimeDatabase::mimeTypeForFile(const QFileInfo &fileInfo, MatchMode mode) const | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | QMutexLocker locker(&d->mutex); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | if (fileInfo.isDir()
| 4-36 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | return executed 4 times by 1 test: d->mimeTypeForName(QLatin1String("inode/directory"));return d->mimeTypeForName(QLatin1String("inode/directory"));Executed by:
executed 4 times by 1 test: return d->mimeTypeForName(QLatin1String("inode/directory"));Executed by:
| 4 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | QFile file(fileInfo.absoluteFilePath()); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | const QByteArray nativeFilePath = QFile::encodeName(file.fileName()); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | struct stat64 statBuffer; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | if (::
| 12-24 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | if (((((
| 0-24 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | return never executed: d->mimeTypeForName(QLatin1String("inode/chardevice"));return d->mimeTypeForName(QLatin1String("inode/chardevice"));never executed: return d->mimeTypeForName(QLatin1String("inode/chardevice")); | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | if (((((
| 0-24 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | return never executed: d->mimeTypeForName(QLatin1String("inode/blockdevice"));return d->mimeTypeForName(QLatin1String("inode/blockdevice"));never executed: return d->mimeTypeForName(QLatin1String("inode/blockdevice")); | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | if (((((
| 4-20 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | return executed 4 times by 1 test: d->mimeTypeForName(QLatin1String("inode/fifo"));return d->mimeTypeForName(QLatin1String("inode/fifo"));Executed by:
executed 4 times by 1 test: return d->mimeTypeForName(QLatin1String("inode/fifo"));Executed by:
| 4 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | if (((((
| 0-20 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | return never executed: d->mimeTypeForName(QLatin1String("inode/socket"));return d->mimeTypeForName(QLatin1String("inode/socket"));never executed: return d->mimeTypeForName(QLatin1String("inode/socket")); | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | } executed 20 times by 1 test: end of blockExecuted by:
| 20 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | int priority = 0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | switch (mode) { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | case executed 28 times by 1 test: MatchDefault:case MatchDefault:Executed by:
executed 28 times by 1 test: case MatchDefault:Executed by:
| 28 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | file.open(QIODevice::ReadOnly); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | return executed 28 times by 1 test: d->mimeTypeForFileNameAndData(fileInfo.absoluteFilePath(), &file, &priority);return d->mimeTypeForFileNameAndData(fileInfo.absoluteFilePath(), &file, &priority);Executed by:
executed 28 times by 1 test: return d->mimeTypeForFileNameAndData(fileInfo.absoluteFilePath(), &file, &priority);Executed by:
| 28 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | case never executed: MatchExtension:case MatchExtension:never executed: case MatchExtension: | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | locker.unlock(); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | return never executed: mimeTypeForFile(fileInfo.absoluteFilePath(), mode);return mimeTypeForFile(fileInfo.absoluteFilePath(), mode);never executed: return mimeTypeForFile(fileInfo.absoluteFilePath(), mode); | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | case executed 4 times by 1 test: MatchContent:case MatchContent:Executed by:
executed 4 times by 1 test: case MatchContent:Executed by:
| 4 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | if (file.open(QIODevice::ReadOnly)
| 0-4 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | locker.unlock(); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | return executed 4 times by 1 test: mimeTypeForData(&file);return mimeTypeForData(&file);Executed by:
executed 4 times by 1 test: return mimeTypeForData(&file);Executed by:
| 4 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | } else { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | return never executed: d->mimeTypeForName(d->defaultMimeType());return d->mimeTypeForName(d->defaultMimeType());never executed: return d->mimeTypeForName(d->defaultMimeType()); | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | default never executed: :default:never executed: default: | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | ((!(false)) ? qt_assert("false",__FILE__,388) : qt_noop()); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | return never executed: d->mimeTypeForName(d->defaultMimeType());return d->mimeTypeForName(d->defaultMimeType());never executed: return d->mimeTypeForName(d->defaultMimeType()); | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | QMimeType QMimeDatabase::mimeTypeForFile(const QString &fileName, MatchMode mode) const | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | if (mode == MatchExtension
| 40-68 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | QMutexLocker locker(&d->mutex); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | QStringList matches = d->mimeTypeForFileName(fileName); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | const int matchCount = matches.count(); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | if (matchCount == 0
| 16-52 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | return executed 16 times by 1 test: d->mimeTypeForName(d->defaultMimeType());return d->mimeTypeForName(d->defaultMimeType());Executed by:
executed 16 times by 1 test: return d->mimeTypeForName(d->defaultMimeType());Executed by:
| 16 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | } else if (matchCount == 1
| 0-52 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | return executed 52 times by 1 test: d->mimeTypeForName(matches.first());return d->mimeTypeForName(matches.first());Executed by:
executed 52 times by 1 test: return d->mimeTypeForName(matches.first());Executed by:
| 52 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | } else { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | matches.sort(); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | return never executed: d->mimeTypeForName(matches.first());return d->mimeTypeForName(matches.first());never executed: return d->mimeTypeForName(matches.first()); | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | } else { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | QFileInfo fileInfo(fileName); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | return executed 40 times by 1 test: mimeTypeForFile(fileInfo, mode);return mimeTypeForFile(fileInfo, mode);Executed by:
executed 40 times by 1 test: return mimeTypeForFile(fileInfo, mode);Executed by:
| 40 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | QList<QMimeType> QMimeDatabase::mimeTypesForFileName(const QString &fileName) const | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | QMutexLocker locker(&d->mutex); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | QStringList matches = d->mimeTypeForFileName(fileName); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | QList<QMimeType> mimes; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | matches.sort(); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | mimes.reserve(matches.count()); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(matches)>::type> _container_((matches)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (const QString &mime = *_container_.i; _container_.control; _container_.control = 0) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | mimes.append(d->mimeTypeForName(mime)); executed 52 times by 1 test: mimes.append(d->mimeTypeForName(mime));Executed by:
| 52 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | return executed 54 times by 1 test: mimes;return mimes;Executed by:
executed 54 times by 1 test: return mimes;Executed by:
| 54 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | QString QMimeDatabase::suffixForFileName(const QString &fileName) const | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | QMutexLocker locker(&d->mutex); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | QString foundSuffix; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | d->mimeTypeForFileName(fileName, &foundSuffix); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | return executed 16 times by 1 test: foundSuffix;return foundSuffix;Executed by:
executed 16 times by 1 test: return foundSuffix;Executed by:
| 16 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | QMimeType QMimeDatabase::mimeTypeForData(const QByteArray &data) const | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | QMutexLocker locker(&d->mutex); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | int accuracy = 0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | return executed 10 times by 1 test: d->findByData(data, &accuracy);return d->findByData(data, &accuracy);Executed by:
executed 10 times by 1 test: return d->findByData(data, &accuracy);Executed by:
| 10 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | QMimeType QMimeDatabase::mimeTypeForData(QIODevice *device) const | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | QMutexLocker locker(&d->mutex); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | int accuracy = 0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | const bool openedByUs = !device->isOpen()
| 4-18 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | if (device->isOpen()
| 4-28 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | const QByteArray data = device->peek(16384); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | const QMimeType result = d->findByData(data, &accuracy); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | if (openedByUs
| 14 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | device->close(); executed 14 times by 1 test: device->close();Executed by:
| 14 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | return executed 28 times by 1 test: result;return result;Executed by:
executed 28 times by 1 test: return result;Executed by:
| 28 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | return executed 4 times by 1 test: d->mimeTypeForName(d->defaultMimeType());return d->mimeTypeForName(d->defaultMimeType());Executed by:
executed 4 times by 1 test: return d->mimeTypeForName(d->defaultMimeType());Executed by:
| 4 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | QMimeType QMimeDatabase::mimeTypeForUrl(const QUrl &url) const | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | if (url.isLocalFile()
| 0-10 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | return never executed: mimeTypeForFile(url.toLocalFile());return mimeTypeForFile(url.toLocalFile());never executed: return mimeTypeForFile(url.toLocalFile()); | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | const QString scheme = url.scheme(); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | if (scheme.startsWith(QLatin1String("http"))
| 2-8 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | return executed 6 times by 1 test: mimeTypeForName(d->defaultMimeType());return mimeTypeForName(d->defaultMimeType());Executed by:
executed 6 times by 1 test: return mimeTypeForName(d->defaultMimeType());Executed by:
| 6 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | return executed 4 times by 1 test: mimeTypeForFile(url.path());return mimeTypeForFile(url.path());Executed by:
executed 4 times by 1 test: return mimeTypeForFile(url.path());Executed by:
| 4 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | QMimeType QMimeDatabase::mimeTypeForFileNameAndData(const QString &fileName, QIODevice *device) const | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | int accuracy = 0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | const bool openedByUs = !device->isOpen()
| 0-10 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | const QMimeType result = d->mimeTypeForFileNameAndData(fileName, device, &accuracy); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | if (openedByUs
| 10 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | device->close(); executed 10 times by 1 test: device->close();Executed by:
| 10 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | return executed 20 times by 1 test: result;return result;Executed by:
executed 20 times by 1 test: return result;Executed by:
| 20 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | QMimeType QMimeDatabase::mimeTypeForFileNameAndData(const QString &fileName, const QByteArray &data) const | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | QBuffer buffer(const_cast<QByteArray *>(&data)); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | buffer.open(QIODevice::ReadOnly); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | int accuracy = 0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | return executed 10 times by 1 test: d->mimeTypeForFileNameAndData(fileName, &buffer, &accuracy);return d->mimeTypeForFileNameAndData(fileName, &buffer, &accuracy);Executed by:
executed 10 times by 1 test: return d->mimeTypeForFileNameAndData(fileName, &buffer, &accuracy);Executed by:
| 10 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | QList<QMimeType> QMimeDatabase::allMimeTypes() const | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | QMutexLocker locker(&d->mutex); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | return executed 10 times by 1 test: d->allMimeTypes();return d->allMimeTypes();Executed by:
executed 10 times by 1 test: return d->allMimeTypes();Executed by:
| 10 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| Switch to Source code | Preprocessed file |