qmimeprovider.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/corelib/mimetypes/qmimeprovider.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6static void initResources()-
7{-
8 do { extern int qInitResources_mimetypes (); qInitResources_mimetypes (); } while (0);-
9}
executed 2 times by 2 tests: end of block
Executed by:
  • tst_QMimeDatabase
  • tst_qmimetype
2
10-
11-
12-
13static QString fallbackParent(const QString &mimeTypeName)-
14{-
15 const QString myGroup = mimeTypeName.left(mimeTypeName.indexOf(QLatin1Char('/')));-
16-
17 if (myGroup == QLatin1String("text")
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 != QLatin1String("text/plain")
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
18 return
executed 8 times by 1 test: return QLatin1String("text/plain");
Executed by:
  • tst_QMimeDatabase
QLatin1String("text/plain");
executed 8 times by 1 test: return QLatin1String("text/plain");
Executed by:
  • tst_QMimeDatabase
8
19-
20 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
21-
22 myGroup != QLatin1String("all")
myGroup != QLa...1String("all")Description
TRUEevaluated 52 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEnever evaluated
&& myGroup != QLatin1String("fonts")
myGroup != QLa...tring("fonts")Description
TRUEevaluated 52 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEnever evaluated
&& myGroup != QLatin1String("print")
myGroup != QLa...tring("print")Description
TRUEevaluated 52 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEnever evaluated
&& myGroup != QLatin1String("uri")
myGroup != QLa...1String("uri")Description
TRUEevaluated 52 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEnever evaluated
0-52
23 && 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
24 return
executed 36 times by 1 test: return QLatin1String("application/octet-stream");
Executed by:
  • tst_QMimeDatabase
QLatin1String("application/octet-stream");
executed 36 times by 1 test: return QLatin1String("application/octet-stream");
Executed by:
  • tst_QMimeDatabase
36
25 }-
26 return
executed 24 times by 1 test: return QString();
Executed by:
  • tst_QMimeDatabase
QString();
executed 24 times by 1 test: return QString();
Executed by:
  • tst_QMimeDatabase
24
27}-
28-
29QMimeProviderBase::QMimeProviderBase(QMimeDatabasePrivate *db)-
30 : m_db(db)-
31{-
32}
executed 6 times by 3 tests: end of block
Executed by:
  • tst_QDebug
  • tst_QMimeDatabase
  • tst_qmimetype
