qmimeprovider.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/corelib/mimetypes/qmimeprovider.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2015 The Qt Company Ltd.-
4** Copyright (C) 2015 Klaralvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author David Faure <david.faure@kdab.com>-
5** Contact: http://www.qt.io/licensing/-
6**-
7** This file is part of the QtCore module of the Qt Toolkit.-
8**-
9** $QT_BEGIN_LICENSE:LGPL21$-
10** Commercial License Usage-
11** Licensees holding valid commercial Qt licenses may use this file in-
12** accordance with the commercial license agreement provided with the-
13** Software or, alternatively, in accordance with the terms contained in-
14** a written agreement between you and The Qt Company. For licensing terms-
15** and conditions see http://www.qt.io/terms-conditions. For further-
16** information use the contact form at http://www.qt.io/contact-us.-
17**-
18** GNU Lesser General Public License Usage-
19** Alternatively, this file may be used under the terms of the GNU Lesser-
20** General Public License version 2.1 or version 3 as published by the Free-
21** Software Foundation and appearing in the file LICENSE.LGPLv21 and-
22** LICENSE.LGPLv3 included in the packaging of this file. Please review the-
23** following information to ensure the GNU Lesser General Public License-
24** requirements will be met: https://www.gnu.org/licenses/lgpl.html and-
25** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.-
26**-
27** As a special exception, The Qt Company gives you certain additional-
28** rights. These rights are described in The Qt Company LGPL Exception-
29** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.-
30**-
31** $QT_END_LICENSE$-
32**-
33****************************************************************************/-
34-
35#include "qmimeprovider_p.h"-
36-
37#ifndef QT_NO_MIMETYPE-
38-
39#include "qmimetypeparser_p.h"-
40#include <qstandardpaths.h>-
41#include "qmimemagicrulematcher_p.h"-
42-
43#include <QXmlStreamReader>-
44#include <QDir>-
45#include <QFile>-
46#include <QByteArrayMatcher>-
47#include <QDebug>-
48#include <QDateTime>-
49#include <QtEndian>-
50-
51static void initResources()-
52{-
53 Q_INIT_RESOURCE(mimetypes);-
54}
executed 2 times by 2 tests: end of block
Executed by:
  • tst_QMimeDatabase
  • tst_qmimetype
2
55-
56QT_BEGIN_NAMESPACE-
57-
58static QString fallbackParent(const QString &mimeTypeName)-
59{-
60 const QString myGroup = mimeTypeName.left(mimeTypeName.indexOf(QLatin1Char('/')));-
61 // All text/* types are subclasses of text/plain.-
62 if (myGroup == QLatin1String("text") && mimeTypeName != QLatin1String("text/plain"))
myGroup == QLa...String("text")Description
TRUEevaluated 28 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 40 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
mimeTypeName !...("text/plain")Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 20 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
8-40
63 return QLatin1String("text/plain");
executed 8 times by 1 test: return QLatin1String("text/plain");
Executed by:
  • tst_QMimeDatabase
8
64 // All real-file mimetypes implicitly derive from application/octet-stream-
65 if (myGroup != QLatin1String("inode") &&
myGroup != QLa...tring("inode")Description
TRUEevaluated 52 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 8 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
8-52
66 // ignore non-file extensions-
67 myGroup != QLatin1String("all") && myGroup != QLatin1String("fonts") && myGroup != QLatin1String("print") && myGroup != QLatin1String("uri")
myGroup != QLa...1String("all")Description
TRUEevaluated 52 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEnever evaluated
myGroup != QLa...tring("fonts")Description
TRUEevaluated 52 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEnever evaluated
myGroup != QLa...tring("print")Description
TRUEevaluated 52 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEnever evaluated
myGroup != QLa...1String("uri")Description
TRUEevaluated 52 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEnever evaluated
0-52
68 && mimeTypeName != QLatin1String("application/octet-stream")) {
mimeTypeName !...octet-stream")Description
TRUEevaluated 36 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 16 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
16-36
69 return QLatin1String("application/octet-stream");
executed 36 times by 1 test: return QLatin1String("application/octet-stream");
Executed by:
  • tst_QMimeDatabase
36
70 }-
71 return QString();
executed 24 times by 1 test: return QString();
Executed by:
  • tst_QMimeDatabase
24
72}-
73-
74QMimeProviderBase::QMimeProviderBase(QMimeDatabasePrivate *db)-
75 : m_db(db)-
76{-
77}
executed 6 times by 3 tests: end of block
Executed by:
  • tst_QDebug
  • tst_QMimeDatabase
  • tst_qmimetype
6
78-
79Q_CORE_EXPORT int qmime_secondsBetweenChecks = 5; // exported for the unit test-
80-
81bool QMimeProviderBase::shouldCheck()-
82{-
83 if (m_lastCheck.isValid() && m_lastCheck.elapsed() < qmime_secondsBetweenChecks * 1000)
m_lastCheck.isValid()Description
TRUEevaluated 9085 times by 2 tests
Evaluated by:
  • tst_QDebug
  • tst_QMimeDatabase
FALSEevaluated 4 times by 3 tests
Evaluated by:
  • tst_QDebug
  • tst_QMimeDatabase
  • tst_qmimetype
m_lastCheck.el...nChecks * 1000Description
TRUEevaluated 8977 times by 2 tests
Evaluated by:
  • tst_QDebug
  • tst_QMimeDatabase
FALSEevaluated 108 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
4-9085
84 return false;
executed 8977 times by 2 tests: return false;
Executed by:
  • tst_QDebug
  • tst_QMimeDatabase
8977
85 m_lastCheck.start();-
86 return true;
executed 112 times by 3 tests: return true;
Executed by:
  • tst_QDebug
  • tst_QMimeDatabase
  • tst_qmimetype
112
87}-
88-
89QMimeBinaryProvider::QMimeBinaryProvider(QMimeDatabasePrivate *db)-
90 : QMimeProviderBase(db), m_mimetypeListLoaded(false)-
91{-
92}
executed 4 times by 3 tests: end of block
Executed by:
  • tst_QDebug
  • tst_QMimeDatabase
  • tst_qmimetype
4
93-
94#if defined(Q_OS_UNIX) && !defined(Q_OS_INTEGRITY)-
95#define QT_USE_MMAP-
96#endif-
97-
98struct QMimeBinaryProvider::CacheFile-
99{-
100 CacheFile(const QString &fileName);-
101 ~CacheFile();-
102-
103 bool isValid() const { return m_valid; }
executed 3 times by 2 tests: return m_valid;
Executed by:
  • tst_QDebug
  • tst_QMimeDatabase
3
104 inline quint16 getUint16(int offset) const-
105 {-
106 return qFromBigEndian(*reinterpret_cast<quint16 *>(data + offset));
executed 12 times by 2 tests: return qFromBigEndian(*reinterpret_cast<quint16 *>(data + offset));
Executed by:
  • tst_QDebug
  • tst_QMimeDatabase
12
107 }-
108 inline quint32 getUint32(int offset) const-
109 {-
110 return qFromBigEndian(*reinterpret_cast<quint32 *>(data + offset));
executed 92955 times by 2 tests: return qFromBigEndian(*reinterpret_cast<quint32 *>(data + offset));
Executed by:
  • tst_QDebug
  • tst_QMimeDatabase
92955
111 }-
112 inline const char *getCharStar(int offset) const-
113 {-
114 return reinterpret_cast<const char *>(data + offset);
executed 31519 times by 2 tests: return reinterpret_cast<const char *>(data + offset);
Executed by:
  • tst_QDebug
  • tst_QMimeDatabase
31519
115 }-
116 bool load();-
117 bool reload();-
118-
119 QFile file;-
120 uchar *data;-
121 QDateTime m_mtime;-
122 bool m_valid;-
123};-
124-
125QMimeBinaryProvider::CacheFile::CacheFile(const QString &fileName)-
126 : file(fileName), m_valid(false)-
127{-
128 load();-
129}
executed 3 times by 2 tests: end of block
Executed by:
  • tst_QDebug
  • tst_QMimeDatabase
