Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/corelib/mimetypes/qmimeprovider.cpp |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||||||||||||||
2 | - | |||||||||||||||||||||||||
3 | - | |||||||||||||||||||||||||
4 | - | |||||||||||||||||||||||||
5 | - | |||||||||||||||||||||||||
6 | static 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:
| 2 | ||||||||||||||||||||||||
10 | - | |||||||||||||||||||||||||
11 | - | |||||||||||||||||||||||||
12 | - | |||||||||||||||||||||||||
13 | static QString fallbackParent(const QString &mimeTypeName) | - | ||||||||||||||||||||||||
14 | { | - | ||||||||||||||||||||||||
15 | const QString myGroup = mimeTypeName.left(mimeTypeName.indexOf(QLatin1Char('/'))); | - | ||||||||||||||||||||||||
16 | - | |||||||||||||||||||||||||
17 | if (myGroup == QLatin1String("text")
| 8-40 | ||||||||||||||||||||||||
18 | return executed 8 times by 1 test: QLatin1String("text/plain");return QLatin1String("text/plain"); Executed by:
executed 8 times by 1 test: return QLatin1String("text/plain"); Executed by:
| 8 | ||||||||||||||||||||||||
19 | - | |||||||||||||||||||||||||
20 | if (myGroup != QLatin1String("inode")
| 8-52 | ||||||||||||||||||||||||
21 | - | |||||||||||||||||||||||||
22 | myGroup != QLatin1String("all")
| 0-52 | ||||||||||||||||||||||||
23 | && mimeTypeName != QLatin1String("application/octet-stream")
| 16-36 | ||||||||||||||||||||||||
24 | return executed 36 times by 1 test: QLatin1String("application/octet-stream");return QLatin1String("application/octet-stream"); Executed by:
executed 36 times by 1 test: return QLatin1String("application/octet-stream"); Executed by:
| 36 | ||||||||||||||||||||||||
25 | } | - | ||||||||||||||||||||||||
26 | return executed 24 times by 1 test: QString();return QString(); Executed by:
executed 24 times by 1 test: return QString(); Executed by:
| 24 | ||||||||||||||||||||||||
27 | } | - | ||||||||||||||||||||||||
28 | - | |||||||||||||||||||||||||
29 | QMimeProviderBase::QMimeProviderBase(QMimeDatabasePrivate *db) | - | ||||||||||||||||||||||||
30 | : m_db(db) | - | ||||||||||||||||||||||||
31 | { | - | ||||||||||||||||||||||||
32 | } executed 6 times by 3 tests: end of block Executed by:
| 6 | ||||||||||||||||||||||||
33 | - | |||||||||||||||||||||||||
34 | __attribute__((visibility("default"))) int qmime_secondsBetweenChecks = 5; | - | ||||||||||||||||||||||||
35 | - | |||||||||||||||||||||||||
36 | bool QMimeProviderBase::shouldCheck() | - | ||||||||||||||||||||||||
37 | { | - | ||||||||||||||||||||||||
38 | if (m_lastCheck.isValid()
| 4-9085 | ||||||||||||||||||||||||
39 | return executed 8977 times by 2 tests: false;return false; Executed by:
executed 8977 times by 2 tests: return false; Executed by:
| 8977 | ||||||||||||||||||||||||
40 | m_lastCheck.start(); | - | ||||||||||||||||||||||||
41 | return executed 112 times by 3 tests: true;return true; Executed by:
executed 112 times by 3 tests: return true; Executed by:
| 112 | ||||||||||||||||||||||||
42 | } | - | ||||||||||||||||||||||||
43 | - | |||||||||||||||||||||||||
44 | QMimeBinaryProvider::QMimeBinaryProvider(QMimeDatabasePrivate *db) | - | ||||||||||||||||||||||||
45 | : QMimeProviderBase(db), m_mimetypeListLoaded(false) | - | ||||||||||||||||||||||||
46 | { | - | ||||||||||||||||||||||||
47 | } executed 4 times by 3 tests: end of block Executed by:
| 4 | ||||||||||||||||||||||||
48 | - | |||||||||||||||||||||||||
49 | - | |||||||||||||||||||||||||
50 | - | |||||||||||||||||||||||||
51 | - | |||||||||||||||||||||||||
52 | - | |||||||||||||||||||||||||
53 | struct QMimeBinaryProvider::CacheFile | - | ||||||||||||||||||||||||
54 | { | - | ||||||||||||||||||||||||
55 | CacheFile(const QString &fileName); | - | ||||||||||||||||||||||||
56 | ~CacheFile(); | - | ||||||||||||||||||||||||
57 | - | |||||||||||||||||||||||||
58 | bool isValid() const { return executed 3 times by 2 tests: m_valid;return m_valid; Executed by:
executed 3 times by 2 tests: }return m_valid; Executed by:
| 3 | ||||||||||||||||||||||||
59 | inline quint16 getUint16(int offset) const | - | ||||||||||||||||||||||||
60 | { | - | ||||||||||||||||||||||||
61 | return executed 12 times by 2 tests: qFromBigEndian(*reinterpret_cast<quint16 *>(data + offset));return qFromBigEndian(*reinterpret_cast<quint16 *>(data + offset)); Executed by:
executed 12 times by 2 tests: return qFromBigEndian(*reinterpret_cast<quint16 *>(data + offset)); Executed by:
| 12 | ||||||||||||||||||||||||
62 | } | - | ||||||||||||||||||||||||
63 | inline quint32 getUint32(int offset) const | - | ||||||||||||||||||||||||
64 | { | - | ||||||||||||||||||||||||
65 | return executed 92955 times by 2 tests: qFromBigEndian(*reinterpret_cast<quint32 *>(data + offset));return qFromBigEndian(*reinterpret_cast<quint32 *>(data + offset)); Executed by:
executed 92955 times by 2 tests: return qFromBigEndian(*reinterpret_cast<quint32 *>(data + offset)); Executed by:
| 92955 | ||||||||||||||||||||||||
66 | } | - | ||||||||||||||||||||||||
67 | inline const char *getCharStar(int offset) const | - | ||||||||||||||||||||||||
68 | { | - | ||||||||||||||||||||||||
69 | return executed 31519 times by 2 tests: reinterpret_cast<const char *>(data + offset);return reinterpret_cast<const char *>(data + offset); Executed by:
executed 31519 times by 2 tests: return reinterpret_cast<const char *>(data + offset); Executed by:
| 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 | - | |||||||||||||||||||||||||
80 | QMimeBinaryProvider::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:
| 3 | ||||||||||||||||||||||||
85 | - | |||||||||||||||||||||||||
86 | QMimeBinaryProvider::CacheFile::~CacheFile() | - | ||||||||||||||||||||||||
87 | { | - | ||||||||||||||||||||||||
88 | } | - | ||||||||||||||||||||||||
89 | - | |||||||||||||||||||||||||
90 | bool QMimeBinaryProvider::CacheFile::load() | - | ||||||||||||||||||||||||
91 | { | - | ||||||||||||||||||||||||
92 | if (!file.open(QIODevice::ReadOnly)
| 0-6 | ||||||||||||||||||||||||
93 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||||||||||||||
94 | data = file.map(0, file.size()); | - | ||||||||||||||||||||||||
95 | if (data
| 0-6 | ||||||||||||||||||||||||
96 | const int major = getUint16(0); | - | ||||||||||||||||||||||||
97 | const int minor = getUint16(2); | - | ||||||||||||||||||||||||
98 | m_valid = (major == 1
| 0-6 | ||||||||||||||||||||||||
99 | } executed 6 times by 2 tests: end of block Executed by:
| 6 | ||||||||||||||||||||||||
100 | m_mtime = QFileInfo(file).lastModified(); | - | ||||||||||||||||||||||||
101 | return executed 6 times by 2 tests: m_valid;return m_valid; Executed by:
executed 6 times by 2 tests: return m_valid; Executed by:
| 6 | ||||||||||||||||||||||||
102 | } | - | ||||||||||||||||||||||||
103 | - | |||||||||||||||||||||||||
104 | bool QMimeBinaryProvider::CacheFile::reload() | - | ||||||||||||||||||||||||
105 | { | - | ||||||||||||||||||||||||
106 | - | |||||||||||||||||||||||||
107 | m_valid = false; | - | ||||||||||||||||||||||||
108 | if (file.isOpen()
| 0-3 | ||||||||||||||||||||||||
109 | file.close(); | - | ||||||||||||||||||||||||
110 | } executed 3 times by 1 test: end of block Executed by:
| 3 | ||||||||||||||||||||||||
111 | data = 0; | - | ||||||||||||||||||||||||
112 | return executed 3 times by 1 test: load();return load(); Executed by:
executed 3 times by 1 test: return load(); Executed by:
| 3 | ||||||||||||||||||||||||
113 | } | - | ||||||||||||||||||||||||
114 | - | |||||||||||||||||||||||||
115 | QMimeBinaryProvider::CacheFile *QMimeBinaryProvider::CacheFileList::findCacheFile(const QString &fileName) const | - | ||||||||||||||||||||||||
116 | { | - | ||||||||||||||||||||||||
117 | for (const_iterator it = begin(); it != end()
| 3 | ||||||||||||||||||||||||
118 | if ((*
| 1-2 | ||||||||||||||||||||||||
119 | return executed 2 times by 1 test: *it;return *it; Executed by:
executed 2 times by 1 test: return *it; Executed by:
| 2 | ||||||||||||||||||||||||
120 | } executed 1 time by 1 test: end of block Executed by:
| 1 | ||||||||||||||||||||||||
121 | return executed 3 times by 2 tests: 0;return 0; Executed by:
executed 3 times by 2 tests: return 0; Executed by:
| 3 | ||||||||||||||||||||||||
122 | } | - | ||||||||||||||||||||||||
123 | - | |||||||||||||||||||||||||
124 | QMimeBinaryProvider::~QMimeBinaryProvider() | - | ||||||||||||||||||||||||
125 | { | - | ||||||||||||||||||||||||
126 | qDeleteAll(m_cacheFiles); | - | ||||||||||||||||||||||||
127 | } executed 4 times by 4 tests: end of block Executed by:
| 4 | ||||||||||||||||||||||||
128 | - | |||||||||||||||||||||||||
129 | - | |||||||||||||||||||||||||
130 | enum { | - | ||||||||||||||||||||||||
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 | - | |||||||||||||||||||||||||
142 | bool QMimeBinaryProvider::isValid() | - | ||||||||||||||||||||||||
143 | { | - | ||||||||||||||||||||||||
144 | - | |||||||||||||||||||||||||
145 | if (!qEnvironmentVariableIsEmpty("QT_NO_MIME_CACHE")
| 1-3 | ||||||||||||||||||||||||
146 | return executed 1 time by 1 test: false;return false; Executed by:
executed 1 time by 1 test: return false; Executed by:
| 1 | ||||||||||||||||||||||||
147 | - | |||||||||||||||||||||||||
148 | ((!(m_cacheFiles.isEmpty())) ? qt_assert("m_cacheFiles.isEmpty()",__FILE__,193) : qt_noop()); | - | ||||||||||||||||||||||||
149 | checkCache(); | - | ||||||||||||||||||||||||
150 | - | |||||||||||||||||||||||||
151 | if (m_cacheFiles.count() > 1
| 0-3 | ||||||||||||||||||||||||
152 | return never executed: true;return true; never executed: return true; | 0 | ||||||||||||||||||||||||
153 | if (m_cacheFiles.isEmpty()
| 1-2 | ||||||||||||||||||||||||
154 | return executed 1 time by 1 test: false;return false; Executed by:
executed 1 time by 1 test: return false; Executed by:
| 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: foundFile != localCacheFile;return foundFile != localCacheFile; Executed by:
executed 2 times by 2 tests: return foundFile != localCacheFile; Executed by:
| 2 | ||||||||||||||||||||||||
161 | - | |||||||||||||||||||||||||
162 | - | |||||||||||||||||||||||||
163 | - | |||||||||||||||||||||||||
164 | } | - | ||||||||||||||||||||||||
165 | - | |||||||||||||||||||||||||
166 | bool QMimeBinaryProvider::CacheFileList::checkCacheChanged() | - | ||||||||||||||||||||||||
167 | { | - | ||||||||||||||||||||||||
168 | bool somethingChanged = false; | - | ||||||||||||||||||||||||
169 | QMutableListIterator<CacheFile *> it(*this); | - | ||||||||||||||||||||||||
170 | while (it.hasNext()
| 56-78 | ||||||||||||||||||||||||
171 | CacheFile *cacheFile = it.next(); | - | ||||||||||||||||||||||||
172 | QFileInfo fileInfo(cacheFile->file); | - | ||||||||||||||||||||||||
173 | if (!fileInfo.exists()
| 1-77 | ||||||||||||||||||||||||
174 | delete cacheFile; | - | ||||||||||||||||||||||||
175 | it.remove(); | - | ||||||||||||||||||||||||
176 | somethingChanged = true; | - | ||||||||||||||||||||||||
177 | } executed 1 time by 1 test: else if (fileInfo.lastModified() > cacheFile->m_mtimeend of block Executed by:
| 1-74 | ||||||||||||||||||||||||
178 | if (!cacheFile->reload()
| 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:
| 3 | ||||||||||||||||||||||||
184 | } executed 78 times by 1 test: end of block Executed by:
| 78 | ||||||||||||||||||||||||
185 | return executed 56 times by 3 tests: somethingChanged;return somethingChanged; Executed by:
executed 56 times by 3 tests: return somethingChanged; Executed by:
| 56 | ||||||||||||||||||||||||
186 | } | - | ||||||||||||||||||||||||
187 | - | |||||||||||||||||||||||||
188 | void QMimeBinaryProvider::checkCache() | - | ||||||||||||||||||||||||
189 | { | - | ||||||||||||||||||||||||
190 | if (!shouldCheck()
| 56-4477 | ||||||||||||||||||||||||
191 | return; executed 4477 times by 2 tests: return; Executed by:
| 4477 | ||||||||||||||||||||||||
192 | - | |||||||||||||||||||||||||
193 | - | |||||||||||||||||||||||||
194 | if (m_cacheFiles.checkCacheChanged()
| 4-52 | ||||||||||||||||||||||||
195 | m_mimetypeListLoaded = false; executed 4 times by 1 test: m_mimetypeListLoaded = false; Executed by:
| 4 | ||||||||||||||||||||||||
196 | - | |||||||||||||||||||||||||
197 | - | |||||||||||||||||||||||||
198 | const QStringList cacheFileNames = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QLatin1String("mime/mime.cache")); | - | ||||||||||||||||||||||||
199 | if (cacheFileNames != m_cacheFileNames
| 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
| 2-3 | ||||||||||||||||||||||||
203 | - | |||||||||||||||||||||||||
204 | cacheFile = new CacheFile(cacheFileName); | - | ||||||||||||||||||||||||
205 | if (cacheFile->isValid()
| 0-3 | ||||||||||||||||||||||||
206 | m_cacheFiles.append(cacheFile); executed 3 times by 2 tests: m_cacheFiles.append(cacheFile); Executed by:
| 3 | ||||||||||||||||||||||||
207 | else | - | ||||||||||||||||||||||||
208 | delete cacheFile; never executed: delete cacheFile; | 0 | ||||||||||||||||||||||||
209 | } | - | ||||||||||||||||||||||||
210 | } executed 5 times by 2 tests: end of block Executed by:
| 5 | ||||||||||||||||||||||||
211 | m_cacheFileNames = cacheFileNames; | - | ||||||||||||||||||||||||
212 | m_mimetypeListLoaded = false; | - | ||||||||||||||||||||||||
213 | } executed 4 times by 2 tests: end of block Executed by:
| 4 | ||||||||||||||||||||||||
214 | } executed 56 times by 3 tests: end of block Executed by:
| 56 | ||||||||||||||||||||||||
215 | - | |||||||||||||||||||||||||
216 | static 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: QMimeType(data);return QMimeType(data); Executed by:
executed 5482 times by 2 tests: return QMimeType(data); Executed by:
| 5482 | ||||||||||||||||||||||||
225 | } | - | ||||||||||||||||||||||||
226 | - | |||||||||||||||||||||||||
227 | QMimeType QMimeBinaryProvider::mimeTypeForName(const QString &name) | - | ||||||||||||||||||||||||
228 | { | - | ||||||||||||||||||||||||
229 | checkCache(); | - | ||||||||||||||||||||||||
230 | if (!m_mimetypeListLoaded
| 7-2145 | ||||||||||||||||||||||||
231 | loadMimeTypeList(); executed 7 times by 2 tests: loadMimeTypeList(); Executed by:
| 7 | ||||||||||||||||||||||||
232 | if (!m_mimetypeNames.contains(name)
| 8-2144 | ||||||||||||||||||||||||
233 | return executed 8 times by 1 test: QMimeType();return QMimeType(); Executed by:
executed 8 times by 1 test: return QMimeType(); Executed by:
| 8 | ||||||||||||||||||||||||
234 | return executed 2144 times by 2 tests: mimeTypeForNameUnchecked(name);return mimeTypeForNameUnchecked(name); Executed by:
executed 2144 times by 2 tests: return mimeTypeForNameUnchecked(name); Executed by:
| 2144 | ||||||||||||||||||||||||
235 | } | - | ||||||||||||||||||||||||
236 | - | |||||||||||||||||||||||||
237 | QStringList QMimeBinaryProvider::findByFileName(const QString &fileName, QString *foundSuffix) | - | ||||||||||||||||||||||||
238 | { | - | ||||||||||||||||||||||||
239 | checkCache(); | - | ||||||||||||||||||||||||
240 | if (fileName.isEmpty()
| 2-94 | ||||||||||||||||||||||||
241 | return executed 2 times by 1 test: QStringList();return QStringList(); Executed by:
executed 2 times by 1 test: return QStringList(); Executed by:
| 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()
| 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:
| 32 | ||||||||||||||||||||||||
254 | } executed 97 times by 1 test: end of block Executed by:
| 97 | ||||||||||||||||||||||||
255 | if (foundSuffix
| 8-86 | ||||||||||||||||||||||||
256 | * executed 8 times by 1 test: foundSuffix = result.m_foundSuffix;*foundSuffix = result.m_foundSuffix; Executed by:
executed 8 times by 1 test: *foundSuffix = result.m_foundSuffix; Executed by:
| 8 | ||||||||||||||||||||||||
257 | return executed 94 times by 1 test: result.m_matchingMimeTypes;return result.m_matchingMimeTypes; Executed by:
executed 94 times by 1 test: return result.m_matchingMimeTypes; Executed by:
| 94 | ||||||||||||||||||||||||
258 | } | - | ||||||||||||||||||||||||
259 | - | |||||||||||||||||||||||||
260 | void 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
| 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
| 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)
| 16-1586 | ||||||||||||||||||||||||
279 | result.addMatch(QLatin1String(mimeType), weight, pattern); executed 16 times by 1 test: result.addMatch(QLatin1String(mimeType), weight, pattern); Executed by:
| 16 | ||||||||||||||||||||||||
280 | } executed 1602 times by 1 test: end of block Executed by:
| 1602 | ||||||||||||||||||||||||
281 | } executed 194 times by 1 test: end of block Executed by:
| 194 | ||||||||||||||||||||||||
282 | - | |||||||||||||||||||||||||
283 | bool 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
| 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
| 586-723 | ||||||||||||||||||||||||
293 | min = mid + 1; executed 586 times by 1 test: min = mid + 1; Executed by:
| 586 | ||||||||||||||||||||||||
294 | else if (ch > fileChar
| 339-384 | ||||||||||||||||||||||||
295 | max = mid - 1; executed 339 times by 1 test: max = mid - 1; Executed by:
| 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
| 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:
| 378 | ||||||||||||||||||||||||
303 | if (!success
| 181-203 | ||||||||||||||||||||||||
304 | for (int i = 0; i < numChildren
| 57-190 | ||||||||||||||||||||||||
305 | const int childOff = childrenOffset + 12 * i; | - | ||||||||||||||||||||||||
306 | const int mch = cacheFile->getUint32(childOff); | - | ||||||||||||||||||||||||
307 | if (mch != 0
| 66-124 | ||||||||||||||||||||||||
308 | break; executed 124 times by 1 test: break; Executed by:
| 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
| 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:
| 62 | ||||||||||||||||||||||||
318 | } executed 66 times by 1 test: end of block Executed by:
| 66 | ||||||||||||||||||||||||
319 | } executed 181 times by 1 test: end of block Executed by:
| 181 | ||||||||||||||||||||||||
320 | return executed 384 times by 1 test: success;return success; Executed by:
executed 384 times by 1 test: return success; Executed by:
| 384 | ||||||||||||||||||||||||
321 | } | - | ||||||||||||||||||||||||
322 | } | - | ||||||||||||||||||||||||
323 | return executed 123 times by 1 test: false;return false; Executed by:
executed 123 times by 1 test: return false; Executed by:
| 123 | ||||||||||||||||||||||||
324 | } | - | ||||||||||||||||||||||||
325 | - | |||||||||||||||||||||||||
326 | bool 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
| 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
| 215-9901 | ||||||||||||||||||||||||
339 | - | |||||||||||||||||||||||||
340 | if (!QMimeMagicRule::matchSubstring(dataPtr, dataSize, rangeStart, rangeLength, valueLength, cacheFile->getCharStar(valueOffset), mask)
| 45-10071 | ||||||||||||||||||||||||
341 | continue; executed 10071 times by 1 test: continue; Executed by:
| 10071 | ||||||||||||||||||||||||
342 | - | |||||||||||||||||||||||||
343 | const int numChildren = cacheFile->getUint32(off + 24); | - | ||||||||||||||||||||||||
344 | const int firstChildOffset = cacheFile->getUint32(off + 28); | - | ||||||||||||||||||||||||
345 | if (numChildren == 0
| 22-23 | ||||||||||||||||||||||||
346 | return executed 23 times by 1 test: true;return true; Executed by:
executed 23 times by 1 test: return true; Executed by:
| 23 | ||||||||||||||||||||||||
347 | - | |||||||||||||||||||||||||
348 | if (matchMagicRule(cacheFile, numChildren, firstChildOffset, data)
| 4-18 | ||||||||||||||||||||||||
349 | return executed 4 times by 1 test: true;return true; Executed by:
executed 4 times by 1 test: return true; Executed by:
| 4 | ||||||||||||||||||||||||
350 | } executed 18 times by 1 test: end of block Executed by:
| 18 | ||||||||||||||||||||||||
351 | return executed 5890 times by 1 test: false;return false; Executed by:
executed 5890 times by 1 test: return false; Executed by:
| 5890 | ||||||||||||||||||||||||
352 | } | - | ||||||||||||||||||||||||
353 | - | |||||||||||||||||||||||||
354 | QMimeType 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
| 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)
| 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: mimeTypeForNameUnchecked(QLatin1String(mimeType));return mimeTypeForNameUnchecked(QLatin1String(mimeType)); Executed by:
executed 23 times by 1 test: return mimeTypeForNameUnchecked(QLatin1String(mimeType)); Executed by:
| 23 | ||||||||||||||||||||||||
374 | } | - | ||||||||||||||||||||||||
375 | } executed 5872 times by 1 test: end of block Executed by:
| 5872 | ||||||||||||||||||||||||
376 | } executed 9 times by 1 test: end of block Executed by:
| 9 | ||||||||||||||||||||||||
377 | return executed 9 times by 1 test: QMimeType();return QMimeType(); Executed by:
executed 9 times by 1 test: return QMimeType(); Executed by:
| 9 | ||||||||||||||||||||||||
378 | } | - | ||||||||||||||||||||||||
379 | - | |||||||||||||||||||||||||
380 | QStringList 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
| 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
| 230-236 | ||||||||||||||||||||||||
398 | begin = medium + 1; | - | ||||||||||||||||||||||||
399 | } executed 230 times by 1 test: else if (cmp > 0end of block Executed by:
| 26-230 | ||||||||||||||||||||||||
400 | end = medium - 1; | - | ||||||||||||||||||||||||
401 | } executed 210 times by 1 test: else {end of block Executed by:
| 210 | ||||||||||||||||||||||||
402 | const int parentsOffset = cacheFile->getUint32(off + 4); | - | ||||||||||||||||||||||||
403 | const int numParents = cacheFile->getUint32(parentsOffset); | - | ||||||||||||||||||||||||
404 | for (int i = 0; i < numParents
| 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:
| 34 | ||||||||||||||||||||||||
409 | break; executed 26 times by 1 test: break; Executed by:
| 26 | ||||||||||||||||||||||||
410 | } | - | ||||||||||||||||||||||||
411 | } | - | ||||||||||||||||||||||||
412 | } executed 60 times by 1 test: end of block Executed by:
| 60 | ||||||||||||||||||||||||
413 | if (result.isEmpty()
| 26-34 | ||||||||||||||||||||||||
414 | const QString parent = fallbackParent(mime); | - | ||||||||||||||||||||||||
415 | if (!parent.isEmpty()
| 12-22 | ||||||||||||||||||||||||
416 | result.append(parent); executed 22 times by 1 test: result.append(parent); Executed by:
| 22 | ||||||||||||||||||||||||
417 | } executed 34 times by 1 test: end of block Executed by:
| 34 | ||||||||||||||||||||||||
418 | return executed 60 times by 1 test: result;return result; Executed by:
executed 60 times by 1 test: return result; Executed by:
| 60 | ||||||||||||||||||||||||
419 | } | - | ||||||||||||||||||||||||
420 | - | |||||||||||||||||||||||||
421 | QString 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
| 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
| 8004-8566 | ||||||||||||||||||||||||
437 | begin = medium + 1; | - | ||||||||||||||||||||||||
438 | } executed 8566 times by 2 tests: else if (cmp > 0end of block Executed by:
| 9-8566 | ||||||||||||||||||||||||
439 | end = medium - 1; | - | ||||||||||||||||||||||||
440 | } executed 7995 times by 2 tests: else {end of block Executed by:
| 7995 | ||||||||||||||||||||||||
441 | const int mimeOffset = cacheFile->getUint32(off + 4); | - | ||||||||||||||||||||||||
442 | const char *mimeType = cacheFile->getCharStar(mimeOffset); | - | ||||||||||||||||||||||||
443 | return executed 9 times by 1 test: QLatin1String(mimeType);return QLatin1String(mimeType); Executed by:
executed 9 times by 1 test: return QLatin1String(mimeType); Executed by:
| 9 | ||||||||||||||||||||||||
444 | } | - | ||||||||||||||||||||||||
445 | } | - | ||||||||||||||||||||||||
446 | } executed 2180 times by 2 tests: end of block Executed by:
| 2180 | ||||||||||||||||||||||||
447 | - | |||||||||||||||||||||||||
448 | return executed 2169 times by 2 tests: name;return name; Executed by:
executed 2169 times by 2 tests: return name; Executed by:
| 2169 | ||||||||||||||||||||||||
449 | } | - | ||||||||||||||||||||||||
450 | - | |||||||||||||||||||||||||
451 | QStringList 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
| 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
| 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:
| 4 | ||||||||||||||||||||||||
469 | } executed 776 times by 1 test: end of block Executed by:
| 776 | ||||||||||||||||||||||||
470 | } executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||||||||||||||||||||
471 | return executed 4 times by 1 test: result;return result; Executed by:
executed 4 times by 1 test: return result; Executed by:
| 4 | ||||||||||||||||||||||||
472 | } | - | ||||||||||||||||||||||||
473 | - | |||||||||||||||||||||||||
474 | void QMimeBinaryProvider::loadMimeTypeList() | - | ||||||||||||||||||||||||
475 | { | - | ||||||||||||||||||||||||
476 | if (!m_mimetypeListLoaded
| 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)
| 0-10 | ||||||||||||||||||||||||
485 | while (!file.atEnd()
| 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:
| 4698 | ||||||||||||||||||||||||
490 | } executed 10 times by 2 tests: end of block Executed by:
| 10 | ||||||||||||||||||||||||
491 | } executed 10 times by 2 tests: end of block Executed by:
| 10 | ||||||||||||||||||||||||
492 | } executed 7 times by 2 tests: end of block Executed by:
| 7 | ||||||||||||||||||||||||
493 | } executed 12 times by 2 tests: end of block Executed by:
| 12 | ||||||||||||||||||||||||
494 | - | |||||||||||||||||||||||||
495 | QList<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()
| 5-3315 | ||||||||||||||||||||||||
503 | result.append(mimeTypeForNameUnchecked(*it)); executed 3315 times by 1 test: result.append(mimeTypeForNameUnchecked(*it)); Executed by:
| 3315 | ||||||||||||||||||||||||
504 | - | |||||||||||||||||||||||||
505 | return executed 5 times by 1 test: result;return result; Executed by:
executed 5 times by 1 test: return result; Executed by:
| 5 | ||||||||||||||||||||||||
506 | } | - | ||||||||||||||||||||||||
507 | - | |||||||||||||||||||||||||
508 | void QMimeBinaryProvider::loadMimeTypePrivate(QMimeTypePrivate &data) | - | ||||||||||||||||||||||||
509 | { | - | ||||||||||||||||||||||||
510 | - | |||||||||||||||||||||||||
511 | - | |||||||||||||||||||||||||
512 | - | |||||||||||||||||||||||||
513 | - | |||||||||||||||||||||||||
514 | if (data.loaded
| 10-18 | ||||||||||||||||||||||||
515 | return; executed 10 times by 1 test: return; Executed by:
| 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()
| 0-18 | ||||||||||||||||||||||||
523 | mimeFiles = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QString::fromLatin1("mime/") + file); | - | ||||||||||||||||||||||||
524 | } never executed: end of block | 0 | ||||||||||||||||||||||||
525 | if (mimeFiles.isEmpty()
| 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
| 18 | ||||||||||||||||||||||||
537 | QFile qfile(*it); | - | ||||||||||||||||||||||||
538 | if (!qfile.open(QFile::ReadOnly)
| 0-18 | ||||||||||||||||||||||||
539 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
540 | - | |||||||||||||||||||||||||
541 | QXmlStreamReader xml(&qfile); | - | ||||||||||||||||||||||||
542 | if (xml.readNextStartElement()
| 0-18 | ||||||||||||||||||||||||
543 | if (xml.name() != QLatin1String("mime-type")
| 0-18 | ||||||||||||||||||||||||
544 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
545 | } | - | ||||||||||||||||||||||||
546 | const QStringRef name = xml.attributes().value(QLatin1String("type")); | - | ||||||||||||||||||||||||
547 | if (name.isEmpty()
| 0-18 | ||||||||||||||||||||||||
548 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
549 | if (name.compare(data.name, Qt::CaseInsensitive)
| 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()
| 18-812 | ||||||||||||||||||||||||
553 | const QStringRef tag = xml.name(); | - | ||||||||||||||||||||||||
554 | if (tag == QLatin1String("comment")
| 66-746 | ||||||||||||||||||||||||
555 | QString lang = xml.attributes().value(QLatin1String("xml:lang")).toString(); | - | ||||||||||||||||||||||||
556 | const QString text = xml.readElementText(); | - | ||||||||||||||||||||||||
557 | if (lang.isEmpty()
| 18-728 | ||||||||||||||||||||||||
558 | lang = QLatin1String("en_US"); | - | ||||||||||||||||||||||||
559 | } executed 18 times by 1 test: end of block Executed by:
| 18 | ||||||||||||||||||||||||
560 | data.localeComments.insert(lang, text); | - | ||||||||||||||||||||||||
561 | continue; executed 746 times by 1 test: continue; Executed by:
| 746 | ||||||||||||||||||||||||
562 | } else if (tag == QLatin1String("icon")
| 0-66 | ||||||||||||||||||||||||
563 | data.iconName = xml.attributes().value(QLatin1String("name")).toString(); | - | ||||||||||||||||||||||||
564 | } never executed: else if (tag == QLatin1String("glob-deleteall")end of block
| 0-65 | ||||||||||||||||||||||||
565 | data.globPatterns.clear(); | - | ||||||||||||||||||||||||
566 | } executed 1 time by 1 test: else if (tag == QLatin1String("glob")end of block Executed by:
| 1-35 | ||||||||||||||||||||||||
567 | const QString pattern = xml.attributes().value(QLatin1String("pattern")).toString(); | - | ||||||||||||||||||||||||
568 | if (mainPattern.isEmpty()
| 1-16 | ||||||||||||||||||||||||
569 | mainPattern = pattern; | - | ||||||||||||||||||||||||
570 | } executed 13 times by 1 test: end of block Executed by:
| 13 | ||||||||||||||||||||||||
571 | if (!data.globPatterns.contains(pattern)
| 0-30 | ||||||||||||||||||||||||
572 | data.globPatterns.append(pattern); executed 30 times by 1 test: data.globPatterns.append(pattern); Executed by:
| 30 | ||||||||||||||||||||||||
573 | } executed 30 times by 1 test: end of block Executed by:
| 30 | ||||||||||||||||||||||||
574 | xml.skipCurrentElement(); | - | ||||||||||||||||||||||||
575 | } executed 66 times by 1 test: end of block Executed by:
| 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:
| 18 | ||||||||||||||||||||||||
578 | } executed 18 times by 1 test: end of block Executed by:
| 18 | ||||||||||||||||||||||||
579 | - | |||||||||||||||||||||||||
580 | - | |||||||||||||||||||||||||
581 | - | |||||||||||||||||||||||||
582 | - | |||||||||||||||||||||||||
583 | if (!mainPattern.isEmpty()
| 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:
| 1 | ||||||||||||||||||||||||
588 | } executed 18 times by 1 test: end of block Executed by:
| 18 | ||||||||||||||||||||||||
589 | - | |||||||||||||||||||||||||
590 | - | |||||||||||||||||||||||||
591 | QString 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
| 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
| 16-18 | ||||||||||||||||||||||||
604 | begin = medium + 1; executed 18 times by 1 test: begin = medium + 1; Executed by:
| 18 | ||||||||||||||||||||||||
605 | else if (cmp > 0
| 2-14 | ||||||||||||||||||||||||
606 | end = medium - 1; executed 14 times by 1 test: end = medium - 1; Executed by:
| 14 | ||||||||||||||||||||||||
607 | else { | - | ||||||||||||||||||||||||
608 | const int iconOffset = cacheFile->getUint32(off + 4); | - | ||||||||||||||||||||||||
609 | return executed 2 times by 1 test: QLatin1String(cacheFile->getCharStar(iconOffset));return QLatin1String(cacheFile->getCharStar(iconOffset)); Executed by:
executed 2 times by 1 test: return QLatin1String(cacheFile->getCharStar(iconOffset)); Executed by:
| 2 | ||||||||||||||||||||||||
610 | } | - | ||||||||||||||||||||||||
611 | } | - | ||||||||||||||||||||||||
612 | return executed 6 times by 1 test: QString();return QString(); Executed by:
executed 6 times by 1 test: return QString(); Executed by:
| 6 | ||||||||||||||||||||||||
613 | } | - | ||||||||||||||||||||||||
614 | - | |||||||||||||||||||||||||
615 | void 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()
| 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:
| 4 | ||||||||||||||||||||||||
626 | } executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||||||||||||||||||||
627 | - | |||||||||||||||||||||||||
628 | void 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()
| 2 | ||||||||||||||||||||||||
635 | data.genericIconName = icon; | - | ||||||||||||||||||||||||
636 | return; executed 2 times by 1 test: return; Executed by:
| 2 | ||||||||||||||||||||||||
637 | } | - | ||||||||||||||||||||||||
638 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||
639 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||
640 | - | |||||||||||||||||||||||||
641 | - | |||||||||||||||||||||||||
642 | - | |||||||||||||||||||||||||
643 | QMimeXMLProvider::QMimeXMLProvider(QMimeDatabasePrivate *db) | - | ||||||||||||||||||||||||
644 | : QMimeProviderBase(db), m_loaded(false) | - | ||||||||||||||||||||||||
645 | { | - | ||||||||||||||||||||||||
646 | initResources(); | - | ||||||||||||||||||||||||
647 | } executed 2 times by 2 tests: end of block Executed by:
| 2 | ||||||||||||||||||||||||
648 | - | |||||||||||||||||||||||||
649 | QMimeXMLProvider::~QMimeXMLProvider() | - | ||||||||||||||||||||||||
650 | { | - | ||||||||||||||||||||||||
651 | } | - | ||||||||||||||||||||||||
652 | - | |||||||||||||||||||||||||
653 | bool QMimeXMLProvider::isValid() | - | ||||||||||||||||||||||||
654 | { | - | ||||||||||||||||||||||||
655 | return never executed: true;return true; never executed: return true; | 0 | ||||||||||||||||||||||||
656 | } | - | ||||||||||||||||||||||||
657 | - | |||||||||||||||||||||||||
658 | QMimeType QMimeXMLProvider::mimeTypeForName(const QString &name) | - | ||||||||||||||||||||||||
659 | { | - | ||||||||||||||||||||||||
660 | ensureLoaded(); | - | ||||||||||||||||||||||||
661 | - | |||||||||||||||||||||||||
662 | return executed 2183 times by 1 test: m_nameMimeTypeMap.value(name);return m_nameMimeTypeMap.value(name); Executed by:
executed 2183 times by 1 test: return m_nameMimeTypeMap.value(name); Executed by:
| 2183 | ||||||||||||||||||||||||
663 | } | - | ||||||||||||||||||||||||
664 | - | |||||||||||||||||||||||||
665 | QStringList 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: matchingMimeTypes;return matchingMimeTypes; Executed by:
executed 96 times by 1 test: return matchingMimeTypes; Executed by:
| 96 | ||||||||||||||||||||||||
671 | } | - | ||||||||||||||||||||||||
672 | - | |||||||||||||||||||||||||
673 | QMimeType 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)
| 37-11003 | ||||||||||||||||||||||||
681 | const int priority = matcher.priority(); | - | ||||||||||||||||||||||||
682 | if (priority > *accuracyPtr
| 14-23 | ||||||||||||||||||||||||
683 | *accuracyPtr = priority; | - | ||||||||||||||||||||||||
684 | candidate = matcher.mimetype(); | - | ||||||||||||||||||||||||
685 | } executed 23 times by 1 test: end of block Executed by:
| 23 | ||||||||||||||||||||||||
686 | } executed 37 times by 1 test: end of block Executed by:
| 37 | ||||||||||||||||||||||||
687 | } executed 11040 times by 1 test: end of block Executed by:
| 11040 | ||||||||||||||||||||||||
688 | return executed 32 times by 1 test: mimeTypeForName(candidate);return mimeTypeForName(candidate); Executed by:
executed 32 times by 1 test: return mimeTypeForName(candidate); Executed by:
| 32 | ||||||||||||||||||||||||
689 | } | - | ||||||||||||||||||||||||
690 | - | |||||||||||||||||||||||||
691 | void QMimeXMLProvider::ensureLoaded() | - | ||||||||||||||||||||||||
692 | { | - | ||||||||||||||||||||||||
693 | if (!m_loaded
| 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
| 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:
| 88 | ||||||||||||||||||||||||
705 | QStringList::const_iterator endIt(files.constEnd()); | - | ||||||||||||||||||||||||
706 | for (QStringList::const_iterator it(files.constBegin()); it != endIt
| 88-261 | ||||||||||||||||||||||||
707 | allFiles.append(packageDir + QLatin1Char('/') + *it); | - | ||||||||||||||||||||||||
708 | } executed 261 times by 1 test: end of block Executed by:
| 261 | ||||||||||||||||||||||||
709 | } executed 88 times by 1 test: end of block Executed by:
| 88 | ||||||||||||||||||||||||
710 | - | |||||||||||||||||||||||||
711 | if (!fdoXmlFound
| 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
| 5-52 | ||||||||||||||||||||||||
717 | return; executed 52 times by 1 test: return; Executed by:
| 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:
| 17 | ||||||||||||||||||||||||
730 | } executed 5 times by 1 test: end of block Executed by:
| 5 | ||||||||||||||||||||||||
731 | } executed 4505 times by 1 test: end of block Executed by:
| 4505 | ||||||||||||||||||||||||
732 | - | |||||||||||||||||||||||||
733 | void QMimeXMLProvider::load(const QString &fileName) | - | ||||||||||||||||||||||||
734 | { | - | ||||||||||||||||||||||||
735 | QString errorMessage; | - | ||||||||||||||||||||||||
736 | if (!load(fileName, &errorMessage)
| 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:
| 17 | ||||||||||||||||||||||||
739 | - | |||||||||||||||||||||||||
740 | bool 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)
| 0-17 | ||||||||||||||||||||||||
746 | if (errorMessage
| 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: false;return false; never executed: return false; | 0 | ||||||||||||||||||||||||
749 | } | - | ||||||||||||||||||||||||
750 | - | |||||||||||||||||||||||||
751 | if (errorMessage
| 0-17 | ||||||||||||||||||||||||
752 | errorMessage->clear(); executed 17 times by 1 test: errorMessage->clear(); Executed by:
| 17 | ||||||||||||||||||||||||
753 | - | |||||||||||||||||||||||||
754 | QMimeTypeParser parser(*this); | - | ||||||||||||||||||||||||
755 | return executed 17 times by 1 test: parser.parse(&file, fileName, errorMessage);return parser.parse(&file, fileName, errorMessage); Executed by:
executed 17 times by 1 test: return parser.parse(&file, fileName, errorMessage); Executed by:
| 17 | ||||||||||||||||||||||||
756 | } | - | ||||||||||||||||||||||||
757 | - | |||||||||||||||||||||||||
758 | void QMimeXMLProvider::addGlobPattern(const QMimeGlobPattern &glob) | - | ||||||||||||||||||||||||
759 | { | - | ||||||||||||||||||||||||
760 | m_mimeTypeGlobs.addGlob(glob); | - | ||||||||||||||||||||||||
761 | } executed 4136 times by 1 test: end of block Executed by:
| 4136 | ||||||||||||||||||||||||
762 | - | |||||||||||||||||||||||||
763 | void 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:
| 3319 | ||||||||||||||||||||||||
767 | - | |||||||||||||||||||||||||
768 | QStringList QMimeXMLProvider::parents(const QString &mime) | - | ||||||||||||||||||||||||
769 | { | - | ||||||||||||||||||||||||
770 | ensureLoaded(); | - | ||||||||||||||||||||||||
771 | QStringList result = m_parents.value(mime); | - | ||||||||||||||||||||||||
772 | if (result.isEmpty()
| 26-34 | ||||||||||||||||||||||||
773 | const QString parent = fallbackParent(mime); | - | ||||||||||||||||||||||||
774 | if (!parent.isEmpty()
| 12-22 | ||||||||||||||||||||||||
775 | result.append(parent); executed 22 times by 1 test: result.append(parent); Executed by:
| 22 | ||||||||||||||||||||||||
776 | } executed 34 times by 1 test: end of block Executed by:
| 34 | ||||||||||||||||||||||||
777 | return executed 60 times by 1 test: result;return result; Executed by:
executed 60 times by 1 test: return result; Executed by:
| 60 | ||||||||||||||||||||||||
778 | } | - | ||||||||||||||||||||||||
779 | - | |||||||||||||||||||||||||
780 | void 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:
| 1560 | ||||||||||||||||||||||||
784 | - | |||||||||||||||||||||||||
785 | QStringList QMimeXMLProvider::listAliases(const QString &name) | - | ||||||||||||||||||||||||
786 | { | - | ||||||||||||||||||||||||
787 | ensureLoaded(); | - | ||||||||||||||||||||||||
788 | - | |||||||||||||||||||||||||
789 | return executed 4 times by 1 test: m_aliases.keys(name);return m_aliases.keys(name); Executed by:
executed 4 times by 1 test: return m_aliases.keys(name); Executed by:
| 4 | ||||||||||||||||||||||||
790 | } | - | ||||||||||||||||||||||||
791 | - | |||||||||||||||||||||||||
792 | QString QMimeXMLProvider::resolveAlias(const QString &name) | - | ||||||||||||||||||||||||
793 | { | - | ||||||||||||||||||||||||
794 | ensureLoaded(); | - | ||||||||||||||||||||||||
795 | return executed 2177 times by 1 test: m_aliases.value(name, name);return m_aliases.value(name, name); Executed by:
executed 2177 times by 1 test: return m_aliases.value(name, name); Executed by:
| 2177 | ||||||||||||||||||||||||
796 | } | - | ||||||||||||||||||||||||
797 | - | |||||||||||||||||||||||||
798 | void 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:
| 975 | ||||||||||||||||||||||||
802 | - | |||||||||||||||||||||||||
803 | QList<QMimeType> QMimeXMLProvider::allMimeTypes() | - | ||||||||||||||||||||||||
804 | { | - | ||||||||||||||||||||||||
805 | ensureLoaded(); | - | ||||||||||||||||||||||||
806 | return executed 5 times by 1 test: m_nameMimeTypeMap.values();return m_nameMimeTypeMap.values(); Executed by:
executed 5 times by 1 test: return m_nameMimeTypeMap.values(); Executed by:
| 5 | ||||||||||||||||||||||||
807 | } | - | ||||||||||||||||||||||||
808 | - | |||||||||||||||||||||||||
809 | void QMimeXMLProvider::addMagicMatcher(const QMimeMagicRuleMatcher &matcher) | - | ||||||||||||||||||||||||
810 | { | - | ||||||||||||||||||||||||
811 | m_magicMatchers.append(matcher); | - | ||||||||||||||||||||||||
812 | } executed 1733 times by 1 test: end of block Executed by:
| 1733 | ||||||||||||||||||||||||
813 | - | |||||||||||||||||||||||||
814 | - | |||||||||||||||||||||||||
Switch to Source code | Preprocessed file |