6
33-
34__attribute__((visibility("default"))) int qmime_secondsBetweenChecks = 5;-
35-
36bool QMimeProviderBase::shouldCheck()-
37{-
38 if (m_lastCheck.isValid()
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.elapsed() < qmime_secondsBetweenChecks * 1000
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
39 return
executed 8977 times by 2 tests: return false;
Executed by:
  • tst_QDebug
  • tst_QMimeDatabase
false;
executed 8977 times by 2 tests: return false;
Executed by:
  • tst_QDebug
  • tst_QMimeDatabase
8977
40 m_lastCheck.start();-
41 return
executed 112 times by 3 tests: return true;
Executed by:
  • tst_QDebug
  • tst_QMimeDatabase
  • tst_qmimetype
true;
executed 112 times by 3 tests: return true;
Executed by:
  • tst_QDebug
  • tst_QMimeDatabase
  • tst_qmimetype
112
42}-
43-
44QMimeBinaryProvider::QMimeBinaryProvider(QMimeDatabasePrivate *db)-
45 : QMimeProviderBase(db), m_mimetypeListLoaded(false)-
46{-
47}
executed 4 times by 3 tests: end of block
Executed by:
  • tst_QDebug
  • tst_QMimeDatabase
  • tst_qmimetype
4
48-
49-
50-
51-
52-
53struct QMimeBinaryProvider::CacheFile-
54{-
55 CacheFile(const QString &fileName);-
56 ~CacheFile();-
57-
58 bool isValid() const { return
executed 3 times by 2 tests: return m_valid;
Executed by:
  • tst_QDebug
  • tst_QMimeDatabase
m_valid;
executed 3 times by 2 tests: return m_valid;
Executed by:
  • tst_QDebug
  • tst_QMimeDatabase
}
3
59 inline quint16 getUint16(int offset) const-
60 {-
61 return
executed 12 times by 2 tests: return qFromBigEndian(*reinterpret_cast<quint16 *>(data + offset));
Executed by:
  • tst_QDebug
  • tst_QMimeDatabase
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
62 }-
63 inline quint32 getUint32(int offset) const-
64 {-
65 return
executed 92955 times by 2 tests: return qFromBigEndian(*reinterpret_cast<quint32 *>(data + offset));
Executed by:
  • tst_QDebug
  • tst_QMimeDatabase
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
66 }-
67 inline const char *getCharStar(int offset) const-
68 {-
69 return
executed 31519 times by 2 tests: return reinterpret_cast<const char *>(data + offset);
Executed by:
  • tst_QDebug
  • tst_QMimeDatabase
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
70 }-
71 bool load();-
72 bool reload();-
73-
74 QFile file;-
75 uchar *data;-
76 QDateTime m_mtime;-
77 bool m_valid;-
78};-
79-
80QMimeBinaryProvider::CacheFile::CacheFile(const QString &fileName)-
81 : file(fileName), m_valid(false)-
82{-
83 load();-
84}
executed 3 times by 2 tests: end of block
Executed by:
  • tst_QDebug
  • tst_QMimeDatabase
3
85-
86QMimeBinaryProvider::CacheFile::~CacheFile()-
87{-
88}-
89-
90bool QMimeBinaryProvider::CacheFile::load()-
91{-
92 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
93 return
never executed: return false;
false;
never executed: return false;
0
94 data = file.map(0, file.size());-
95 if (data
dataDescription
TRUEevaluated 6 times by 2 tests
Evaluated by:
  • tst_QDebug
  • tst_QMimeDatabase
FALSEnever evaluated
) {
0-6
96 const int major = getUint16(0);-
97 const int minor = getUint16(2);-
98 m_valid = (major == 1
major == 1Description
TRUEevaluated 6 times by 2 tests
Evaluated by:
  • tst_QDebug
  • tst_QMimeDatabase
FALSEnever evaluated
&& minor >= 1
minor >= 1Description
TRUEevaluated 6 times by 2 tests
Evaluated by:
  • tst_QDebug
  • tst_QMimeDatabase
FALSEnever evaluated
&& minor <= 2
minor <= 2Description
TRUEevaluated 6 times by 2 tests
Evaluated by:
  • tst_QDebug
  • tst_QMimeDatabase
FALSEnever evaluated
);
0-6
99 }
executed 6 times by 2 tests: end of block
Executed by:
  • tst_QDebug
  • tst_QMimeDatabase
6
100 m_mtime = QFileInfo(file).lastModified();-
101 return
executed 6 times by 2 tests: return m_valid;
Executed by:
  • tst_QDebug
  • tst_QMimeDatabase
m_valid;
executed 6 times by 2 tests: return m_valid;
Executed by:
  • tst_QDebug
  • tst_QMimeDatabase
6
102}-
103-
104bool QMimeBinaryProvider::CacheFile::reload()-
105{-
106-
107 m_valid = false;-
108 if (file.isOpen()
file.isOpen()Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEnever evaluated
) {
0-3
109 file.close();-
110 }
executed 3 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
3
111 data = 0;-
112 return
executed 3 times by 1 test: return load();
Executed by:
  • tst_QMimeDatabase
load();
executed 3 times by 1 test: return load();
Executed by:
  • tst_QMimeDatabase
3
113}-
114-
115QMimeBinaryProvider::CacheFile *QMimeBinaryProvider::CacheFileList::findCacheFile(const QString &fileName) const-
116{-
117 for (const_iterator it = begin(); it != end()
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
; ++it) {
3
118 if ((*
(*it)->file.fi...() == fileNameDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QMimeDatabase
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
119 return
executed 2 times by 1 test: return *it;
Executed by:
  • tst_QMimeDatabase
*it;
executed 2 times by 1 test: return *it;
Executed by:
  • tst_QMimeDatabase
2
120 }
executed 1 time by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
1
121 return
executed 3 times by 2 tests: return 0;
Executed by:
  • tst_QDebug
  • tst_QMimeDatabase
0;
executed 3 times by 2 tests: return 0;
Executed by:
  • tst_QDebug
  • tst_QMimeDatabase
3
122}-
123-
124QMimeBinaryProvider::~QMimeBinaryProvider()-
125{-
126 qDeleteAll(m_cacheFiles);-
127}
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
128-
129-
130enum {-
131 PosAliasListOffset = 4,-
132 PosParentListOffset = 8,-
133 PosLiteralListOffset = 12,-
134 PosReverseSuffixTreeOffset = 16,-
135 PosGlobListOffset = 20,-
136 PosMagicListOffset = 24,-
137-
138 PosIconsListOffset = 32,-
139 PosGenericIconsListOffset = 36-
140};-
141-
142bool QMimeBinaryProvider::isValid()-
143{-
144-
145 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
146 return
executed 1 time by 1 test: return false;
Executed by:
  • tst_QMimeDatabase
false;
executed 1 time by 1 test: return false;
Executed by:
  • tst_QMimeDatabase
1
147-
148 ((!(m_cacheFiles.isEmpty())) ? qt_assert("m_cacheFiles.isEmpty()",__FILE__,193) : qt_noop());-
149 checkCache();-
150-
151 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
152 return
never executed: return true;
true;
never executed: return true;
0
153 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
154 return
executed 1 time by 1 test: return false;
Executed by:
  • tst_qmimetype
false;
executed 1 time by 1 test: return false;
Executed by:
  • tst_qmimetype
1
155-
156-
157 const QString foundFile = m_cacheFiles.first()->file.fileName();-
158 const QString localCacheFile = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QLatin1String("/mime/mime.cache");-
159-
160 return
executed 2 times by 2 tests: return foundFile != localCacheFile;
Executed by:
  • tst_QDebug
  • tst_QMimeDatabase
foundFile != localCacheFile;
executed 2 times by 2 tests: return foundFile != localCacheFile;
Executed by:
  • tst_QDebug
  • tst_QMimeDatabase
2
161-
162-
163-
164}-
165-
166bool QMimeBinaryProvider::CacheFileList::checkCacheChanged()-
167{-
168 bool somethingChanged = false;-
169 QMutableListIterator<CacheFile *> it(*this);-
170 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
171 CacheFile *cacheFile = it.next();-
172 QFileInfo fileInfo(cacheFile->file);-
173 if (!fileInfo.exists()
!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
174 delete cacheFile;-
175 it.remove();-
176 somethingChanged = true;-
177 }
executed 1 time by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
else if (fileInfo.lastModified() > cacheFile->m_mtime
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
178 if (!cacheFile->reload()
!cacheFile->reload()Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
) {
0-3
179 delete cacheFile;-
180 it.remove();-
181 }
never executed: end of block
0
182 somethingChanged = true;-
183 }
executed 3 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
3
184 }
executed 78 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
78
185 return
executed 56 times by 3 tests: return somethingChanged;
Executed by:
  • tst_QDebug
  • tst_QMimeDatabase
  • tst_qmimetype
somethingChanged;
executed 56 times by 3 tests: return somethingChanged;
Executed by:
  • tst_QDebug
  • tst_QMimeDatabase
  • tst_qmimetype
56
186}-
187-
188void QMimeBinaryProvider::checkCache()-
189{-
190 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
191 return;
executed 4477 times by 2 tests: return;
Executed by:
  • tst_QDebug
  • tst_QMimeDatabase
4477
192-
193-
194 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
195 m_mimetypeListLoaded = false;
executed 4 times by 1 test: m_mimetypeListLoaded = false;
Executed by:
  • tst_QMimeDatabase
4
196-
197-
198 const QStringList cacheFileNames = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QLatin1String("mime/mime.cache"));-
199 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
200 for (QForeachContainer<typename QtPrivate::remove_reference<decltype(cacheFileNames)>::type> _container_((cacheFileNames)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (const QString &cacheFileName = *_container_.i; _container_.control; _container_.control = 0) {-
201 CacheFile *cacheFile = m_cacheFiles.findCacheFile(cacheFileName);-
202 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
203-
204 cacheFile = new CacheFile(cacheFileName);-
205 if (cacheFile->isValid()
cacheFile->isValid()Description
TRUEevaluated 3 times by 2 tests
Evaluated by:
  • tst_QDebug
  • tst_QMimeDatabase
FALSEnever evaluated
)
0-3
206 m_cacheFiles.append(cacheFile);
executed 3 times by 2 tests: m_cacheFiles.append(cacheFile);
Executed by:
  • tst_QDebug
  • tst_QMimeDatabase
3
207 else-
208 delete cacheFile;
never executed: delete cacheFile;
0
209 }-
210 }
executed 5 times by 2 tests: end of block
Executed by:
  • tst_QDebug
  • tst_QMimeDatabase
5
211 m_cacheFileNames = cacheFileNames;-
212 m_mimetypeListLoaded = false;-
213 }
executed 4 times by 2 tests: end of block
Executed by:
  • tst_QDebug
  • tst_QMimeDatabase
4
214}
executed 56 times by 3 tests: end of block
Executed by:
  • tst_QDebug
  • tst_QMimeDatabase
  • tst_qmimetype
56
215-
216static QMimeType mimeTypeForNameUnchecked(const QString &name)-
217{-
218 QMimeTypePrivate data;-
219 data.name = name;-
220-
221-
222-
223-
224 return
executed 5482 times by 2 tests: return QMimeType(data);
Executed by:
  • tst_QDebug
  • tst_QMimeDatabase
QMimeType(data);
executed 5482 times by 2 tests: return QMimeType(data);
Executed by:
  • tst_QDebug
  • tst_QMimeDatabase
5482
225}-
226-
227QMimeType QMimeBinaryProvider::mimeTypeForName(const QString &name)-
228{-
229 checkCache();-
230 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
231 loadMimeTypeList();
executed 7 times by 2 tests: loadMimeTypeList();
Executed by:
  • tst_QDebug
  • tst_QMimeDatabase
7
232 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
233 return
executed 8 times by 1 test: return QMimeType();
Executed by:
  • tst_QMimeDatabase
QMimeType();
executed 8 times by 1 test: return QMimeType();
Executed by:
  • tst_QMimeDatabase
8
234 return
executed 2144 times by 2 tests: return mimeTypeForNameUnchecked(name);
Executed by:
  • tst_QDebug
  • tst_QMimeDatabase
mimeTypeForNameUnchecked(name);
executed 2144 times by 2 tests: return mimeTypeForNameUnchecked(name);
Executed by:
  • tst_QDebug
  • tst_QMimeDatabase
2144
235}-
236-
237QStringList QMimeBinaryProvider::findByFileName(const QString &fileName, QString *foundSuffix)-
238{-
239 checkCache();-
240 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
241 return
executed 2 times by 1 test: return QStringList();
Executed by:
  • tst_QMimeDatabase
QStringList();
executed 2 times by 1 test: return QStringList();
Executed by:
  • tst_QMimeDatabase
2
242 const QString lowerFileName = fileName.toLower();-
243 QMimeGlobMatchResult result;-
244-
245 for (QForeachContainer<typename QtPrivate::remove_reference<decltype(m_cacheFiles)>::type> _container_((m_cacheFiles)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (CacheFile *cacheFile = *_container_.i; _container_.control; _container_.control = 0) {-
246 matchGlobList(result, cacheFile, cacheFile->getUint32(PosLiteralListOffset), fileName);-
247 matchGlobList(result, cacheFile, cacheFile->getUint32(PosGlobListOffset), fileName);-
248 const int reverseSuffixTreeOffset = cacheFile->getUint32(PosReverseSuffixTreeOffset);-
249 const int numRoots = cacheFile->getUint32(reverseSuffixTreeOffset);-
250 const int firstRootOffset = cacheFile->getUint32(reverseSuffixTreeOffset + 4);-
251 matchSuffixTree(result, cacheFile, numRoots, firstRootOffset, lowerFileName, fileName.length() - 1, false);-
252 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
253 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
254 }
executed 97 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
97
255 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
256 *
executed 8 times by 1 test: *foundSuffix = result.m_foundSuffix;
Executed by:
  • tst_QMimeDatabase
foundSuffix = result.m_foundSuffix;
executed 8 times by 1 test: *foundSuffix = result.m_foundSuffix;
Executed by:
  • tst_QMimeDatabase
8
257 return
executed 94 times by 1 test: return result.m_matchingMimeTypes;
Executed by:
  • tst_QMimeDatabase
result.m_matchingMimeTypes;
executed 94 times by 1 test: return result.m_matchingMimeTypes;
Executed by:
  • tst_QMimeDatabase
94
258}-
259-
260void QMimeBinaryProvider::matchGlobList(QMimeGlobMatchResult &result, CacheFile *cacheFile, int off, const QString &fileName)-
261{-
262 const int numGlobs = cacheFile->getUint32(off);-
263-
264 for (int i = 0; i < numGlobs
i < numGlobsDescription
TRUEevaluated 1602 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 194 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
; ++i) {
194-1602
265 const int globOffset = cacheFile->getUint32(off + 4 + 12 * i);-
266 const int mimeTypeOffset = cacheFile->getUint32(off + 4 + 12 * i + 4);-
267 const int flagsAndWeight = cacheFile->getUint32(off + 4 + 12 * i + 8);-
268 const int weight = flagsAndWeight & 0xff;-
269 const bool caseSensitive = flagsAndWeight & 0x100;-
270 const Qt::CaseSensitivity qtCaseSensitive = caseSensitive
caseSensitiveDescription
TRUEevaluated 94 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 1508 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
? Qt::CaseSensitive : Qt::CaseInsensitive;
94-1508
271 const QString pattern = QLatin1String(cacheFile->getCharStar(globOffset));-
272-
273 const char *mimeType = cacheFile->getCharStar(mimeTypeOffset);-
274-
275 QMimeGlobPattern glob(pattern, QString() , weight, qtCaseSensitive);-
276-
277-
278 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
279 result.addMatch(QLatin1String(mimeType), weight, pattern);
executed 16 times by 1 test: result.addMatch(QLatin1String(mimeType), weight, pattern);
Executed by:
  • tst_QMimeDatabase
16
280 }
executed 1602 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
1602
281}
executed 194 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
194
282-
283bool QMimeBinaryProvider::matchSuffixTree(QMimeGlobMatchResult &result, QMimeBinaryProvider::CacheFile *cacheFile, int numEntries, int firstOffset, const QString &fileName, int charPos, bool caseSensitiveCheck)-
284{-
285 QChar fileChar = fileName[charPos];-
286 int min = 0;-
287 int max = numEntries - 1;-
288 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
289 const int mid = (min + max) / 2;-
290 const int off = firstOffset + 12 * mid;-
291 const QChar ch = cacheFile->getUint32(off);-
292 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
293 min = mid + 1;
executed 586 times by 1 test: min = mid + 1;
Executed by:
  • tst_QMimeDatabase
586
294 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
295 max = mid - 1;
executed 339 times by 1 test: max = mid - 1;
Executed by:
  • tst_QMimeDatabase
339
296 else {-
297 --charPos;-
298 int numChildren = cacheFile->getUint32(off + 4);-
299 int childrenOffset = cacheFile->getUint32(off + 8);-
300 bool success = false;-
301 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
302 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
303 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
304 for (int i = 0; i < numChildren
i < numChildrenDescription
TRUEevaluated 190 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 57 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
; ++i) {
57-190
305 const int childOff = childrenOffset + 12 * i;-
306 const int mch = cacheFile->getUint32(childOff);-
307 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
308 break;
executed 124 times by 1 test: break;
Executed by:
  • tst_QMimeDatabase
124
309 const int mimeTypeOffset = cacheFile->getUint32(childOff + 4);-
310 const char *mimeType = cacheFile->getCharStar(mimeTypeOffset);-
311 const int flagsAndWeight = cacheFile->getUint32(childOff + 8);-
312 const int weight = flagsAndWeight & 0xff;-
313 const bool caseSensitive = flagsAndWeight & 0x100;-
314 if (caseSensitiveCheck
caseSensitiveCheckDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 62 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
|| !caseSensitive
!caseSensitiveDescription
TRUEevaluated 58 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
) {
4-62
315 result.addMatch(QLatin1String(mimeType), weight, QLatin1Char('*') + fileName.mid(charPos+1));-
316 success = true;-
317 }
executed 62 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
62
318 }
executed 66 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
66
319 }
executed 181 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
181
320 return
executed 384 times by 1 test: return success;
Executed by:
  • tst_QMimeDatabase
success;
executed 384 times by 1 test: return success;
Executed by:
  • tst_QMimeDatabase
384
321 }-
322 }-
323 return
executed 123 times by 1 test: return false;
Executed by:
  • tst_QMimeDatabase
false;
executed 123 times by 1 test: return false;
Executed by:
  • tst_QMimeDatabase
123
324}-
325-
326bool QMimeBinaryProvider::matchMagicRule(QMimeBinaryProvider::CacheFile *cacheFile, int numMatchlets, int firstOffset, const QByteArray &data)-
327{-
328 const char *dataPtr = data.constData();-
329 const int dataSize = data.size();-
330 for (int matchlet = 0; matchlet < numMatchlets
matchlet < numMatchletsDescription
TRUEevaluated 10116 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 5890 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
; ++matchlet) {
5890-10116
331 const int off = firstOffset + matchlet * 32;-
332 const int rangeStart = cacheFile->getUint32(off);-
333 const int rangeLength = cacheFile->getUint32(off + 4);-
334-
335 const int valueLength = cacheFile->getUint32(off + 12);-
336 const int valueOffset = cacheFile->getUint32(off + 16);-
337 const int maskOffset = cacheFile->getUint32(off + 20);-
338 const char *mask = maskOffset
maskOffsetDescription
TRUEevaluated 215 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 9901 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
? cacheFile->getCharStar(maskOffset) : __null;
215-9901
339-
340 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
341 continue;
executed 10071 times by 1 test: continue;
Executed by:
  • tst_QMimeDatabase
10071
342-
343 const int numChildren = cacheFile->getUint32(off + 24);-
344 const int firstChildOffset = cacheFile->getUint32(off + 28);-
345 if (numChildren == 0
numChildren == 0Description
TRUEevaluated 23 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 22 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
)
22-23
346 return
executed 23 times by 1 test: return true;
Executed by:
  • tst_QMimeDatabase
true;
executed 23 times by 1 test: return true;
Executed by:
  • tst_QMimeDatabase
23
347-
348 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
349 return
executed 4 times by 1 test: return true;
Executed by:
  • tst_QMimeDatabase
true;
executed 4 times by 1 test: return true;
Executed by:
  • tst_QMimeDatabase
4
350 }
executed 18 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
18
351 return
executed 5890 times by 1 test: return false;
Executed by:
  • tst_QMimeDatabase
false;
executed 5890 times by 1 test: return false;
Executed by:
  • tst_QMimeDatabase
5890
352}-
353-
354QMimeType QMimeBinaryProvider::findByMagic(const QByteArray &data, int *accuracyPtr)-
355{-
356 checkCache();-
357 for (QForeachContainer<typename QtPrivate::remove_reference<decltype(m_cacheFiles)>::type> _container_((m_cacheFiles)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (CacheFile *cacheFile = *_container_.i; _container_.control; _container_.control = 0) {-
358 const int magicListOffset = cacheFile->getUint32(PosMagicListOffset);-
359 const int numMatches = cacheFile->getUint32(magicListOffset);-
360-
361 const int firstMatchOffset = cacheFile->getUint32(magicListOffset + 8);-
362-
363 for (int i = 0; i < numMatches
i < numMatchesDescription
TRUEevaluated 5895 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 9 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
; ++i) {
9-5895
364 const int off = firstMatchOffset + i * 16;-
365 const int numMatchlets = cacheFile->getUint32(off + 8);-
366 const int firstMatchletOffset = cacheFile->getUint32(off + 12);-
367 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
368 const int mimeTypeOffset = cacheFile->getUint32(off + 4);-
369 const char *mimeType = cacheFile->getCharStar(mimeTypeOffset);-
370 *accuracyPtr = cacheFile->getUint32(off);-
371-
372-
373 return
executed 23 times by 1 test: return mimeTypeForNameUnchecked(QLatin1String(mimeType));
Executed by:
  • tst_QMimeDatabase
mimeTypeForNameUnchecked(QLatin1String(mimeType));
executed 23 times by 1 test: return mimeTypeForNameUnchecked(QLatin1String(mimeType));
Executed by:
  • tst_QMimeDatabase
23
374 }-
375 }
executed 5872 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
5872
376 }
executed 9 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
9
377 return
executed 9 times by 1 test: return QMimeType();
Executed by:
  • tst_QMimeDatabase
QMimeType();
executed 9 times by 1 test: return QMimeType();
Executed by:
  • tst_QMimeDatabase
9
378}-
379-
380QStringList QMimeBinaryProvider::parents(const QString &mime)-
381{-
382 checkCache();-
383 const QByteArray mimeStr = mime.toLatin1();-
384 QStringList result;-
385 for (QForeachContainer<typename QtPrivate::remove_reference<decltype(m_cacheFiles)>::type> _container_((m_cacheFiles)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (CacheFile *cacheFile = *_container_.i; _container_.control; _container_.control = 0) {-
386 const int parentListOffset = cacheFile->getUint32(PosParentListOffset);-
387 const int numEntries = cacheFile->getUint32(parentListOffset);-
388-
389 int begin = 0;-
390 int end = numEntries - 1;-
391 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
392 const int medium = (begin + end) / 2;-
393 const int off = parentListOffset + 4 + 8 * medium;-
394 const int mimeOffset = cacheFile->getUint32(off);-
395 const char *aMime = cacheFile->getCharStar(mimeOffset);-
396 const int cmp = qstrcmp(aMime, mimeStr);-
397 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
398 begin = medium + 1;-
399 }
executed 230 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
else if (cmp > 0
cmp > 0Description
TRUEevaluated 210 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 26 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
) {
26-230
400 end = medium - 1;-
401 }
executed 210 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
else {
210
402 const int parentsOffset = cacheFile->getUint32(off + 4);-
403 const int numParents = cacheFile->getUint32(parentsOffset);-
404 for (int i = 0; i < numParents
i < numParentsDescription
TRUEevaluated 34 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 26 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
; ++i) {
26-34
405 const int parentOffset = cacheFile->getUint32(parentsOffset + 4 + 4 * i);-
406 const char *aParent = cacheFile->getCharStar(parentOffset);-
407 result.append(QString::fromLatin1(aParent));-
408 }
executed 34 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
34
409 break;
executed 26 times by 1 test: break;
Executed by:
  • tst_QMimeDatabase
26
410 }-
411 }-
412 }
executed 60 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
60
413 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
414 const QString parent = fallbackParent(mime);-
415 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
416 result.append(parent);
executed 22 times by 1 test: result.append(parent);
Executed by:
  • tst_QMimeDatabase
22
417 }
executed 34 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
34
418 return
executed 60 times by 1 test: return result;
Executed by:
  • tst_QMimeDatabase
result;
executed 60 times by 1 test: return result;
Executed by:
  • tst_QMimeDatabase
60
419}-
420-
421QString QMimeBinaryProvider::resolveAlias(const QString &name)-
422{-
423 checkCache();-
424 const QByteArray input = name.toLatin1();-
425 for (QForeachContainer<typename QtPrivate::remove_reference<decltype(m_cacheFiles)>::type> _container_((m_cacheFiles)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (CacheFile *cacheFile = *_container_.i; _container_.control; _container_.control = 0) {-
426 const int aliasListOffset = cacheFile->getUint32(PosAliasListOffset);-
427 const int numEntries = cacheFile->getUint32(aliasListOffset);-
428 int begin = 0;-
429 int end = numEntries - 1;-
430 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
431 const int medium = (begin + end) / 2;-
432 const int off = aliasListOffset + 4 + 8 * medium;-
433 const int aliasOffset = cacheFile->getUint32(off);-
434 const char *alias = cacheFile->getCharStar(aliasOffset);-
435 const int cmp = qstrcmp(alias, input);-
436 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
437 begin = medium + 1;-
438 }
executed 8566 times by 2 tests: end of block
Executed by:
  • tst_QDebug
  • tst_QMimeDatabase
else if (cmp > 0
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
439 end = medium - 1;-
440 }
executed 7995 times by 2 tests: end of block
Executed by:
  • tst_QDebug
  • tst_QMimeDatabase
else {
7995
441 const int mimeOffset = cacheFile->getUint32(off + 4);-
442 const char *mimeType = cacheFile->getCharStar(mimeOffset);-
443 return
executed 9 times by 1 test: return QLatin1String(mimeType);
Executed by:
  • tst_QMimeDatabase
QLatin1String(mimeType);
executed 9 times by 1 test: return QLatin1String(mimeType);
Executed by:
  • tst_QMimeDatabase
9
444 }-
445 }-
446 }
executed 2180 times by 2 tests: end of block
Executed by:
  • tst_QDebug
  • tst_QMimeDatabase
2180
447-
448 return
executed 2169 times by 2 tests: return name;
Executed by:
  • tst_QDebug
  • tst_QMimeDatabase
name;
executed 2169 times by 2 tests: return name;
Executed by:
  • tst_QDebug
  • tst_QMimeDatabase
2169
449}-
450-
451QStringList QMimeBinaryProvider::listAliases(const QString &name)-
452{-
453 checkCache();-
454 QStringList result;-
455 const QByteArray input = name.toLatin1();-
456 for (QForeachContainer<typename QtPrivate::remove_reference<decltype(m_cacheFiles)>::type> _container_((m_cacheFiles)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (CacheFile *cacheFile = *_container_.i; _container_.control; _container_.control = 0) {-
457 const int aliasListOffset = cacheFile->getUint32(PosAliasListOffset);-
458 const int numEntries = cacheFile->getUint32(aliasListOffset);-
459 for (int pos = 0; pos < numEntries
pos < numEntriesDescription
TRUEevaluated 776 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
; ++pos) {
4-776
460 const int off = aliasListOffset + 4 + 8 * pos;-
461 const int mimeOffset = cacheFile->getUint32(off + 4);-
462 const char *mimeType = cacheFile->getCharStar(mimeOffset);-
463-
464 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
465 const int aliasOffset = cacheFile->getUint32(off);-
466 const char *alias = cacheFile->getCharStar(aliasOffset);-
467 result.append(QString::fromLatin1(alias));-
468 }
executed 4 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
4
469 }
executed 776 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
776
470 }
executed 4 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
4
471 return
executed 4 times by 1 test: return result;
Executed by:
  • tst_QMimeDatabase
result;
executed 4 times by 1 test: return result;
Executed by:
  • tst_QMimeDatabase
4
472}-
473-
474void QMimeBinaryProvider::loadMimeTypeList()-
475{-
476 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
477 m_mimetypeListLoaded = true;-
478 m_mimetypeNames.clear();-
479-
480-
481 const QStringList typesFilenames = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QLatin1String("mime/types"));-
482 for (QForeachContainer<typename QtPrivate::remove_reference<decltype(typesFilenames)>::type> _container_((typesFilenames)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (const QString &typeFilename = *_container_.i; _container_.control; _container_.control = 0) {-
483 QFile file(typeFilename);-
484 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
485 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
486 QByteArray line = file.readLine();-
487 line.chop(1);-
488 m_mimetypeNames.insert(QString::fromLatin1(line.constData(), line.size()));-
489 }
executed 4698 times by 2 tests: end of block
Executed by:
  • tst_QDebug
  • tst_QMimeDatabase
4698
490 }
executed 10 times by 2 tests: end of block
Executed by:
  • tst_QDebug
  • tst_QMimeDatabase
10
491 }
executed 10 times by 2 tests: end of block
Executed by:
  • tst_QDebug
  • tst_QMimeDatabase
10
492 }
executed 7 times by 2 tests: end of block
Executed by:
  • tst_QDebug
  • tst_QMimeDatabase
7
493}
executed 12 times by 2 tests: end of block
Executed by:
  • tst_QDebug
  • tst_QMimeDatabase