3
130-
131QMimeBinaryProvider::CacheFile::~CacheFile()-
132{-
133}-
134-
135bool QMimeBinaryProvider::CacheFile::load()-
136{-
137 if (!file.open(QIODevice::ReadOnly))
!file.open(QIO...ice::ReadOnly)Description
TRUEnever evaluated
FALSEevaluated 6 times by 2 tests
Evaluated by:
  • tst_QDebug
  • tst_QMimeDatabase
0-6
138 return false;
never executed: return false;
0
139 data = file.map(0, file.size());-
140 if (data) {
dataDescription
TRUEevaluated 6 times by 2 tests
Evaluated by:
  • tst_QDebug
  • tst_QMimeDatabase
FALSEnever evaluated
0-6
141 const int major = getUint16(0);-
142 const int minor = getUint16(2);-
143 m_valid = (major == 1 && minor >= 1 && minor <= 2);
major == 1Description
TRUEevaluated 6 times by 2 tests
Evaluated by:
  • tst_QDebug
  • tst_QMimeDatabase
FALSEnever evaluated
minor >= 1Description
TRUEevaluated 6 times by 2 tests
Evaluated by:
  • tst_QDebug
  • tst_QMimeDatabase
FALSEnever evaluated
minor <= 2Description
TRUEevaluated 6 times by 2 tests
Evaluated by:
  • tst_QDebug
  • tst_QMimeDatabase
FALSEnever evaluated
0-6
144 }
executed 6 times by 2 tests: end of block
Executed by:
  • tst_QDebug
  • tst_QMimeDatabase
6
145 m_mtime = QFileInfo(file).lastModified();-
146 return m_valid;
executed 6 times by 2 tests: return m_valid;
Executed by:
  • tst_QDebug
  • tst_QMimeDatabase
6
147}-
148-
149bool QMimeBinaryProvider::CacheFile::reload()-
150{-
151 //qDebug() << "reload!" << file->fileName();-
152 m_valid = false;-
153 if (file.isOpen()) {
file.isOpen()Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEnever evaluated
0-3
154 file.close();-
155 }
executed 3 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
3
156 data = 0;-
157 return load();
executed 3 times by 1 test: return load();
Executed by:
  • tst_QMimeDatabase
3
158}-
159-
160QMimeBinaryProvider::CacheFile *QMimeBinaryProvider::CacheFileList::findCacheFile(const QString &fileName) const-
161{-
162 for (const_iterator it = begin(); it != end(); ++it) {
it != end()Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 3 times by 2 tests
Evaluated by:
  • tst_QDebug
  • tst_QMimeDatabase
3
163 if ((*it)->file.fileName() == fileName)
(*it)->file.fi...() == fileNameDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QMimeDatabase
1-2
164 return *it;
executed 2 times by 1 test: return *it;
Executed by:
  • tst_QMimeDatabase
2
165 }
executed 1 time by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
1
166 return 0;
executed 3 times by 2 tests: return 0;
Executed by:
  • tst_QDebug
  • tst_QMimeDatabase
3
167}-
168-
169QMimeBinaryProvider::~QMimeBinaryProvider()-
170{-
171 qDeleteAll(m_cacheFiles);-
172}
executed 4 times by 4 tests: end of block
Executed by:
  • tst_QMimeDatabase
  • tst_qdebug - unknown status
  • tst_qmimedatabase-cache - unknown status
  • tst_qmimetype
4
173-
174// Position of the "list offsets" values, at the beginning of the mime.cache file-
175enum {-
176 PosAliasListOffset = 4,-
177 PosParentListOffset = 8,-
178 PosLiteralListOffset = 12,-
179 PosReverseSuffixTreeOffset = 16,-
180 PosGlobListOffset = 20,-
181 PosMagicListOffset = 24,-
182 // PosNamespaceListOffset = 28,-
183 PosIconsListOffset = 32,-
184 PosGenericIconsListOffset = 36-
185};-
186-
187bool QMimeBinaryProvider::isValid()-
188{-
189#if defined(QT_USE_MMAP)-
190 if (!qEnvironmentVariableIsEmpty("QT_NO_MIME_CACHE"))
!qEnvironmentV...O_MIME_CACHE")Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 3 times by 3 tests
Evaluated by:
  • tst_QDebug
  • tst_QMimeDatabase
  • tst_qmimetype
1-3
191 return false;
executed 1 time by 1 test: return false;
Executed by:
  • tst_QMimeDatabase
1
192-
193 Q_ASSERT(m_cacheFiles.isEmpty()); // this method is only ever called once-
194 checkCache();-
195-
196 if (m_cacheFiles.count() > 1)
m_cacheFiles.count() > 1Description
TRUEnever evaluated
FALSEevaluated 3 times by 3 tests
Evaluated by:
  • tst_QDebug
  • tst_QMimeDatabase
  • tst_qmimetype
0-3
197 return true;
never executed: return true;
0
198 if (m_cacheFiles.isEmpty())
m_cacheFiles.isEmpty()Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_qmimetype
FALSEevaluated 2 times by 2 tests
Evaluated by:
  • tst_QDebug
  • tst_QMimeDatabase
1-2
199 return false;
executed 1 time by 1 test: return false;
Executed by:
  • tst_qmimetype
1
200-
201 // We found exactly one file; is it the user-modified mimes, or a system file?-
202 const QString foundFile = m_cacheFiles.first()->file.fileName();-
203 const QString localCacheFile = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QLatin1String("/mime/mime.cache");-
204-
205 return foundFile != localCacheFile;
executed 2 times by 2 tests: return foundFile != localCacheFile;
Executed by:
  • tst_QDebug
  • tst_QMimeDatabase
2
206#else-
207 return false;-
208#endif-
209}-
210-
211bool QMimeBinaryProvider::CacheFileList::checkCacheChanged()-
212{-
213 bool somethingChanged = false;-
214 QMutableListIterator<CacheFile *> it(*this);-
215 while (it.hasNext()) {
it.hasNext()Description
TRUEevaluated 78 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 56 times by 3 tests
Evaluated by:
  • tst_QDebug
  • tst_QMimeDatabase
  • tst_qmimetype
56-78
216 CacheFile *cacheFile = it.next();-
217 QFileInfo fileInfo(cacheFile->file);-
218 if (!fileInfo.exists()) { // This can't happen by just running update-mime-database. But the user could use rm -rf :-)
!fileInfo.exists()Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 77 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
1-77
219 delete cacheFile;-
220 it.remove();-
221 somethingChanged = true;-
222 } else if (fileInfo.lastModified() > cacheFile->m_mtime) {
executed 1 time by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
fileInfo.lastM...eFile->m_mtimeDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 74 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
1-74
223 if (!cacheFile->reload()) {
!cacheFile->reload()Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
0-3
224 delete cacheFile;-
225 it.remove();-
226 }
never executed: end of block
0
227 somethingChanged = true;-
228 }
executed 3 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
3
229 }
executed 78 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
78
230 return somethingChanged;
executed 56 times by 3 tests: return somethingChanged;
Executed by:
  • tst_QDebug
  • tst_QMimeDatabase
  • tst_qmimetype
56
231}-
232-
233void QMimeBinaryProvider::checkCache()-
234{-
235 if (!shouldCheck())
!shouldCheck()Description
TRUEevaluated 4477 times by 2 tests
Evaluated by:
  • tst_QDebug
  • tst_QMimeDatabase
FALSEevaluated 56 times by 3 tests
Evaluated by:
  • tst_QDebug
  • tst_QMimeDatabase
  • tst_qmimetype
56-4477
236 return;
executed 4477 times by 2 tests: return;
Executed by:
  • tst_QDebug
  • tst_QMimeDatabase
4477
237-
238 // First iterate over existing known cache files and check for uptodate-
239 if (m_cacheFiles.checkCacheChanged())
m_cacheFiles.c...CacheChanged()Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 52 times by 3 tests
Evaluated by:
  • tst_QDebug
  • tst_QMimeDatabase
  • tst_qmimetype
4-52
240 m_mimetypeListLoaded = false;
executed 4 times by 1 test: m_mimetypeListLoaded = false;
Executed by:
  • tst_QMimeDatabase
4
241-
242 // Then check if new cache files appeared-
243 const QStringList cacheFileNames = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QLatin1String("mime/mime.cache"));-
244 if (cacheFileNames != m_cacheFileNames) {
cacheFileNames...cacheFileNamesDescription
TRUEevaluated 4 times by 2 tests
Evaluated by:
  • tst_QDebug
  • tst_QMimeDatabase
FALSEevaluated 52 times by 2 tests
Evaluated by:
  • tst_QMimeDatabase
  • tst_qmimetype
4-52
245 foreach (const QString &cacheFileName, cacheFileNames) {-
246 CacheFile *cacheFile = m_cacheFiles.findCacheFile(cacheFileName);-
247 if (!cacheFile) {
!cacheFileDescription
TRUEevaluated 3 times by 2 tests
Evaluated by:
  • tst_QDebug
  • tst_QMimeDatabase
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
2-3
248 //qDebug() << "new file:" << cacheFileName;-
249 cacheFile = new CacheFile(cacheFileName);-
250 if (cacheFile->isValid()) // verify version
cacheFile->isValid()Description
TRUEevaluated 3 times by 2 tests
Evaluated by:
  • tst_QDebug
  • tst_QMimeDatabase
FALSEnever evaluated
0-3
251 m_cacheFiles.append(cacheFile);
executed 3 times by 2 tests: m_cacheFiles.append(cacheFile);
Executed by:
  • tst_QDebug
  • tst_QMimeDatabase
3
252 else-
253 delete cacheFile;
never executed: delete cacheFile;
0
254 }-
255 }
executed 5 times by 2 tests: end of block
Executed by:
  • tst_QDebug
  • tst_QMimeDatabase
5
256 m_cacheFileNames = cacheFileNames;-
257 m_mimetypeListLoaded = false;-
258 }
executed 4 times by 2 tests: end of block
Executed by:
  • tst_QDebug
  • tst_QMimeDatabase
4
259}
executed 56 times by 3 tests: end of block
Executed by:
  • tst_QDebug
  • tst_QMimeDatabase
  • tst_qmimetype
56
260-
261static QMimeType mimeTypeForNameUnchecked(const QString &name)-
262{-
263 QMimeTypePrivate data;-
264 data.name = name;-
265 // The rest is retrieved on demand.-
266 // comment and globPatterns: in loadMimeTypePrivate-
267 // iconName: in loadIcon-
268 // genericIconName: in loadGenericIcon-
269 return QMimeType(data);
executed 5482 times by 2 tests: return QMimeType(data);
Executed by:
  • tst_QDebug
  • tst_QMimeDatabase
5482
270}-
271-
272QMimeType QMimeBinaryProvider::mimeTypeForName(const QString &name)-
273{-
274 checkCache();-
275 if (!m_mimetypeListLoaded)
!m_mimetypeListLoadedDescription
TRUEevaluated 7 times by 2 tests
Evaluated by:
  • tst_QDebug
  • tst_QMimeDatabase
FALSEevaluated 2145 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
7-2145
276 loadMimeTypeList();
executed 7 times by 2 tests: loadMimeTypeList();
Executed by:
  • tst_QDebug
  • tst_QMimeDatabase
7
277 if (!m_mimetypeNames.contains(name))
!m_mimetypeNam...contains(name)Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 2144 times by 2 tests
Evaluated by:
  • tst_QDebug
  • tst_QMimeDatabase
8-2144
278 return QMimeType(); // unknown mimetype
executed 8 times by 1 test: return QMimeType();
Executed by:
  • tst_QMimeDatabase
8
279 return mimeTypeForNameUnchecked(name);
executed 2144 times by 2 tests: return mimeTypeForNameUnchecked(name);
Executed by:
  • tst_QDebug
  • tst_QMimeDatabase
2144
280}-
281-
282QStringList QMimeBinaryProvider::findByFileName(const QString &fileName, QString *foundSuffix)-
283{-
284 checkCache();-
285 if (fileName.isEmpty())
fileName.isEmpty()Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 94 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
2-94
286 return QStringList();
executed 2 times by 1 test: return QStringList();
Executed by:
  • tst_QMimeDatabase
2
287 const QString lowerFileName = fileName.toLower();-
288 QMimeGlobMatchResult result;-
289 // TODO this parses in the order (local, global). Check that it handles "NOGLOBS" correctly.-
290 foreach (CacheFile *cacheFile, m_cacheFiles) {-
291 matchGlobList(result, cacheFile, cacheFile->getUint32(PosLiteralListOffset), fileName);-
292 matchGlobList(result, cacheFile, cacheFile->getUint32(PosGlobListOffset), fileName);-
293 const int reverseSuffixTreeOffset = cacheFile->getUint32(PosReverseSuffixTreeOffset);-
294 const int numRoots = cacheFile->getUint32(reverseSuffixTreeOffset);-
295 const int firstRootOffset = cacheFile->getUint32(reverseSuffixTreeOffset + 4);-
296 matchSuffixTree(result, cacheFile, numRoots, firstRootOffset, lowerFileName, fileName.length() - 1, false);-
297 if (result.m_matchingMimeTypes.isEmpty())
result.m_match...ypes.isEmpty()Description
TRUEevaluated 32 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 65 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
32-65
298 matchSuffixTree(result, cacheFile, numRoots, firstRootOffset, fileName, fileName.length() - 1, true);
executed 32 times by 1 test: matchSuffixTree(result, cacheFile, numRoots, firstRootOffset, fileName, fileName.length() - 1, true);
Executed by:
  • tst_QMimeDatabase
32
299 }
executed 97 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
97
300 if (foundSuffix)
foundSuffixDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 86 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
8-86
301 *foundSuffix = result.m_foundSuffix;
executed 8 times by 1 test: *foundSuffix = result.m_foundSuffix;
Executed by:
  • tst_QMimeDatabase
8
302 return result.m_matchingMimeTypes;
executed 94 times by 1 test: return result.m_matchingMimeTypes;
Executed by:
  • tst_QMimeDatabase
94
303}-
304-
305void QMimeBinaryProvider::matchGlobList(QMimeGlobMatchResult &result, CacheFile *cacheFile, int off, const QString &fileName)-
306{-
307 const int numGlobs = cacheFile->getUint32(off);-
308 //qDebug() << "Loading" << numGlobs << "globs from" << cacheFile->file.fileName() << "at offset" << cacheFile->globListOffset;-
309 for (int i = 0; i < numGlobs; ++i) {
i < numGlobsDescription
TRUEevaluated 1602 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 194 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
194-1602
310 const int globOffset = cacheFile->getUint32(off + 4 + 12 * i);-
311 const int mimeTypeOffset = cacheFile->getUint32(off + 4 + 12 * i + 4);-
312 const int flagsAndWeight = cacheFile->getUint32(off + 4 + 12 * i + 8);-
313 const int weight = flagsAndWeight & 0xff;-
314 const bool caseSensitive = flagsAndWeight & 0x100;-
315 const Qt::CaseSensitivity qtCaseSensitive = caseSensitive ? Qt::CaseSensitive : Qt::CaseInsensitive;
caseSensitiveDescription
TRUEevaluated 94 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 1508 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
94-1508
316 const QString pattern = QLatin1String(cacheFile->getCharStar(globOffset));-
317-
318 const char *mimeType = cacheFile->getCharStar(mimeTypeOffset);-
319 //qDebug() << pattern << mimeType << weight << caseSensitive;-
320 QMimeGlobPattern glob(pattern, QString() /*unused*/, weight, qtCaseSensitive);-
321-
322 // TODO: this could be done faster for literals where a simple == would do.-
323 if (glob.matchFileName(fileName))
glob.matchFileName(fileName)Description
TRUEevaluated 16 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 1586 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
16-1586
324 result.addMatch(QLatin1String(mimeType), weight, pattern);
executed 16 times by 1 test: result.addMatch(QLatin1String(mimeType), weight, pattern);
Executed by:
  • tst_QMimeDatabase
16
325 }
executed 1602 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
1602
326}
executed 194 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
194
327-
328bool QMimeBinaryProvider::matchSuffixTree(QMimeGlobMatchResult &result, QMimeBinaryProvider::CacheFile *cacheFile, int numEntries, int firstOffset, const QString &fileName, int charPos, bool caseSensitiveCheck)-
329{-
330 QChar fileChar = fileName[charPos];-
331 int min = 0;-
332 int max = numEntries - 1;-
333 while (min <= max) {
min <= maxDescription
TRUEevaluated 1309 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 123 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
123-1309
334 const int mid = (min + max) / 2;-
335 const int off = firstOffset + 12 * mid;-
336 const QChar ch = cacheFile->getUint32(off);-
337 if (ch < fileChar)
ch < fileCharDescription
TRUEevaluated 586 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 723 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
586-723
338 min = mid + 1;
executed 586 times by 1 test: min = mid + 1;
Executed by:
  • tst_QMimeDatabase
586
339 else if (ch > fileChar)
ch > fileCharDescription
TRUEevaluated 339 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 384 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
339-384
340 max = mid - 1;
executed 339 times by 1 test: max = mid - 1;
Executed by:
  • tst_QMimeDatabase
339
341 else {-
342 --charPos;-
343 int numChildren = cacheFile->getUint32(off + 4);-
344 int childrenOffset = cacheFile->getUint32(off + 8);-
345 bool success = false;-
346 if (charPos > 0)
charPos > 0Description
TRUEevaluated 378 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 6 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
6-378
347 success = matchSuffixTree(result, cacheFile, numChildren, childrenOffset, fileName, charPos, caseSensitiveCheck);
executed 378 times by 1 test: success = matchSuffixTree(result, cacheFile, numChildren, childrenOffset, fileName, charPos, caseSensitiveCheck);
Executed by:
  • tst_QMimeDatabase
378
348 if (!success) {
!successDescription
TRUEevaluated 181 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 203 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
181-203
349 for (int i = 0; i < numChildren; ++i) {
i < numChildrenDescription
TRUEevaluated 190 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 57 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
57-190
350 const int childOff = childrenOffset + 12 * i;-
351 const int mch = cacheFile->getUint32(childOff);-
352 if (mch != 0)
mch != 0Description
TRUEevaluated 124 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 66 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
66-124
353 break;
executed 124 times by 1 test: break;
Executed by:
  • tst_QMimeDatabase
124
354 const int mimeTypeOffset = cacheFile->getUint32(childOff + 4);-
355 const char *mimeType = cacheFile->getCharStar(mimeTypeOffset);-
356 const int flagsAndWeight = cacheFile->getUint32(childOff + 8);-
357 const int weight = flagsAndWeight & 0xff;-
358 const bool caseSensitive = flagsAndWeight & 0x100;-
359 if (caseSensitiveCheck || !caseSensitive) {
caseSensitiveCheckDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 62 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
!caseSensitiveDescription
TRUEevaluated 58 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
4-62
360 result.addMatch(QLatin1String(mimeType), weight, QLatin1Char('*') + fileName.mid(charPos+1));-
361 success = true;-
362 }
executed 62 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
62
363 }
executed 66 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
66
364 }
executed 181 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
181
365 return success;
executed 384 times by 1 test: return success;
Executed by:
  • tst_QMimeDatabase
384
366 }-
367 }-
368 return false;
executed 123 times by 1 test: return false;
Executed by:
  • tst_QMimeDatabase
123
369}-
370-
371bool QMimeBinaryProvider::matchMagicRule(QMimeBinaryProvider::CacheFile *cacheFile, int numMatchlets, int firstOffset, const QByteArray &data)-
372{-
373 const char *dataPtr = data.constData();-
374 const int dataSize = data.size();-
375 for (int matchlet = 0; matchlet < numMatchlets; ++matchlet) {
matchlet < numMatchletsDescription
TRUEevaluated 10116 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 5890 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
5890-10116
376 const int off = firstOffset + matchlet * 32;-
377 const int rangeStart = cacheFile->getUint32(off);-
378 const int rangeLength = cacheFile->getUint32(off + 4);-
379 //const int wordSize = cacheFile->getUint32(off + 8);-
380 const int valueLength = cacheFile->getUint32(off + 12);-
381 const int valueOffset = cacheFile->getUint32(off + 16);-
382 const int maskOffset = cacheFile->getUint32(off + 20);-
383 const char *mask = maskOffset ? cacheFile->getCharStar(maskOffset) : NULL;
maskOffsetDescription
TRUEevaluated 215 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 9901 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
215-9901
384-
385 if (!QMimeMagicRule::matchSubstring(dataPtr, dataSize, rangeStart, rangeLength, valueLength, cacheFile->getCharStar(valueOffset), mask))
!QMimeMagicRul...Offset), mask)Description
TRUEevaluated 10071 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 45 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
45-10071
386 continue;
executed 10071 times by 1 test: continue;
Executed by:
  • tst_QMimeDatabase