12
494-
495QList<QMimeType> QMimeBinaryProvider::allMimeTypes()-
496{-
497 QList<QMimeType> result;-
498 loadMimeTypeList();-
499 result.reserve(m_mimetypeNames.count());-
500-
501 for (QSet<QString>::const_iterator it = m_mimetypeNames.constBegin();-
502 it != m_mimetypeNames.constEnd()
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
; ++it)
5-3315
503 result.append(mimeTypeForNameUnchecked(*it));
executed 3315 times by 1 test: result.append(mimeTypeForNameUnchecked(*it));
Executed by:
  • tst_QMimeDatabase
3315
504-
505 return
executed 5 times by 1 test: return result;
Executed by:
  • tst_QMimeDatabase
result;
executed 5 times by 1 test: return result;
Executed by:
  • tst_QMimeDatabase
5
506}-
507-
508void QMimeBinaryProvider::loadMimeTypePrivate(QMimeTypePrivate &data)-
509{-
510-
511-
512-
513-
514 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
515 return;
executed 10 times by 1 test: return;
Executed by:
  • tst_QMimeDatabase
10
516 data.loaded = true;-
517-
518-
519 const QString file = data.name + QLatin1String(".xml");-
520-
521 QStringList mimeFiles = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QString::fromLatin1("mime/") + file.toLower());-
522 if (mimeFiles.isEmpty()
mimeFiles.isEmpty()Description
TRUEnever evaluated
FALSEevaluated 18 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
) {
0-18
523 mimeFiles = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QString::fromLatin1("mime/") + file);-
524 }
never executed: end of block
0
525 if (mimeFiles.isEmpty()
mimeFiles.isEmpty()Description
TRUEnever evaluated
FALSEevaluated 18 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
) {
0-18
526 QMessageLogger(__FILE__, 571, __PRETTY_FUNCTION__).warning() << "No file found for" << file << ", even though update-mime-info said it would exist.\n"-
527 "Either it was just removed, or the directory doesn't have executable permission..."-
528 << QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QLatin1String("mime"), QStandardPaths::LocateDirectory);-
529 return;
never executed: return;
0
530 }-
531-
532 QString comment;-
533 QString mainPattern;-
534 const QString preferredLanguage = QLocale().name();-
535-
536 for (QStringList::const_reverse_iterator it = mimeFiles.crbegin(), end = mimeFiles.crend(); it != end
it != endDescription
TRUEevaluated 18 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 18 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
; ++it) {
18
537 QFile qfile(*it);-
538 if (!qfile.open(QFile::ReadOnly)
!qfile.open(QFile::ReadOnly)Description
TRUEnever evaluated
FALSEevaluated 18 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
)
0-18
539 continue;
never executed: continue;
0
540-
541 QXmlStreamReader xml(&qfile);-
542 if (xml.readNextStartElement()
xml.readNextStartElement()Description
TRUEevaluated 18 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEnever evaluated
) {
0-18
543 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
544 continue;
never executed: continue;
0
545 }-
546 const QStringRef name = xml.attributes().value(QLatin1String("type"));-
547 if (name.isEmpty()
name.isEmpty()Description
TRUEnever evaluated
FALSEevaluated 18 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
)
0-18
548 continue;
never executed: continue;
0
549 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
550 QMessageLogger(__FILE__, 595, __PRETTY_FUNCTION__).warning() << "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
551-
552 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
553 const QStringRef tag = xml.name();-
554 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
555 QString lang = xml.attributes().value(QLatin1String("xml:lang")).toString();-
556 const QString text = xml.readElementText();-
557 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
558 lang = QLatin1String("en_US");-
559 }
executed 18 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
18
560 data.localeComments.insert(lang, text);-
561 continue;
executed 746 times by 1 test: continue;
Executed by:
  • tst_QMimeDatabase
746
562 } else if (tag == QLatin1String("icon")
tag == QLatin1String("icon")Description
TRUEnever evaluated
FALSEevaluated 66 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
) {
0-66
563 data.iconName = xml.attributes().value(QLatin1String("name")).toString();-
564 }
never executed: end of block
else if (tag == QLatin1String("glob-deleteall")
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
565 data.globPatterns.clear();-
566 }
executed 1 time by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
else if (tag == QLatin1String("glob")
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
567 const QString pattern = xml.attributes().value(QLatin1String("pattern")).toString();-
568 if (mainPattern.isEmpty()
mainPattern.isEmpty()Description
TRUEevaluated 14 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 16 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
&& pattern.startsWith(QLatin1Char('*'))
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
569 mainPattern = pattern;-
570 }
executed 13 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
13
571 if (!data.globPatterns.contains(pattern)
!data.globPatt...tains(pattern)Description
TRUEevaluated 30 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEnever evaluated
)
0-30
572 data.globPatterns.append(pattern);
executed 30 times by 1 test: data.globPatterns.append(pattern);
Executed by:
  • tst_QMimeDatabase
30
573 }
executed 30 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
30
574 xml.skipCurrentElement();-
575 }
executed 66 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
66
576 ((!(xml.name() == QLatin1String("mime-type"))) ? qt_assert("xml.name() == QLatin1String(\"mime-type\")",__FILE__,621) : qt_noop());-
577 }
executed 18 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
18
578 }
executed 18 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
18
579-
580-
581-
582-
583 if (!mainPattern.isEmpty()
!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()
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.globPatterns.first() != mainPattern
data.globPatte...!= mainPatternDescription
TRUEnever evaluated
FALSEevaluated 12 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
)) {
0-13
584-
585 data.globPatterns.removeAll(mainPattern);-
586 data.globPatterns.prepend(mainPattern);-
587 }
executed 1 time by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
1
588}
executed 18 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
18
589-
590-
591QString QMimeBinaryProvider::iconForMime(CacheFile *cacheFile, int posListOffset, const QByteArray &inputMime)-
592{-
593 const int iconsListOffset = cacheFile->getUint32(posListOffset);-
594 const int numIcons = cacheFile->getUint32(iconsListOffset);-
595 int begin = 0;-
596 int end = numIcons - 1;-
597 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
598 const int medium = (begin + end) / 2;-
599 const int off = iconsListOffset + 4 + 8 * medium;-
600 const int mimeOffset = cacheFile->getUint32(off);-
601 const char *mime = cacheFile->getCharStar(mimeOffset);-
602 const int cmp = qstrcmp(mime, inputMime);-
603 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
604 begin = medium + 1;
executed 18 times by 1 test: begin = medium + 1;
Executed by:
  • tst_QMimeDatabase
18
605 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
606 end = medium - 1;
executed 14 times by 1 test: end = medium - 1;
Executed by:
  • tst_QMimeDatabase
14
607 else {-
608 const int iconOffset = cacheFile->getUint32(off + 4);-
609 return
executed 2 times by 1 test: return QLatin1String(cacheFile->getCharStar(iconOffset));
Executed by:
  • tst_QMimeDatabase
QLatin1String(cacheFile->getCharStar(iconOffset));
executed 2 times by 1 test: return QLatin1String(cacheFile->getCharStar(iconOffset));
Executed by:
  • tst_QMimeDatabase
2
610 }-
611 }-
612 return
executed 6 times by 1 test: return QString();
Executed by:
  • tst_QMimeDatabase