10071
387-
388 const int numChildren = cacheFile->getUint32(off + 24);-
389 const int firstChildOffset = cacheFile->getUint32(off + 28);-
390 if (numChildren == 0) // No submatch? Then we are done.
numChildren == 0Description
TRUEevaluated 23 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 22 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
22-23
391 return true;
executed 23 times by 1 test: return true;
Executed by:
  • tst_QMimeDatabase
23
392 // Check that one of the submatches matches too-
393 if (matchMagicRule(cacheFile, numChildren, firstChildOffset, data))
matchMagicRule...dOffset, data)Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 18 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
4-18
394 return true;
executed 4 times by 1 test: return true;
Executed by:
  • tst_QMimeDatabase
4
395 }
executed 18 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
18
396 return false;
executed 5890 times by 1 test: return false;
Executed by:
  • tst_QMimeDatabase
5890
397}-
398-
399QMimeType QMimeBinaryProvider::findByMagic(const QByteArray &data, int *accuracyPtr)-
400{-
401 checkCache();-
402 foreach (CacheFile *cacheFile, m_cacheFiles) {-
403 const int magicListOffset = cacheFile->getUint32(PosMagicListOffset);-
404 const int numMatches = cacheFile->getUint32(magicListOffset);-
405 //const int maxExtent = cacheFile->getUint32(magicListOffset + 4);-
406 const int firstMatchOffset = cacheFile->getUint32(magicListOffset + 8);-
407-
408 for (int i = 0; i < numMatches; ++i) {
i < numMatchesDescription
TRUEevaluated 5895 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 9 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
9-5895
409 const int off = firstMatchOffset + i * 16;-
410 const int numMatchlets = cacheFile->getUint32(off + 8);-
411 const int firstMatchletOffset = cacheFile->getUint32(off + 12);-
412 if (matchMagicRule(cacheFile, numMatchlets, firstMatchletOffset, data)) {
matchMagicRule...tOffset, data)Description
TRUEevaluated 23 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 5872 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
23-5872
413 const int mimeTypeOffset = cacheFile->getUint32(off + 4);-
414 const char *mimeType = cacheFile->getCharStar(mimeTypeOffset);-
415 *accuracyPtr = cacheFile->getUint32(off);-
416 // Return the first match. We have no rules for conflicting magic data...-
417 // (mime.cache itself is sorted, but what about local overrides with a lower prio?)-
418 return mimeTypeForNameUnchecked(QLatin1String(mimeType));
executed 23 times by 1 test: return mimeTypeForNameUnchecked(QLatin1String(mimeType));
Executed by:
  • tst_QMimeDatabase
23
419 }-
420 }
executed 5872 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
5872
421 }
executed 9 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
9
422 return QMimeType();
executed 9 times by 1 test: return QMimeType();
Executed by:
  • tst_QMimeDatabase
9
423}-
424-
425QStringList QMimeBinaryProvider::parents(const QString &mime)-
426{-
427 checkCache();-
428 const QByteArray mimeStr = mime.toLatin1();-
429 QStringList result;-
430 foreach (CacheFile *cacheFile, m_cacheFiles) {-
431 const int parentListOffset = cacheFile->getUint32(PosParentListOffset);-
432 const int numEntries = cacheFile->getUint32(parentListOffset);-
433-
434 int begin = 0;-
435 int end = numEntries - 1;-
436 while (begin <= end) {
begin <= endDescription
TRUEevaluated 466 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 34 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
34-466
437 const int medium = (begin + end) / 2;-
438 const int off = parentListOffset + 4 + 8 * medium;-
439 const int mimeOffset = cacheFile->getUint32(off);-
440 const char *aMime = cacheFile->getCharStar(mimeOffset);-
441 const int cmp = qstrcmp(aMime, mimeStr);-
442 if (cmp < 0) {
cmp < 0Description
TRUEevaluated 230 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 236 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
230-236
443 begin = medium + 1;-
444 } else if (cmp > 0) {
executed 230 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
cmp > 0Description
TRUEevaluated 210 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 26 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
26-230
445 end = medium - 1;-
446 } else {
executed 210 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
210
447 const int parentsOffset = cacheFile->getUint32(off + 4);-
448 const int numParents = cacheFile->getUint32(parentsOffset);-
449 for (int i = 0; i < numParents; ++i) {
i < numParentsDescription
TRUEevaluated 34 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 26 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
26-34
450 const int parentOffset = cacheFile->getUint32(parentsOffset + 4 + 4 * i);-
451 const char *aParent = cacheFile->getCharStar(parentOffset);-
452 result.append(QString::fromLatin1(aParent));-
453 }
executed 34 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
34
454 break;
executed 26 times by 1 test: break;
Executed by:
  • tst_QMimeDatabase
26
455 }-
456 }-
457 }
executed 60 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
60
458 if (result.isEmpty()) {
result.isEmpty()Description
TRUEevaluated 34 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 26 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
26-34
459 const QString parent = fallbackParent(mime);-
460 if (!parent.isEmpty())
!parent.isEmpty()Description
TRUEevaluated 22 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 12 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
12-22
461 result.append(parent);
executed 22 times by 1 test: result.append(parent);
Executed by:
  • tst_QMimeDatabase
22
462 }
executed 34 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
34
463 return result;
executed 60 times by 1 test: return result;
Executed by:
  • tst_QMimeDatabase
60
464}-
465-
466QString QMimeBinaryProvider::resolveAlias(const QString &name)-
467{-
468 checkCache();-
469 const QByteArray input = name.toLatin1();-
470 foreach (CacheFile *cacheFile, m_cacheFiles) {-
471 const int aliasListOffset = cacheFile->getUint32(PosAliasListOffset);-
472 const int numEntries = cacheFile->getUint32(aliasListOffset);-
473 int begin = 0;-
474 int end = numEntries - 1;-
475 while (begin <= end) {
begin <= endDescription
TRUEevaluated 16570 times by 2 tests
Evaluated by:
  • tst_QDebug
  • tst_QMimeDatabase
FALSEevaluated 2180 times by 2 tests
Evaluated by:
  • tst_QDebug
  • tst_QMimeDatabase
2180-16570
476 const int medium = (begin + end) / 2;-
477 const int off = aliasListOffset + 4 + 8 * medium;-
478 const int aliasOffset = cacheFile->getUint32(off);-
479 const char *alias = cacheFile->getCharStar(aliasOffset);-
480 const int cmp = qstrcmp(alias, input);-
481 if (cmp < 0) {
cmp < 0Description
TRUEevaluated 8566 times by 2 tests
Evaluated by:
  • tst_QDebug
  • tst_QMimeDatabase
FALSEevaluated 8004 times by 2 tests
Evaluated by:
  • tst_QDebug
  • tst_QMimeDatabase
8004-8566
482 begin = medium + 1;-
483 } else if (cmp > 0) {
executed 8566 times by 2 tests: end of block
Executed by:
  • tst_QDebug
  • tst_QMimeDatabase
cmp > 0Description
TRUEevaluated 7995 times by 2 tests
Evaluated by:
  • tst_QDebug
  • tst_QMimeDatabase
FALSEevaluated 9 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
9-8566
484 end = medium - 1;-
485 } else {
executed 7995 times by 2 tests: end of block
Executed by:
  • tst_QDebug
  • tst_QMimeDatabase
7995
486 const int mimeOffset = cacheFile->getUint32(off + 4);-
487 const char *mimeType = cacheFile->getCharStar(mimeOffset);-
488 return QLatin1String(mimeType);
executed 9 times by 1 test: return QLatin1String(mimeType);
Executed by:
  • tst_QMimeDatabase
9
489 }-
490 }-
491 }
executed 2180 times by 2 tests: end of block
Executed by:
  • tst_QDebug
  • tst_QMimeDatabase
2180
492-
493 return name;
executed 2169 times by 2 tests: return name;
Executed by:
  • tst_QDebug
  • tst_QMimeDatabase
2169
494}-
495-
496QStringList QMimeBinaryProvider::listAliases(const QString &name)-
497{-
498 checkCache();-
499 QStringList result;-
500 const QByteArray input = name.toLatin1();-
501 foreach (CacheFile *cacheFile, m_cacheFiles) {-
502 const int aliasListOffset = cacheFile->getUint32(PosAliasListOffset);-
503 const int numEntries = cacheFile->getUint32(aliasListOffset);-
504 for (int pos = 0; pos < numEntries; ++pos) {
pos < numEntriesDescription
TRUEevaluated 776 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
4-776
505 const int off = aliasListOffset + 4 + 8 * pos;-
506 const int mimeOffset = cacheFile->getUint32(off + 4);-
507 const char *mimeType = cacheFile->getCharStar(mimeOffset);-
508-
509 if (input == mimeType) {
input == mimeTypeDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 772 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
4-772
510 const int aliasOffset = cacheFile->getUint32(off);-
511 const char *alias = cacheFile->getCharStar(aliasOffset);-
512 result.append(QString::fromLatin1(alias));-
513 }
executed 4 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
4
514 }
executed 776 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
776
515 }
executed 4 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
4
516 return result;
executed 4 times by 1 test: return result;
Executed by:
  • tst_QMimeDatabase
4
517}-
518-
519void QMimeBinaryProvider::loadMimeTypeList()-
520{-
521 if (!m_mimetypeListLoaded) {
!m_mimetypeListLoadedDescription
TRUEevaluated 7 times by 2 tests
Evaluated by:
  • tst_QDebug
  • tst_QMimeDatabase
FALSEevaluated 5 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
5-7
522 m_mimetypeListLoaded = true;-
523 m_mimetypeNames.clear();-
524 // Unfortunately mime.cache doesn't have a full list of all mimetypes.-
525 // So we have to parse the plain-text files called "types".-
526 const QStringList typesFilenames = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QLatin1String("mime/types"));-
527 foreach (const QString &typeFilename, typesFilenames) {-
528 QFile file(typeFilename);-
529 if (file.open(QIODevice::ReadOnly)) {
file.open(QIODevice::ReadOnly)Description
TRUEevaluated 10 times by 2 tests
Evaluated by:
  • tst_QDebug
  • tst_QMimeDatabase
FALSEnever evaluated
0-10
530 while (!file.atEnd()) {
!file.atEnd()Description
TRUEevaluated 4698 times by 2 tests
Evaluated by:
  • tst_QDebug
  • tst_QMimeDatabase
FALSEevaluated 10 times by 2 tests
Evaluated by:
  • tst_QDebug
  • tst_QMimeDatabase
10-4698
531 QByteArray line = file.readLine();-
532 line.chop(1);-
533 m_mimetypeNames.insert(QString::fromLatin1(line.constData(), line.size()));-
534 }
executed 4698 times by 2 tests: end of block
Executed by:
  • tst_QDebug
  • tst_QMimeDatabase
4698
535 }
executed 10 times by 2 tests: end of block
Executed by:
  • tst_QDebug
  • tst_QMimeDatabase
10
536 }
executed 10 times by 2 tests: end of block
Executed by:
  • tst_QDebug
  • tst_QMimeDatabase
10
537 }
executed 7 times by 2 tests: end of block
Executed by:
  • tst_QDebug
  • tst_QMimeDatabase