QString();
executed 6 times by 1 test: return QString();
Executed by:
  • tst_QMimeDatabase
6
613}-
614-
615void QMimeBinaryProvider::loadIcon(QMimeTypePrivate &data)-
616{-
617 checkCache();-
618 const QByteArray inputMime = data.name.toLatin1();-
619 for (QForeachContainer<typename QtPrivate::remove_reference<decltype(m_cacheFiles)>::type> _container_((m_cacheFiles)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (CacheFile *cacheFile = *_container_.i; _container_.control; _container_.control = 0) {-
620 const QString icon = iconForMime(cacheFile, PosIconsListOffset, inputMime);-
621 if (!icon.isEmpty()
!icon.isEmpty()Description
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
) {
0-4
622 data.iconName = icon;-
623 return;
never executed: return;
0
624 }-
625 }
executed 4 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
4
626}
executed 4 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
4
627-
628void QMimeBinaryProvider::loadGenericIcon(QMimeTypePrivate &data)-
629{-
630 checkCache();-
631 const QByteArray inputMime = data.name.toLatin1();-
632 for (QForeachContainer<typename QtPrivate::remove_reference<decltype(m_cacheFiles)>::type> _container_((m_cacheFiles)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (CacheFile *cacheFile = *_container_.i; _container_.control; _container_.control = 0) {-
633 const QString icon = iconForMime(cacheFile, PosGenericIconsListOffset, inputMime);-
634 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
635 data.genericIconName = icon;-
636 return;
executed 2 times by 1 test: return;
Executed by:
  • tst_QMimeDatabase
2
637 }-
638 }
executed 2 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
2
639}
executed 2 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
2
640-
641-
642-
643QMimeXMLProvider::QMimeXMLProvider(QMimeDatabasePrivate *db)-
644 : QMimeProviderBase(db), m_loaded(false)-
645{-
646 initResources();-
647}
executed 2 times by 2 tests: end of block
Executed by:
  • tst_QMimeDatabase
  • tst_qmimetype
2
648-
649QMimeXMLProvider::~QMimeXMLProvider()-
650{-
651}-
652-
653bool QMimeXMLProvider::isValid()-
654{-
655 return
never executed: return true;
true;
never executed: return true;
0
656}-
657-
658QMimeType QMimeXMLProvider::mimeTypeForName(const QString &name)-
659{-
660 ensureLoaded();-
661-
662 return
executed 2183 times by 1 test: return m_nameMimeTypeMap.value(name);
Executed by:
  • tst_QMimeDatabase
m_nameMimeTypeMap.value(name);
executed 2183 times by 1 test: return m_nameMimeTypeMap.value(name);
Executed by:
  • tst_QMimeDatabase
2183
663}-
664-
665QStringList QMimeXMLProvider::findByFileName(const QString &fileName, QString *foundSuffix)-
666{-
667 ensureLoaded();-
668-
669 const QStringList matchingMimeTypes = m_mimeTypeGlobs.matchingGlobs(fileName, foundSuffix);-
670 return
executed 96 times by 1 test: return matchingMimeTypes;
Executed by:
  • tst_QMimeDatabase
matchingMimeTypes;
executed 96 times by 1 test: return matchingMimeTypes;
Executed by:
  • tst_QMimeDatabase
96
671}-
672-
673QMimeType QMimeXMLProvider::findByMagic(const QByteArray &data, int *accuracyPtr)-
674{-
675 ensureLoaded();-
676-
677 QString candidate;-
678-
679 for (QForeachContainer<typename QtPrivate::remove_reference<decltype(m_magicMatchers)>::type> _container_((m_magicMatchers)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (const QMimeMagicRuleMatcher &matcher = *_container_.i; _container_.control; _container_.control = 0) {-
680 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
681 const int priority = matcher.priority();-
682 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
683 *accuracyPtr = priority;-
684 candidate = matcher.mimetype();-
685 }
executed 23 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
23
686 }
executed 37 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
37
687 }
executed 11040 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
11040
688 return
executed 32 times by 1 test: return mimeTypeForName(candidate);
Executed by:
  • tst_QMimeDatabase
mimeTypeForName(candidate);
executed 32 times by 1 test: return mimeTypeForName(candidate);
Executed by:
  • tst_QMimeDatabase
32
689}-
690-
691void QMimeXMLProvider::ensureLoaded()-
692{-
693 if (!m_loaded
!m_loadedDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 4556 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
|| shouldCheck()
shouldCheck()Description
TRUEevaluated 56 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 4500 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
) {
1-4556
694 bool fdoXmlFound = false;-
695 QStringList allFiles;-
696-
697 const QStringList packageDirs = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QLatin1String("mime/packages"), QStandardPaths::LocateDirectory);-
698-
699 for (QForeachContainer<typename QtPrivate::remove_reference<decltype(packageDirs)>::type> _container_((packageDirs)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (const QString &packageDir = *_container_.i; _container_.control; _container_.control = 0) {-
700 QDir dir(packageDir);-
701 const QStringList files = dir.entryList(QDir::Files | QDir::NoDotAndDotDot);-
702-
703 if (!fdoXmlFound
!fdoXmlFoundDescription
TRUEevaluated 88 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEnever evaluated
)
0-88
704 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
705 QStringList::const_iterator endIt(files.constEnd());-
706 for (QStringList::const_iterator it(files.constBegin()); it != endIt
it != endItDescription
TRUEevaluated 261 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEevaluated 88 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
; ++it) {
88-261
707 allFiles.append(packageDir + QLatin1Char('/') + *it);-
708 }
executed 261 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
261
709 }
executed 88 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
88
710-
711 if (!fdoXmlFound
!fdoXmlFoundDescription
TRUEnever evaluated
FALSEevaluated 57 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
) {
0-57
712-
713 allFiles.prepend(QLatin1String(":/qt-project.org/qmime/freedesktop.org.xml"));-
714 }
never executed: end of block
0
715-
716 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
717 return;
executed 52 times by 1 test: return;
Executed by:
  • tst_QMimeDatabase
52
718 m_allFiles = allFiles;-
719-
720 m_nameMimeTypeMap.clear();-
721 m_aliases.clear();-
722 m_parents.clear();-
723 m_mimeTypeGlobs.clear();-
724 m_magicMatchers.clear();-
725-
726-
727-
728 for (QForeachContainer<typename QtPrivate::remove_reference<decltype(allFiles)>::type> _container_((allFiles)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (const QString &file = *_container_.i; _container_.control; _container_.control = 0)-
729 load(file);
executed 17 times by 1 test: load(file);
Executed by:
  • tst_QMimeDatabase
17
730 }
executed 5 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
5
731}
executed 4505 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
4505
732-
733void QMimeXMLProvider::load(const QString &fileName)-
734{-
735 QString errorMessage;-
736 if (!load(fileName, &errorMessage)
!load(fileName, &errorMessage)Description
TRUEnever evaluated
FALSEevaluated 17 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
)
0-17
737 QMessageLogger(__FILE__, 797, __PRETTY_FUNCTION__).warning("QMimeDatabase: Error loading %s\n%s", QString(fileName).toLocal8Bit().constData(), QString(errorMessage).toLocal8Bit().constData());
never executed: QMessageLogger(__FILE__, 797, __PRETTY_FUNCTION__).warning("QMimeDatabase: Error loading %s\n%s", QString(fileName).toLocal8Bit().constData(), QString(errorMessage).toLocal8Bit().constData());
0
738}
executed 17 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
17
739-
740bool QMimeXMLProvider::load(const QString &fileName, QString *errorMessage)-
741{-
742 m_loaded = true;-
743-
744 QFile file(fileName);-
745 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
746 if (errorMessage
errorMessageDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
747 *
never executed: *errorMessage = QString::fromLatin1("Cannot open %1: %2").arg(fileName, file.errorString());
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
748 return
never executed: return false;
false;
never executed: return false;
0
749 }-
750-
751 if (errorMessage
errorMessageDescription
TRUEevaluated 17 times by 1 test
Evaluated by:
  • tst_QMimeDatabase
FALSEnever evaluated
)
0-17
752 errorMessage->clear();
executed 17 times by 1 test: errorMessage->clear();
Executed by:
  • tst_QMimeDatabase
17
753-
754 QMimeTypeParser parser(*this);-
755 return
executed 17 times by 1 test: return parser.parse(&file, fileName, errorMessage);
Executed by:
  • tst_QMimeDatabase
parser.parse(&file, fileName, errorMessage);
executed 17 times by 1 test: return parser.parse(&file, fileName, errorMessage);
Executed by:
  • tst_QMimeDatabase
17
756}-
757-
758void QMimeXMLProvider::addGlobPattern(const QMimeGlobPattern &glob)-
759{-
760 m_mimeTypeGlobs.addGlob(glob);-
761}
executed 4136 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
4136
762-
763void QMimeXMLProvider::addMimeType(const QMimeType &mt)-
764{-
765 m_nameMimeTypeMap.insert(mt.name(), mt);-
766}
executed 3319 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
3319
767-
768QStringList QMimeXMLProvider::parents(const QString &mime)-
769{-
770 ensureLoaded();-
771 QStringList result = m_parents.value(mime);-
772 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
773 const QString parent = fallbackParent(mime);-
774 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
775 result.append(parent);
executed 22 times by 1 test: result.append(parent);
Executed by:
  • tst_QMimeDatabase
22
776 }
executed 34 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
34
777 return
executed 60 times by 1 test: return result;
Executed by:
  • tst_QMimeDatabase
result;
executed 60 times by 1 test: return result;
Executed by:
  • tst_QMimeDatabase
60
778}-
779-
780void QMimeXMLProvider::addParent(const QString &child, const QString &parent)-
781{-
782 m_parents[child].append(parent);-
783}
executed 1560 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
1560
784-
785QStringList QMimeXMLProvider::listAliases(const QString &name)-
786{-
787 ensureLoaded();-
788-
789 return
executed 4 times by 1 test: return m_aliases.keys(name);
Executed by:
  • tst_QMimeDatabase
m_aliases.keys(name);
executed 4 times by 1 test: return m_aliases.keys(name);
Executed by:
  • tst_QMimeDatabase
4
790}-
791-
792QString QMimeXMLProvider::resolveAlias(const QString &name)-
793{-
794 ensureLoaded();-
795 return
executed 2177 times by 1 test: return m_aliases.value(name, name);
Executed by:
  • tst_QMimeDatabase
m_aliases.value(name, name);
executed 2177 times by 1 test: return m_aliases.value(name, name);
Executed by:
  • tst_QMimeDatabase
2177
796}-
797-
798void QMimeXMLProvider::addAlias(const QString &alias, const QString &name)-
799{-
800 m_aliases.insert(alias, name);-
801}
executed 975 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
975
802-
803QList<QMimeType> QMimeXMLProvider::allMimeTypes()-
804{-
805 ensureLoaded();-
806 return
executed 5 times by 1 test: return m_nameMimeTypeMap.values();
Executed by:
  • tst_QMimeDatabase
m_nameMimeTypeMap.values();
executed 5 times by 1 test: return m_nameMimeTypeMap.values();
Executed by:
  • tst_QMimeDatabase
5
807}-
808-
809void QMimeXMLProvider::addMagicMatcher(const QMimeMagicRuleMatcher &matcher)-
810{-
811 m_magicMatchers.append(matcher);-
812}
executed 1733 times by 1 test: end of block
Executed by:
  • tst_QMimeDatabase
1733
813-
814-
Switch to Source codePreprocessed file

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