7
538}
executed 12 times by 2 tests: end of block
Executed by:
  • tst_QDebug
  • tst_QMimeDatabase
12
539-
540QList<QMimeType> QMimeBinaryProvider::allMimeTypes()-
541{-
542 QList<QMimeType> result;-
543 loadMimeTypeList();-
544 result.reserve(m_mimetypeNames.count());-
545-
546 for (QSet<QString>::const_iterator it = m_mimetypeNames.constBegin();-
547 it != m_mimetypeNames.constEnd(); ++it)
it != m_mimety...mes.constEnd()Description
TRUEevaluated 3315 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 5 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
5-3315
548 result.append(mimeTypeForNameUnchecked(*it));
executed 3315 times by 1 test: result.append(mimeTypeForNameUnchecked(*it));
Executed by:
  • tst_QMimeDatabase
3315
549-
550 return result;
executed 5 times by 1 test: return result;
Executed by:
  • tst_QMimeDatabase
5
551}-
552-
553void QMimeBinaryProvider::loadMimeTypePrivate(QMimeTypePrivate &data)-
554{-
555#ifdef QT_NO_XMLSTREAMREADER-
556 qWarning() << "Cannot load mime type since QXmlStreamReader is not available.";-
557 return;-
558#else-
559 if (data.loaded)
data.loadedDescription
TRUEevaluated 10 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 18 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
10-18
560 return;
executed 10 times by 1 test: return;
Executed by:
  • tst_QMimeDatabase
10
561 data.loaded = true;-
562 // load comment and globPatterns-
563-
564 const QString file = data.name + QLatin1String(".xml");-
565 // shared-mime-info since 1.3 lowercases the xml files-
566 QStringList mimeFiles = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QString::fromLatin1("mime/") + file.toLower());-
567 if (mimeFiles.isEmpty()) {
mimeFiles.isEmpty()Description
TRUEnever evaluated
FALSEevaluated 18 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
0-18
568 mimeFiles = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QString::fromLatin1("mime/") + file); // pre-1.3-
569 }
never executed: end of block
0
570 if (mimeFiles.isEmpty()) {
mimeFiles.isEmpty()Description
TRUEnever evaluated
FALSEevaluated 18 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
0-18
571 qWarning() << "No file found for" << file << ", even though update-mime-info said it would exist.\n"-
572 "Either it was just removed, or the directory doesn't have executable permission..."-
573 << QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QLatin1String("mime"), QStandardPaths::LocateDirectory);-
574 return;
never executed: return;
0
575 }-
576-
577 QString comment;-
578 QString mainPattern;-
579 const QString preferredLanguage = QLocale().name();-
580-
581 for (QStringList::const_reverse_iterator it = mimeFiles.crbegin(), end = mimeFiles.crend(); it != end; ++it) { // global first, then local.
it != endDescription
TRUEevaluated 18 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 18 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
18
582 QFile qfile(*it);-
583 if (!qfile.open(QFile::ReadOnly))
!qfile.open(QFile::ReadOnly)Description
TRUEnever evaluated
FALSEevaluated 18 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
0-18
584 continue;
never executed: continue;
0
585-
586 QXmlStreamReader xml(&qfile);-
587 if (xml.readNextStartElement()) {
xml.readNextStartElement()Description
TRUEevaluated 18 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEnever evaluated
0-18
588 if (xml.name() != QLatin1String("mime-type")) {
xml.name() != ...g("mime-type")Description
TRUEnever evaluated
FALSEevaluated 18 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
0-18
589 continue;
never executed: continue;
0
590 }-
591 const QStringRef name = xml.attributes().value(QLatin1String("type"));-
592 if (name.isEmpty())
name.isEmpty()Description
TRUEnever evaluated
FALSEevaluated 18 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
0-18
593 continue;
never executed: continue;
0
594 if (name.compare(data.name, Qt::CaseInsensitive))
name.compare(d...seInsensitive)Description
TRUEnever evaluated
FALSEevaluated 18 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
0-18
595 qWarning() << "Got name" << name << "in file" << file << "expected" << data.name;
never executed: QMessageLogger(__FILE__, 595, __PRETTY_FUNCTION__).warning() << "Got name" << name << "in file" << file << "expected" << data.name;
0
596-
597 while (xml.readNextStartElement()) {
xml.readNextStartElement()Description
TRUEevaluated 812 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 18 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
18-812
598 const QStringRef tag = xml.name();-
599 if (tag == QLatin1String("comment")) {
tag == QLatin1...ing("comment")Description
TRUEevaluated 746 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 66 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
66-746
600 QString lang = xml.attributes().value(QLatin1String("xml:lang")).toString();-
601 const QString text = xml.readElementText();-
602 if (lang.isEmpty()) {
lang.isEmpty()Description
TRUEevaluated 18 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 728 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
18-728
603 lang = QLatin1String("en_US");-
604 }
executed 18 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
18
605 data.localeComments.insert(lang, text);-
606 continue; // we called readElementText, so we're at the EndElement already.
executed 746 times by 1 test: continue;
Executed by:
  • tst_QMimeDatabase
746
607 } else if (tag == QLatin1String("icon")) { // as written out by shared-mime-info >= 0.40
tag == QLatin1String("icon")Description
TRUEnever evaluated
FALSEevaluated 66 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
0-66
608 data.iconName = xml.attributes().value(QLatin1String("name")).toString();-
609 } else if (tag == QLatin1String("glob-deleteall")) { // as written out by shared-mime-info >= 0.70
never executed: end of block
tag == QLatin1...ob-deleteall")Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 65 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
0-65
610 data.globPatterns.clear();-
611 } else if (tag == QLatin1String("glob")) { // as written out by shared-mime-info >= 0.70
executed 1 time by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
tag == QLatin1String("glob")Description
TRUEevaluated 30 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 35 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
1-35
612 const QString pattern = xml.attributes().value(QLatin1String("pattern")).toString();-
613 if (mainPattern.isEmpty() && pattern.startsWith(QLatin1Char('*'))) {
mainPattern.isEmpty()Description
TRUEevaluated 14 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 16 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
pattern.starts...tin1Char('*'))Description
TRUEevaluated 13 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QMimeDatabase
1-16
614 mainPattern = pattern;-
615 }
executed 13 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
13
616 if (!data.globPatterns.contains(pattern))
!data.globPatt...tains(pattern)Description
TRUEevaluated 30 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEnever evaluated
0-30
617 data.globPatterns.append(pattern);
executed 30 times by 1 test: data.globPatterns.append(pattern);
Executed by:
  • tst_QMimeDatabase
30
618 }
executed 30 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
30
619 xml.skipCurrentElement();-
620 }
executed 66 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
66
621 Q_ASSERT(xml.name() == QLatin1String("mime-type"));-
622 }
executed 18 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
18
623 }
executed 18 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
18
624-
625 // Let's assume that shared-mime-info is at least version 0.70-
626 // Otherwise we would need 1) a version check, and 2) code for parsing patterns from the globs file.-
627#if 1-
628 if (!mainPattern.isEmpty() && (data.globPatterns.isEmpty() || data.globPatterns.first() != mainPattern)) {
!mainPattern.isEmpty()Description
TRUEevaluated 13 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 5 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
data.globPatterns.isEmpty()Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 12 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
data.globPatte...!= mainPatternDescription
TRUEnever evaluated
FALSEevaluated 12 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
0-13
629 // ensure it's first in the list of patterns-
630 data.globPatterns.removeAll(mainPattern);-
631 data.globPatterns.prepend(mainPattern);-
632 }
executed 1 time by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
1
633#else-
634 const bool globsInXml = sharedMimeInfoVersion() >= QT_VERSION_CHECK(0, 70, 0);-
635 if (globsInXml) {-
636 if (!mainPattern.isEmpty() && data.globPatterns.first() != mainPattern) {-
637 // ensure it's first in the list of patterns-
638 data.globPatterns.removeAll(mainPattern);-
639 data.globPatterns.prepend(mainPattern);-
640 }-
641 } else {-
642 // Fallback: get the patterns from the globs file-
643 // TODO: This would be the only way to support shared-mime-info < 0.70-
644 // But is this really worth the effort?-
645 }-
646#endif-
647#endif //QT_NO_XMLSTREAMREADER-
648}
executed 18 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
18
649-
650// Binary search in the icons or generic-icons list-
651QString QMimeBinaryProvider::iconForMime(CacheFile *cacheFile, int posListOffset, const QByteArray &inputMime)-
652{-
653 const int iconsListOffset = cacheFile->getUint32(posListOffset);-
654 const int numIcons = cacheFile->getUint32(iconsListOffset);-
655 int begin = 0;-
656 int end = numIcons - 1;-
657 while (begin <= end) {
begin <= endDescription
TRUEevaluated 34 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 6 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
6-34
658 const int medium = (begin + end) / 2;-
659 const int off = iconsListOffset + 4 + 8 * medium;-
660 const int mimeOffset = cacheFile->getUint32(off);-
661 const char *mime = cacheFile->getCharStar(mimeOffset);-
662 const int cmp = qstrcmp(mime, inputMime);-
663 if (cmp < 0)
cmp < 0Description
TRUEevaluated 18 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 16 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
16-18
664 begin = medium + 1;
executed 18 times by 1 test: begin = medium + 1;
Executed by:
  • tst_QMimeDatabase
18
665 else if (cmp > 0)
cmp > 0Description
TRUEevaluated 14 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
2-14
666 end = medium - 1;
executed 14 times by 1 test: end = medium - 1;
Executed by:
  • tst_QMimeDatabase
14
667 else {-
668 const int iconOffset = cacheFile->getUint32(off + 4);-
669 return QLatin1String(cacheFile->getCharStar(iconOffset));
executed 2 times by 1 test: return QLatin1String(cacheFile->getCharStar(iconOffset));
Executed by:
  • tst_QMimeDatabase
2
670 }-
671 }-
672 return QString();
executed 6 times by 1 test: return QString();
Executed by:
  • tst_QMimeDatabase
6
673}-
674-
675void QMimeBinaryProvider::loadIcon(QMimeTypePrivate &data)-
676{-
677 checkCache();-
678 const QByteArray inputMime = data.name.toLatin1();-
679 foreach (CacheFile *cacheFile, m_cacheFiles) {-
680 const QString icon = iconForMime(cacheFile, PosIconsListOffset, inputMime);-
681 if (!icon.isEmpty()) {
!icon.isEmpty()Description
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
0-4
682 data.iconName = icon;-
683 return;
never executed: return;
0
684 }-
685 }
executed 4 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
4
686}
executed 4 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
4
687-
688void QMimeBinaryProvider::loadGenericIcon(QMimeTypePrivate &data)-
689{-
690 checkCache();-
691 const QByteArray inputMime = data.name.toLatin1();-
692 foreach (CacheFile *cacheFile, m_cacheFiles) {-
693 const QString icon = iconForMime(cacheFile, PosGenericIconsListOffset, inputMime);-
694 if (!icon.isEmpty()) {
!icon.isEmpty()Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
2
695 data.genericIconName = icon;-
696 return;
executed 2 times by 1 test: return;
Executed by:
  • tst_QMimeDatabase
2
697 }-
698 }
executed 2 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
2
699}
executed 2 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
2
700-
701////-
702-
703QMimeXMLProvider::QMimeXMLProvider(QMimeDatabasePrivate *db)-
704 : QMimeProviderBase(db), m_loaded(false)-
705{-
706 initResources();-
707}
executed 2 times by 2 tests: end of block
Executed by:
  • tst_QMimeDatabase
  • tst_qmimetype
2
708-
709QMimeXMLProvider::~QMimeXMLProvider()-
710{-
711}-
712-
713bool QMimeXMLProvider::isValid()-
714{-
715 return true;
never executed: return true;
0
716}-
717-
718QMimeType QMimeXMLProvider::mimeTypeForName(const QString &name)-
719{-
720 ensureLoaded();-
721-
722 return m_nameMimeTypeMap.value(name);
executed 2183 times by 1 test: return m_nameMimeTypeMap.value(name);
Executed by:
  • tst_QMimeDatabase
2183
723}-
724-
725QStringList QMimeXMLProvider::findByFileName(const QString &fileName, QString *foundSuffix)-
726{-
727 ensureLoaded();-
728-
729 const QStringList matchingMimeTypes = m_mimeTypeGlobs.matchingGlobs(fileName, foundSuffix);-
730 return matchingMimeTypes;
executed 96 times by 1 test: return matchingMimeTypes;
Executed by:
  • tst_QMimeDatabase
96
731}-
732-
733QMimeType QMimeXMLProvider::findByMagic(const QByteArray &data, int *accuracyPtr)-
734{-
735 ensureLoaded();-
736-
737 QString candidate;-
738-
739 foreach (const QMimeMagicRuleMatcher &matcher, m_magicMatchers) {-
740 if (matcher.matches(data)) {
matcher.matches(data)Description
TRUEevaluated 37 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 11003 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
37-11003
741 const int priority = matcher.priority();-
742 if (priority > *accuracyPtr) {
priority > *accuracyPtrDescription
TRUEevaluated 23 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 14 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
14-23
743 *accuracyPtr = priority;-
744 candidate = matcher.mimetype();-
745 }
executed 23 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
23
746 }
executed 37 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
37
747 }
executed 11040 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
11040
748 return mimeTypeForName(candidate);
executed 32 times by 1 test: return mimeTypeForName(candidate);
Executed by:
  • tst_QMimeDatabase
32
749}-
750-
751void QMimeXMLProvider::ensureLoaded()-
752{-
753 if (!m_loaded || shouldCheck()) {
!m_loadedDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 4556 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
shouldCheck()Description
TRUEevaluated 56 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 4500 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
1-4556
754 bool fdoXmlFound = false;-
755 QStringList allFiles;-
756-
757 const QStringList packageDirs = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QLatin1String("mime/packages"), QStandardPaths::LocateDirectory);-
758 //qDebug() << "packageDirs=" << packageDirs;-
759 foreach (const QString &packageDir, packageDirs) {-
760 QDir dir(packageDir);-
761 const QStringList files = dir.entryList(QDir::Files | QDir::NoDotAndDotDot);-
762 //qDebug() << static_cast<const void *>(this) << packageDir << files;-
763 if (!fdoXmlFound)
!fdoXmlFoundDescription
TRUEevaluated 88 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEnever evaluated
0-88
764 fdoXmlFound = files.contains(QLatin1String("freedesktop.org.xml"));
executed 88 times by 1 test: fdoXmlFound = files.contains(QLatin1String("freedesktop.org.xml"));
Executed by:
  • tst_QMimeDatabase
88
765 QStringList::const_iterator endIt(files.constEnd());-
766 for (QStringList::const_iterator it(files.constBegin()); it != endIt; ++it) {
it != endItDescription
TRUEevaluated 261 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 88 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
88-261
767 allFiles.append(packageDir + QLatin1Char('/') + *it);-
768 }
executed 261 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
261
769 }
executed 88 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
88
770-
771 if (!fdoXmlFound) {
!fdoXmlFoundDescription
TRUEnever evaluated
FALSEevaluated 57 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
0-57
772 // We could instead install the file as part of installing Qt?-
773 allFiles.prepend(QLatin1String(":/qt-project.org/qmime/freedesktop.org.xml"));-
774 }
never executed: end of block
0
775-
776 if (m_allFiles == allFiles)
m_allFiles == allFilesDescription
TRUEevaluated 52 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 5 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
5-52
777 return;
executed 52 times by 1 test: return;
Executed by:
  • tst_QMimeDatabase
52
778 m_allFiles = allFiles;-
779-
780 m_nameMimeTypeMap.clear();-
781 m_aliases.clear();-
782 m_parents.clear();-
783 m_mimeTypeGlobs.clear();-
784 m_magicMatchers.clear();-
785-
786 //qDebug() << "Loading" << m_allFiles;-
787-
788 foreach (const QString &file, allFiles)-
789 load(file);
executed 17 times by 1 test: load(file);
Executed by:
  • tst_QMimeDatabase
17
790 }
executed 5 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
5
791}
executed 4505 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
4505
792-
793void QMimeXMLProvider::load(const QString &fileName)-
794{-
795 QString errorMessage;-
796 if (!load(fileName, &errorMessage))
!load(fileName, &errorMessage)Description
TRUEnever evaluated
FALSEevaluated 17 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
0-17
797 qWarning("QMimeDatabase: Error loading %s\n%s", qPrintable(fileName), qPrintable(errorMessage));
never executed: QMessageLogger(__FILE__, 797, __PRETTY_FUNCTION__).warning("QMimeDatabase: Error loading %s\n%s", QString(fileName).toLocal8Bit().constData(), QString(errorMessage).toLocal8Bit().constData());
0
798}
executed 17 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
17
799-
800bool QMimeXMLProvider::load(const QString &fileName, QString *errorMessage)-
801{-
802 m_loaded = true;-
803-
804 QFile file(fileName);-
805 if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
!file.open(QIO...ODevice::Text)Description
TRUEnever evaluated
FALSEevaluated 17 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
0-17
806 if (errorMessage)
errorMessageDescription
TRUEnever evaluated
FALSEnever evaluated
0
807 *errorMessage = QString::fromLatin1("Cannot open %1: %2").arg(fileName, file.errorString());
never executed: *errorMessage = QString::fromLatin1("Cannot open %1: %2").arg(fileName, file.errorString());
0
808 return false;
never executed: return false;
0
809 }-
810-
811 if (errorMessage)
errorMessageDescription
TRUEevaluated 17 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEnever evaluated
0-17
812 errorMessage->clear();
executed 17 times by 1 test: errorMessage->clear();
Executed by:
  • tst_QMimeDatabase
17
813-
814 QMimeTypeParser parser(*this);-
815 return parser.parse(&file, fileName, errorMessage);
executed 17 times by 1 test: return parser.parse(&file, fileName, errorMessage);
Executed by:
  • tst_QMimeDatabase
17
816}-
817-
818void QMimeXMLProvider::addGlobPattern(const QMimeGlobPattern &glob)-
819{-
820 m_mimeTypeGlobs.addGlob(glob);-
821}
executed 4136 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
4136
822-
823void QMimeXMLProvider::addMimeType(const QMimeType &mt)-
824{-
825 m_nameMimeTypeMap.insert(mt.name(), mt);-
826}
executed 3319 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
3319
827-
828QStringList QMimeXMLProvider::parents(const QString &mime)-
829{-
830 ensureLoaded();-
831 QStringList result = m_parents.value(mime);-
832 if (result.isEmpty()) {
result.isEmpty()Description
TRUEevaluated 34 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 26 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
26-34
833 const QString parent = fallbackParent(mime);-
834 if (!parent.isEmpty())
!parent.isEmpty()Description
TRUEevaluated 22 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 12 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
12-22
835 result.append(parent);
executed 22 times by 1 test: result.append(parent);
Executed by:
  • tst_QMimeDatabase
22
836 }
executed 34 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
34
837 return result;
executed 60 times by 1 test: return result;
Executed by:
  • tst_QMimeDatabase
60
838}-
839-
840void QMimeXMLProvider::addParent(const QString &child, const QString &parent)-
841{-
842 m_parents[child].append(parent);-
843}
executed 1560 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
1560
844-
845QStringList QMimeXMLProvider::listAliases(const QString &name)-
846{-
847 ensureLoaded();-
848 // Iterate through the whole hash. This method is rarely used.-
849 return m_aliases.keys(name);
executed 4 times by 1 test: return m_aliases.keys(name);
Executed by:
  • tst_QMimeDatabase
4
850}-
851-
852QString QMimeXMLProvider::resolveAlias(const QString &name)-
853{-
854 ensureLoaded();-
855 return m_aliases.value(name, name);
executed 2177 times by 1 test: return m_aliases.value(name, name);
Executed by:
  • tst_QMimeDatabase
2177
856}-
857-
858void QMimeXMLProvider::addAlias(const QString &alias, const QString &name)-
859{-
860 m_aliases.insert(alias, name);-
861}
executed 975 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
975
862-
863QList<QMimeType> QMimeXMLProvider::allMimeTypes()-
864{-
865 ensureLoaded();-
866 return m_nameMimeTypeMap.values();
executed 5 times by 1 test: return m_nameMimeTypeMap.values();
Executed by:
  • tst_QMimeDatabase
5
867}-
868-
869void QMimeXMLProvider::addMagicMatcher(const QMimeMagicRuleMatcher &matcher)-
870{-
871 m_magicMatchers.append(matcher);-
872}
executed 1733 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
1733
873-
874QT_END_NAMESPACE-
875-
876#endif // QT_NO_MIMETYPE-
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9