io/qresource.cpp

Source codeSwitch to Preprocessed file
LineSource CodeCoverage
1/**************************************************************************** -
2** -
3** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -
4** Contact: http://www.qt-project.org/legal -
5** -
6** This file is part of the QtCore module of the Qt Toolkit. -
7** -
8** $QT_BEGIN_LICENSE:LGPL$ -
9** Commercial License Usage -
10** Licensees holding valid commercial Qt licenses may use this file in -
11** accordance with the commercial license agreement provided with the -
12** Software or, alternatively, in accordance with the terms contained in -
13** a written agreement between you and Digia. For licensing terms and -
14** conditions see http://qt.digia.com/licensing. For further information -
15** use the contact form at http://qt.digia.com/contact-us. -
16** -
17** GNU Lesser General Public License Usage -
18** Alternatively, this file may be used under the terms of the GNU Lesser -
19** General Public License version 2.1 as published by the Free Software -
20** Foundation and appearing in the file LICENSE.LGPL included in the -
21** packaging of this file. Please review the following information to -
22** ensure the GNU Lesser General Public License version 2.1 requirements -
23** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -
24** -
25** In addition, as a special exception, Digia gives you certain additional -
26** rights. These rights are described in the Digia Qt LGPL Exception -
27** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -
28** -
29** GNU General Public License Usage -
30** Alternatively, this file may be used under the terms of the GNU -
31** General Public License version 3.0 as published by the Free Software -
32** Foundation and appearing in the file LICENSE.GPL included in the -
33** packaging of this file. Please review the following information to -
34** ensure the GNU General Public License version 3.0 requirements will be -
35** met: http://www.gnu.org/copyleft/gpl.html. -
36** -
37** -
38** $QT_END_LICENSE$ -
39** -
40****************************************************************************/ -
41 -
42#include "qresource.h" -
43#include "qresource_p.h" -
44#include "qresource_iterator_p.h" -
45#include "qset.h" -
46#include "qhash.h" -
47#include "qmutex.h" -
48#include "qdebug.h" -
49#include "qlocale.h" -
50#include "qglobal.h" -
51#include "qvector.h" -
52#include "qdatetime.h" -
53#include "qbytearray.h" -
54#include "qstringlist.h" -
55#include <qshareddata.h> -
56#include <qplatformdefs.h> -
57#include "private/qabstractfileengine_p.h" -
58 -
59#ifdef Q_OS_UNIX -
60# include "private/qcore_unix_p.h" -
61#endif -
62 -
63//#define DEBUG_RESOURCE_MATCH -
64 -
65#if defined(Q_OS_VXWORKS) -
66# if defined(m_data) -
67# undef m_data -
68# endif -
69# if defined(m_len) -
70# undef m_len -
71# endif -
72#endif -
73 -
74QT_BEGIN_NAMESPACE -
75 -
76 -
77class QStringSplitter -
78{ -
79public: -
80 QStringSplitter(const QString &s) -
81 : m_string(s), m_data(m_string.constData()), m_len(s.length()), m_pos(0) -
82 { -
83 m_splitChar = QLatin1Char('/');
executed (the execution status of this line is deduced): m_splitChar = QLatin1Char('/');
-
84 }
executed: }
Execution Count:29554
29554
85 -
86 inline bool hasNext() { -
87 while (m_pos < m_len && m_data[m_pos] == m_splitChar)
evaluated: m_pos < m_len
TRUEFALSE
yes
Evaluation Count:155612
yes
Evaluation Count:12362
evaluated: m_data[m_pos] == m_splitChar
TRUEFALSE
yes
Evaluation Count:61722
yes
Evaluation Count:93890
12362-155612
88 ++m_pos;
executed: ++m_pos;
Execution Count:61722
61722
89 return m_pos < m_len;
executed: return m_pos < m_len;
Execution Count:106252
106252
90 } -
91 -
92 inline QStringRef next() { -
93 int start = m_pos;
executed (the execution status of this line is deduced): int start = m_pos;
-
94 while (m_pos < m_len && m_data[m_pos] != m_splitChar)
evaluated: m_pos < m_len
TRUEFALSE
yes
Evaluation Count:618973
yes
Evaluation Count:8472
evaluated: m_data[m_pos] != m_splitChar
TRUEFALSE
yes
Evaluation Count:565723
yes
Evaluation Count:53250
8472-618973
95 ++m_pos;
executed: ++m_pos;
Execution Count:565723
565723
96 return QStringRef(&m_string, start, m_pos - start);
executed: return QStringRef(&m_string, start, m_pos - start);
Execution Count:61722
61722
97 } -
98 -
99 QString m_string; -
100 const QChar *m_data; -
101 QChar m_splitChar; -
102 int m_len; -
103 int m_pos; -
104}; -
105 -
106 -
107//resource glue -
108class QResourceRoot -
109{ -
110 enum Flags -
111 { -
112 Compressed = 0x01, -
113 Directory = 0x02 -
114 }; -
115 const uchar *tree, *names, *payloads; -
116 inline int findOffset(int node) const { return node * 14; } //sizeof each tree element
executed: return node * 14;
Execution Count:264678
264678
117 uint hash(int node) const; -
118 QString name(int node) const; -
119 short flags(int node) const; -
120public: -
121 mutable QAtomicInt ref; -
122 -
123 inline QResourceRoot(): tree(0), names(0), payloads(0) {}
never executed: }
0
124 inline QResourceRoot(const uchar *t, const uchar *n, const uchar *d) { setSource(t, n, d); }
executed: }
Execution Count:183
183
125 virtual ~QResourceRoot() { } -
126 int findNode(const QString &path, const QLocale &locale=QLocale()) const; -
127 inline bool isContainer(int node) const { return flags(node) & Directory; }
executed: return flags(node) & Directory;
Execution Count:6252
6252
128 inline bool isCompressed(int node) const { return flags(node) & Compressed; }
executed: return flags(node) & Compressed;
Execution Count:6124
6124
129 const uchar *data(int node, qint64 *size) const; -
130 QStringList children(int node) const; -
131 virtual QString mappingRoot() const { return QString(); }
executed: return QString();
Execution Count:52892
52892
132 bool mappingRootSubdir(const QString &path, QString *match=0) const; -
133 inline bool operator==(const QResourceRoot &other) const -
134 { return tree == other.tree && names == other.names && payloads == other.payloads; }
executed: return tree == other.tree && names == other.names && payloads == other.payloads;
Execution Count:463
463
135 inline bool operator!=(const QResourceRoot &other) const -
136 { return !operator==(other); }
never executed: return !operator==(other);
0
137 enum ResourceRootType { Resource_Builtin, Resource_File, Resource_Buffer }; -
138 virtual ResourceRootType type() const { return Resource_Builtin; }
never executed: return Resource_Builtin;
0
139 -
140protected: -
141 inline void setSource(const uchar *t, const uchar *n, const uchar *d) { -
142 tree = t;
executed (the execution status of this line is deduced): tree = t;
-
143 names = n;
executed (the execution status of this line is deduced): names = n;
-
144 payloads = d;
executed (the execution status of this line is deduced): payloads = d;
-
145 }
executed: }
Execution Count:183
183
146}; -
147 -
148static QString cleanPath(const QString &_path) -
149{ -
150 QString path = QDir::cleanPath(_path);
executed (the execution status of this line is deduced): QString path = QDir::cleanPath(_path);
-
151 // QDir::cleanPath does not remove two trailing slashes under _Windows_ -
152 // due to support for UNC paths. Remove those manually. -
153 if (path.startsWith(QLatin1String("//")))
partially evaluated: path.startsWith(QLatin1String("//"))
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:9754
0-9754
154 path.remove(0, 1);
never executed: path.remove(0, 1);
0
155 return path;
executed: return path;
Execution Count:9754
9754
156} -
157 -
158Q_DECLARE_TYPEINFO(QResourceRoot, Q_MOVABLE_TYPE); -
159 -
160Q_GLOBAL_STATIC_WITH_ARGS(QMutex, resourceMutex, (QMutex::Recursive))
never executed: delete x;
executed: return thisGlobalStatic.pointer.load();
Execution Count:10001
never evaluated: !thisGlobalStatic.pointer.testAndSetOrdered(0, x)
partially evaluated: !thisGlobalStatic.pointer.load()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:10001
never evaluated: !thisGlobalStatic.destroyed
0-10001
161 -
162typedef QList<QResourceRoot*> ResourceList; -
163Q_GLOBAL_STATIC(ResourceList, resourceList)
never executed: delete x;
executed: return thisGlobalStatic.pointer.load();
Execution Count:10893
never evaluated: !thisGlobalStatic.pointer.testAndSetOrdered(0, x)
partially evaluated: !thisGlobalStatic.pointer.load()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:10893
never evaluated: !thisGlobalStatic.destroyed
0-10893
164 -
165Q_GLOBAL_STATIC(QStringList, resourceSearchPaths)
never executed: delete x;
executed: return thisGlobalStatic.pointer.load();
Execution Count:80
partially evaluated: !thisGlobalStatic.pointer.testAndSetOrdered(0, x)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4
evaluated: !thisGlobalStatic.pointer.load()
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:76
partially evaluated: !thisGlobalStatic.destroyed
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
0-80
166 -
167/*! -
168 \class QResource -
169 \inmodule QtCore -
170 \brief The QResource class provides an interface for reading directly from resources. -
171 -
172 \ingroup io -
173 -
174 \reentrant -
175 \since 4.2 -
176 -
177 QResource is an object that represents a set of data (and possibly -
178 children) relating to a single resource entity. QResource gives direct -
179 access to the bytes in their raw format. In this way direct access -
180 allows reading data without buffer copying or indirection. Indirection -
181 is often useful when interacting with the resource entity as if it is a -
182 file, this can be achieved with QFile. The data and children behind a -
183 QResource are normally compiled into an application/library, but it is -
184 also possible to load a resource at runtime. When loaded at run time -
185 the resource file will be loaded as one big set of data and then given -
186 out in pieces via references into the resource tree. -
187 -
188 A QResource can either be loaded with an absolute path, either treated -
189 as a file system rooted with a \c{/} character, or in resource notation -
190 rooted with a \c{:} character. A relative resource can also be opened -
191 which will be found in the list of paths returned by QDir::searchPaths(). -
192 -
193 A QResource that is representing a file will have data backing it, this -
194 data can possibly be compressed, in which case qUncompress() must be -
195 used to access the real data; this happens implicitly when accessed -
196 through a QFile. A QResource that is representing a directory will have -
197 only children and no data. -
198 -
199 \section1 Dynamic Resource Loading -
200 -
201 A resource can be left out of an application's binary and loaded when -
202 it is needed at run-time by using the registerResource() function. The -
203 resource file passed into registerResource() must be a binary resource -
204 as created by rcc. Further information about binary resources can be -
205 found in \l{The Qt Resource System} documentation. -
206 -
207 This can often be useful when loading a large set of application icons -
208 that may change based on a setting, or that can be edited by a user and -
209 later recreated. The resource is immediately loaded into memory, either -
210 as a result of a single file read operation, or as a memory mapped file. -
211 -
212 This approach can prove to be a significant performance gain as only a -
213 single file will be loaded, and pieces of data will be given out via the -
214 path requested in setFileName(). -
215 -
216 The unregisterResource() function removes a reference to a particular -
217 file. If there are QResources that currently reference resources related -
218 to the unregistered file, they will continue to be valid but the resource -
219 file itself will be removed from the resource roots, and thus no further -
220 QResource can be created pointing into this resource data. The resource -
221 itself will be unmapped from memory when the last QResource that points -
222 to it is destroyed. -
223 -
224 \sa {The Qt Resource System}, QFile, QDir, QFileInfo -
225*/ -
226 -
227class QResourcePrivate { -
228public: -
229 inline QResourcePrivate(QResource *_q) : q_ptr(_q) { clear(); }
executed: }
Execution Count:8275
8275
230 inline ~QResourcePrivate() { clear(); }
executed: }
Execution Count:8275
8275
231 -
232 void ensureInitialized() const; -
233 void ensureChildren() const; -
234 -
235 bool load(const QString &file); -
236 void clear(); -
237 -
238 QLocale locale; -
239 QString fileName, absoluteFilePath; -
240 QList<QResourceRoot*> related; -
241 uint container : 1; -
242 mutable uint compressed : 1; -
243 mutable qint64 size; -
244 mutable const uchar *data; -
245 mutable QStringList children; -
246 -
247 QResource *q_ptr; -
248 Q_DECLARE_PUBLIC(QResource) -
249}; -
250 -
251void -
252QResourcePrivate::clear() -
253{ -
254 absoluteFilePath.clear();
executed (the execution status of this line is deduced): absoluteFilePath.clear();
-
255 compressed = 0;
executed (the execution status of this line is deduced): compressed = 0;
-
256 data = 0;
executed (the execution status of this line is deduced): data = 0;
-
257 size = 0;
executed (the execution status of this line is deduced): size = 0;
-
258 children.clear();
executed (the execution status of this line is deduced): children.clear();
-
259 container = 0;
executed (the execution status of this line is deduced): container = 0;
-
260 for(int i = 0; i < related.size(); ++i) {
evaluated: i < related.size()
TRUEFALSE
yes
Evaluation Count:6252
yes
Evaluation Count:24822
6252-24822
261 QResourceRoot *root = related.at(i);
executed (the execution status of this line is deduced): QResourceRoot *root = related.at(i);
-
262 if(!root->ref.deref())
partially evaluated: !root->ref.deref()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:6252
0-6252
263 delete root;
never executed: delete root;
0
264 }
executed: }
Execution Count:6252
6252
265 related.clear();
executed (the execution status of this line is deduced): related.clear();
-
266}
executed: }
Execution Count:24822
24822
267 -
268bool -
269QResourcePrivate::load(const QString &file) -
270{ -
271 related.clear();
executed (the execution status of this line is deduced): related.clear();
-
272 QMutexLocker lock(resourceMutex());
executed (the execution status of this line is deduced): QMutexLocker lock(resourceMutex());
-
273 const ResourceList *list = resourceList();
executed (the execution status of this line is deduced): const ResourceList *list = resourceList();
-
274 QString cleaned = cleanPath(file);
executed (the execution status of this line is deduced): QString cleaned = cleanPath(file);
-
275 for(int i = 0; i < list->size(); ++i) {
evaluated: i < list->size()
TRUEFALSE
yes
Evaluation Count:29554
yes
Evaluation Count:9738
9738-29554
276 QResourceRoot *res = list->at(i);
executed (the execution status of this line is deduced): QResourceRoot *res = list->at(i);
-
277 const int node = res->findNode(cleaned, locale);
executed (the execution status of this line is deduced): const int node = res->findNode(cleaned, locale);
-
278 if(node != -1) {
evaluated: node != -1
TRUEFALSE
yes
Evaluation Count:6252
yes
Evaluation Count:23302
6252-23302
279 if(related.isEmpty()) {
evaluated: related.isEmpty()
TRUEFALSE
yes
Evaluation Count:6245
yes
Evaluation Count:7
7-6245
280 container = res->isContainer(node);
executed (the execution status of this line is deduced): container = res->isContainer(node);
-
281 if(!container) {
evaluated: !container
TRUEFALSE
yes
Evaluation Count:6124
yes
Evaluation Count:121
121-6124
282 data = res->data(node, &size);
executed (the execution status of this line is deduced): data = res->data(node, &size);
-
283 compressed = res->isCompressed(node);
executed (the execution status of this line is deduced): compressed = res->isCompressed(node);
-
284 } else {
executed: }
Execution Count:6124
6124
285 data = 0;
executed (the execution status of this line is deduced): data = 0;
-
286 size = 0;
executed (the execution status of this line is deduced): size = 0;
-
287 compressed = 0;
executed (the execution status of this line is deduced): compressed = 0;
-
288 }
executed: }
Execution Count:121
121
289 } else if(res->isContainer(node) != container) {
partially evaluated: res->isContainer(node) != container
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:7
0-7
290 qWarning("QResourceInfo: Resource [%s] has both data and children!", file.toLatin1().constData());
never executed (the execution status of this line is deduced): QMessageLogger("io/qresource.cpp", 290, __PRETTY_FUNCTION__).warning("QResourceInfo: Resource [%s] has both data and children!", file.toLatin1().constData());
-
291 }
never executed: }
0
292 res->ref.ref();
executed (the execution status of this line is deduced): res->ref.ref();
-
293 related.append(res);
executed (the execution status of this line is deduced): related.append(res);
-
294 } else if(res->mappingRootSubdir(file)) {
executed: }
Execution Count:6252
partially evaluated: res->mappingRootSubdir(file)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:23302
0-23302
295 container = true;
never executed (the execution status of this line is deduced): container = true;
-
296 data = 0;
never executed (the execution status of this line is deduced): data = 0;
-
297 size = 0;
never executed (the execution status of this line is deduced): size = 0;
-
298 compressed = 0;
never executed (the execution status of this line is deduced): compressed = 0;
-
299 res->ref.ref();
never executed (the execution status of this line is deduced): res->ref.ref();
-
300 related.append(res);
never executed (the execution status of this line is deduced): related.append(res);
-
301 }
never executed: }
0
302 } -
303 return !related.isEmpty();
executed: return !related.isEmpty();
Execution Count:9738
9738
304} -
305 -
306void -
307QResourcePrivate::ensureInitialized() const -
308{ -
309 if(!related.isEmpty())
evaluated: !related.isEmpty()
TRUEFALSE
yes
Evaluation Count:238286
yes
Evaluation Count:9738
9738-238286
310 return;
executed: return;
Execution Count:238286
238286
311 QResourcePrivate *that = const_cast<QResourcePrivate *>(this);
executed (the execution status of this line is deduced): QResourcePrivate *that = const_cast<QResourcePrivate *>(this);
-
312 if(fileName == QLatin1String(":"))
evaluated: fileName == QLatin1String(":")
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:9737
1-9737
313 that->fileName += QLatin1Char('/');
executed: that->fileName += QLatin1Char('/');
Execution Count:1
1
314 that->absoluteFilePath = fileName;
executed (the execution status of this line is deduced): that->absoluteFilePath = fileName;
-
315 if(!that->absoluteFilePath.startsWith(QLatin1Char(':')))
partially evaluated: !that->absoluteFilePath.startsWith(QLatin1Char(':'))
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:9738
0-9738
316 that->absoluteFilePath.prepend(QLatin1Char(':'));
never executed: that->absoluteFilePath.prepend(QLatin1Char(':'));
0
317 -
318 QString path = fileName;
executed (the execution status of this line is deduced): QString path = fileName;
-
319 if(path.startsWith(QLatin1Char(':')))
partially evaluated: path.startsWith(QLatin1Char(':'))
TRUEFALSE
yes
Evaluation Count:9738
no
Evaluation Count:0
0-9738
320 path = path.mid(1);
executed: path = path.mid(1);
Execution Count:9738
9738
321 -
322 if(path.startsWith(QLatin1Char('/'))) {
evaluated: path.startsWith(QLatin1Char('/'))
TRUEFALSE
yes
Evaluation Count:9658
yes
Evaluation Count:80
80-9658
323 that->load(path);
executed (the execution status of this line is deduced): that->load(path);
-
324 } else {
executed: }
Execution Count:9658
9658
325 QMutexLocker lock(resourceMutex());
executed (the execution status of this line is deduced): QMutexLocker lock(resourceMutex());
-
326 QStringList searchPaths = *resourceSearchPaths();
executed (the execution status of this line is deduced): QStringList searchPaths = *resourceSearchPaths();
-
327 searchPaths << QLatin1String("");
executed (the execution status of this line is deduced): searchPaths << QLatin1String("");
-
328 for(int i = 0; i < searchPaths.size(); ++i) {
evaluated: i < searchPaths.size()
TRUEFALSE
yes
Evaluation Count:80
yes
Evaluation Count:4
4-80
329 const QString searchPath(searchPaths.at(i) + QLatin1Char('/') + path);
executed (the execution status of this line is deduced): const QString searchPath(searchPaths.at(i) + QLatin1Char('/') + path);
-
330 if(that->load(searchPath)) {
evaluated: that->load(searchPath)
TRUEFALSE
yes
Evaluation Count:76
yes
Evaluation Count:4
4-76
331 that->absoluteFilePath = QLatin1Char(':') + searchPath;
executed (the execution status of this line is deduced): that->absoluteFilePath = QLatin1Char(':') + searchPath;
-
332 break;
executed: break;
Execution Count:76
76
333 } -
334 }
executed: }
Execution Count:4
4
335 }
executed: }
Execution Count:80
80
336} -
337 -
338void -
339QResourcePrivate::ensureChildren() const -
340{ -
341 ensureInitialized();
executed (the execution status of this line is deduced): ensureInitialized();
-
342 if(!children.isEmpty() || !container || related.isEmpty())
partially evaluated: !children.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:16
partially evaluated: !container
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:16
partially evaluated: related.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:16
0-16
343 return;
never executed: return;
0
344 -
345 QString path = absoluteFilePath, k;
executed (the execution status of this line is deduced): QString path = absoluteFilePath, k;
-
346 if(path.startsWith(QLatin1Char(':')))
partially evaluated: path.startsWith(QLatin1Char(':'))
TRUEFALSE
yes
Evaluation Count:16
no
Evaluation Count:0
0-16
347 path = path.mid(1);
executed: path = path.mid(1);
Execution Count:16
16
348 QSet<QString> kids;
executed (the execution status of this line is deduced): QSet<QString> kids;
-
349 QString cleaned = cleanPath(path);
executed (the execution status of this line is deduced): QString cleaned = cleanPath(path);
-
350 for(int i = 0; i < related.size(); ++i) {
evaluated: i < related.size()
TRUEFALSE
yes
Evaluation Count:18
yes
Evaluation Count:16
16-18
351 QResourceRoot *res = related.at(i);
executed (the execution status of this line is deduced): QResourceRoot *res = related.at(i);
-
352 if(res->mappingRootSubdir(path, &k) && !k.isEmpty()) {
partially evaluated: res->mappingRootSubdir(path, &k)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:18
never evaluated: !k.isEmpty()
0-18
353 if(!kids.contains(k)) {
never evaluated: !kids.contains(k)
0
354 children += k;
never executed (the execution status of this line is deduced): children += k;
-
355 kids.insert(k);
never executed (the execution status of this line is deduced): kids.insert(k);
-
356 }
never executed: }
0
357 } else {
never executed: }
0
358 const int node = res->findNode(cleaned);
executed (the execution status of this line is deduced): const int node = res->findNode(cleaned);
-
359 if(node != -1) {
partially evaluated: node != -1
TRUEFALSE
yes
Evaluation Count:18
no
Evaluation Count:0
0-18
360 QStringList related_children = res->children(node);
executed (the execution status of this line is deduced): QStringList related_children = res->children(node);
-
361 for(int kid = 0; kid < related_children.size(); ++kid) {
evaluated: kid < related_children.size()
TRUEFALSE
yes
Evaluation Count:183
yes
Evaluation Count:18
18-183
362 k = related_children.at(kid);
executed (the execution status of this line is deduced): k = related_children.at(kid);
-
363 if(!kids.contains(k)) {
partially evaluated: !kids.contains(k)
TRUEFALSE
yes
Evaluation Count:183
no
Evaluation Count:0
0-183
364 children += k;
executed (the execution status of this line is deduced): children += k;
-
365 kids.insert(k);
executed (the execution status of this line is deduced): kids.insert(k);
-
366 }
executed: }
Execution Count:183
183
367 }
executed: }
Execution Count:183
183
368 }
executed: }
Execution Count:18
18
369 }
executed: }
Execution Count:18
18
370 } -
371}
executed: }
Execution Count:16
16
372 -
373/*! -
374 Constructs a QResource pointing to \a file. \a locale is used to -
375 load a specific localization of a resource data. -
376 -
377 \sa QFileInfo, QDir::searchPaths(), setFileName(), setLocale() -
378*/ -
379 -
380QResource::QResource(const QString &file, const QLocale &locale) : d_ptr(new QResourcePrivate(this)) -
381{ -
382 Q_D(QResource);
executed (the execution status of this line is deduced): QResourcePrivate * const d = d_func();
-
383 d->fileName = file;
executed (the execution status of this line is deduced): d->fileName = file;
-
384 d->locale = locale;
executed (the execution status of this line is deduced): d->locale = locale;
-
385}
executed: }
Execution Count:8275
8275
386 -
387/*! -
388 Releases the resources of the QResource object. -
389*/ -
390QResource::~QResource() -
391{ -
392} -
393 -
394/*! -
395 Sets a QResource to only load the localization of resource to for \a -
396 locale. If a resource for the specific locale is not found then the -
397 C locale is used. -
398 -
399 \sa setFileName() -
400*/ -
401 -
402void QResource::setLocale(const QLocale &locale) -
403{ -
404 Q_D(QResource);
never executed (the execution status of this line is deduced): QResourcePrivate * const d = d_func();
-
405 d->clear();
never executed (the execution status of this line is deduced): d->clear();
-
406 d->locale = locale;
never executed (the execution status of this line is deduced): d->locale = locale;
-
407}
never executed: }
0
408 -
409/*! -
410 Returns the locale used to locate the data for the QResource. -
411*/ -
412 -
413QLocale QResource::locale() const -
414{ -
415 Q_D(const QResource);
never executed (the execution status of this line is deduced): const QResourcePrivate * const d = d_func();
-
416 return d->locale;
never executed: return d->locale;
0
417} -
418 -
419/*! -
420 Sets a QResource to point to \a file. \a file can either be absolute, -
421 in which case it is opened directly, if relative then the file will be -
422 tried to be found in QDir::searchPaths(). -
423 -
424 \sa absoluteFilePath() -
425*/ -
426 -
427void QResource::setFileName(const QString &file) -
428{ -
429 Q_D(QResource);
executed (the execution status of this line is deduced): QResourcePrivate * const d = d_func();
-
430 d->clear();
executed (the execution status of this line is deduced): d->clear();
-
431 d->fileName = file;
executed (the execution status of this line is deduced): d->fileName = file;
-
432}
executed: }
Execution Count:8272
8272
433 -
434/*! -
435 Returns the full path to the file that this QResource represents as it -
436 was passed. -
437 -
438 \sa absoluteFilePath() -
439*/ -
440 -
441QString QResource::fileName() const -
442{ -
443 Q_D(const QResource);
executed (the execution status of this line is deduced): const QResourcePrivate * const d = d_func();
-
444 d->ensureInitialized();
executed (the execution status of this line is deduced): d->ensureInitialized();
-
445 return d->fileName;
executed: return d->fileName;
Execution Count:4134
4134
446} -
447 -
448/*! -
449 Returns the real path that this QResource represents, if the resource -
450 was found via the QDir::searchPaths() it will be indicated in the path. -
451 -
452 \sa fileName() -
453*/ -
454 -
455QString QResource::absoluteFilePath() const -
456{ -
457 Q_D(const QResource);
executed (the execution status of this line is deduced): const QResourcePrivate * const d = d_func();
-
458 d->ensureInitialized();
executed (the execution status of this line is deduced): d->ensureInitialized();
-
459 return d->absoluteFilePath;
executed: return d->absoluteFilePath;
Execution Count:1879
1879
460} -
461 -
462/*! -
463 Returns true if the resource really exists in the resource hierarchy, -
464 false otherwise. -
465 -
466*/ -
467 -
468bool QResource::isValid() const -
469{ -
470 Q_D(const QResource);
executed (the execution status of this line is deduced): const QResourcePrivate * const d = d_func();
-
471 d->ensureInitialized();
executed (the execution status of this line is deduced): d->ensureInitialized();
-
472 return !d->related.isEmpty();
executed: return !d->related.isEmpty();
Execution Count:79296
79296
473} -
474 -
475/*! -
476 \fn bool QResource::isFile() const -
477 -
478 Returns true if the resource represents a file and thus has data -
479 backing it, false if it represents a directory. -
480 -
481 \sa isDir() -
482*/ -
483 -
484 -
485/*! -
486 Returns true if the resource represents a file and the data backing it -
487 is in a compressed format, false otherwise. -
488 -
489 \sa data(), isFile() -
490*/ -
491 -
492bool QResource::isCompressed() const -
493{ -
494 Q_D(const QResource);
executed (the execution status of this line is deduced): const QResourcePrivate * const d = d_func();
-
495 d->ensureInitialized();
executed (the execution status of this line is deduced): d->ensureInitialized();
-
496 return d->compressed;
executed: return d->compressed;
Execution Count:85163
85163
497} -
498 -
499/*! -
500 Returns the size of the data backing the resource. -
501 -
502 \sa data(), isFile() -
503*/ -
504 -
505qint64 QResource::size() const -
506{ -
507 Q_D(const QResource);
executed (the execution status of this line is deduced): const QResourcePrivate * const d = d_func();
-
508 d->ensureInitialized();
executed (the execution status of this line is deduced): d->ensureInitialized();
-
509 return d->size;
executed: return d->size;
Execution Count:73133
73133
510} -
511 -
512/*! -
513 Returns direct access to a read only segment of data that this resource -
514 represents. If the resource is compressed the data returns is -
515 compressed and qUncompress() must be used to access the data. If the -
516 resource is a directory 0 is returned. -
517 -
518 \sa size(), isCompressed(), isFile() -
519*/ -
520 -
521const uchar *QResource::data() const -
522{ -
523 Q_D(const QResource);
executed (the execution status of this line is deduced): const QResourcePrivate * const d = d_func();
-
524 d->ensureInitialized();
executed (the execution status of this line is deduced): d->ensureInitialized();
-
525 return d->data;
executed: return d->data;
Execution Count:2542
2542
526} -
527 -
528/*! -
529 Returns true if the resource represents a directory and thus may have -
530 children() in it, false if it represents a file. -
531 -
532 \sa isFile() -
533*/ -
534 -
535bool QResource::isDir() const -
536{ -
537 Q_D(const QResource);
executed (the execution status of this line is deduced): const QResourcePrivate * const d = d_func();
-
538 d->ensureInitialized();
executed (the execution status of this line is deduced): d->ensureInitialized();
-
539 return d->container;
executed: return d->container;
Execution Count:1861
1861
540} -
541 -
542/*! -
543 Returns a list of all resources in this directory, if the resource -
544 represents a file the list will be empty. -
545 -
546 \sa isDir() -
547*/ -
548 -
549QStringList QResource::children() const -
550{ -
551 Q_D(const QResource);
executed (the execution status of this line is deduced): const QResourcePrivate * const d = d_func();
-
552 d->ensureChildren();
executed (the execution status of this line is deduced): d->ensureChildren();
-
553 return d->children;
executed: return d->children;
Execution Count:16
16
554} -
555 -
556/*! -
557 \obsolete -
558 -
559 Use QDir::addSearchPath() with a prefix instead. -
560 -
561 Adds \a path to the search paths searched in to find resources that are -
562 not specified with an absolute path. The \a path must be an absolute -
563 path (start with \c{/}). -
564 -
565 The default search path is to search only in the root (\c{:/}). The last -
566 path added will be consulted first upon next QResource creation. -
567*/ -
568void -
569QResource::addSearchPath(const QString &path) -
570{ -
571 if (!path.startsWith(QLatin1Char('/'))) {
never evaluated: !path.startsWith(QLatin1Char('/'))
0
572 qWarning("QResource::addResourceSearchPath: Search paths must be absolute (start with /) [%s]",
never executed (the execution status of this line is deduced): QMessageLogger("io/qresource.cpp", 572, __PRETTY_FUNCTION__).warning("QResource::addResourceSearchPath: Search paths must be absolute (start with /) [%s]",
-
573 path.toLocal8Bit().data());
never executed (the execution status of this line is deduced): path.toLocal8Bit().data());
-
574 return;
never executed: return;
0
575 } -
576 QMutexLocker lock(resourceMutex());
never executed (the execution status of this line is deduced): QMutexLocker lock(resourceMutex());
-
577 resourceSearchPaths()->prepend(path);
never executed (the execution status of this line is deduced): resourceSearchPaths()->prepend(path);
-
578}
never executed: }
0
579 -
580/*! -
581 \obsolete -
582 -
583 Use QDir::searchPaths() instead. -
584 -
585 Returns the current search path list. This list is consulted when -
586 creating a relative resource. -
587 -
588 \sa QDir::addSearchPath(), QDir::setSearchPaths() -
589*/ -
590 -
591QStringList -
592QResource::searchPaths() -
593{ -
594 QMutexLocker lock(resourceMutex());
never executed (the execution status of this line is deduced): QMutexLocker lock(resourceMutex());
-
595 return *resourceSearchPaths();
never executed: return *resourceSearchPaths();
0
596} -
597 -
598inline uint QResourceRoot::hash(int node) const -
599{ -
600 if(!node) //root
partially evaluated: !node
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:169137
0-169137
601 return 0;
never executed: return 0;
0
602 const int offset = findOffset(node);
executed (the execution status of this line is deduced): const int offset = findOffset(node);
-
603 int name_offset = (tree[offset+0] << 24) + (tree[offset+1] << 16) +
executed (the execution status of this line is deduced): int name_offset = (tree[offset+0] << 24) + (tree[offset+1] << 16) +
-
604 (tree[offset+2] << 8) + (tree[offset+3] << 0);
executed (the execution status of this line is deduced): (tree[offset+2] << 8) + (tree[offset+3] << 0);
-
605 name_offset += 2; //jump past name length
executed (the execution status of this line is deduced): name_offset += 2;
-
606 return (names[name_offset+0] << 24) + (names[name_offset+1] << 16) +
executed: return (names[name_offset+0] << 24) + (names[name_offset+1] << 16) + (names[name_offset+2] << 8) + (names[name_offset+3] << 0);
Execution Count:169137
169137
607 (names[name_offset+2] << 8) + (names[name_offset+3] << 0);
executed: return (names[name_offset+0] << 24) + (names[name_offset+1] << 16) + (names[name_offset+2] << 8) + (names[name_offset+3] << 0);
Execution Count:169137
169137
608} -
609inline QString QResourceRoot::name(int node) const -
610{ -
611 if(!node) // root
partially evaluated: !node
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:38603
0-38603
612 return QString();
never executed: return QString();
0
613 const int offset = findOffset(node);
executed (the execution status of this line is deduced): const int offset = findOffset(node);
-
614 -
615 QString ret;
executed (the execution status of this line is deduced): QString ret;
-
616 int name_offset = (tree[offset+0] << 24) + (tree[offset+1] << 16) +
executed (the execution status of this line is deduced): int name_offset = (tree[offset+0] << 24) + (tree[offset+1] << 16) +
-
617 (tree[offset+2] << 8) + (tree[offset+3] << 0);
executed (the execution status of this line is deduced): (tree[offset+2] << 8) + (tree[offset+3] << 0);
-
618 const short name_length = (names[name_offset+0] << 8) +
executed (the execution status of this line is deduced): const short name_length = (names[name_offset+0] << 8) +
-
619 (names[name_offset+1] << 0);
executed (the execution status of this line is deduced): (names[name_offset+1] << 0);
-
620 name_offset += 2;
executed (the execution status of this line is deduced): name_offset += 2;
-
621 name_offset += 4; //jump past hash
executed (the execution status of this line is deduced): name_offset += 4;
-
622 -
623 ret.resize(name_length);
executed (the execution status of this line is deduced): ret.resize(name_length);
-
624 QChar *strData = ret.data();
executed (the execution status of this line is deduced): QChar *strData = ret.data();
-
625 for(int i = 0; i < name_length*2; i+=2) {
evaluated: i < name_length*2
TRUEFALSE
yes
Evaluation Count:412595
yes
Evaluation Count:38603
38603-412595
626 QChar c(names[name_offset+i+1], names[name_offset+i]);
executed (the execution status of this line is deduced): QChar c(names[name_offset+i+1], names[name_offset+i]);
-
627 *strData = c;
executed (the execution status of this line is deduced): *strData = c;
-
628 ++strData;
executed (the execution status of this line is deduced): ++strData;
-
629 }
executed: }
Execution Count:412595
412595
630 return ret;
executed: return ret;
Execution Count:38603
38603
631} -
632 -
633int QResourceRoot::findNode(const QString &_path, const QLocale &locale) const -
634{ -
635 QString path = _path;
executed (the execution status of this line is deduced): QString path = _path;
-
636 { -
637 QString root = mappingRoot();
executed (the execution status of this line is deduced): QString root = mappingRoot();
-
638 if(!root.isEmpty()) {
partially evaluated: !root.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:29572
0-29572
639 if(root == path) {
never evaluated: root == path
0
640 path = QLatin1Char('/');
never executed (the execution status of this line is deduced): path = QLatin1Char('/');
-
641 } else {
never executed: }
0
642 if(!root.endsWith(QLatin1Char('/')))
never evaluated: !root.endsWith(QLatin1Char('/'))
0
643 root += QLatin1Char('/');
never executed: root += QLatin1Char('/');
0
644 if(path.size() >= root.size() && path.startsWith(root))
never evaluated: path.size() >= root.size()
never evaluated: path.startsWith(root)
0
645 path = path.mid(root.length()-1);
never executed: path = path.mid(root.length()-1);
0
646 if(path.isEmpty())
never evaluated: path.isEmpty()
0
647 path = QLatin1Char('/');
never executed: path = QLatin1Char('/');
0
648 }
never executed: }
0
649 } -
650 } -
651#ifdef DEBUG_RESOURCE_MATCH -
652 qDebug() << "!!!!" << "START" << path << locale.country() << locale.language(); -
653#endif -
654 -
655 if(path == QLatin1String("/"))
evaluated: path == QLatin1String("/")
TRUEFALSE
yes
Evaluation Count:18
yes
Evaluation Count:29554
18-29554
656 return 0;
executed: return 0;
Execution Count:18
18
657 -
658 //the root node is always first -
659 int child_count = (tree[6] << 24) + (tree[7] << 16) +
executed (the execution status of this line is deduced): int child_count = (tree[6] << 24) + (tree[7] << 16) +
-
660 (tree[8] << 8) + (tree[9] << 0);
executed (the execution status of this line is deduced): (tree[8] << 8) + (tree[9] << 0);
-
661 int child = (tree[10] << 24) + (tree[11] << 16) +
executed (the execution status of this line is deduced): int child = (tree[10] << 24) + (tree[11] << 16) +
-
662 (tree[12] << 8) + (tree[13] << 0);
executed (the execution status of this line is deduced): (tree[12] << 8) + (tree[13] << 0);
-
663 -
664 //now iterate up the tree -
665 int node = -1;
executed (the execution status of this line is deduced): int node = -1;
-
666 -
667 QStringSplitter splitter(path);
executed (the execution status of this line is deduced): QStringSplitter splitter(path);
-
668 while (child_count && splitter.hasNext()) {
partially evaluated: child_count
TRUEFALSE
yes
Evaluation Count:67832
no
Evaluation Count:0
evaluated: splitter.hasNext()
TRUEFALSE
yes
Evaluation Count:61722
yes
Evaluation Count:6110
0-67832
669 QStringRef segment = splitter.next();
executed (the execution status of this line is deduced): QStringRef segment = splitter.next();
-
670 -
671#ifdef DEBUG_RESOURCE_MATCH -
672 qDebug() << " CHILDREN" << segment; -
673 for(int j = 0; j < child_count; ++j) { -
674 qDebug() << " " << child+j << " :: " << name(child+j); -
675 } -
676#endif -
677 const uint h = qt_hash(segment.toString());
executed (the execution status of this line is deduced): const uint h = qt_hash(segment.toString());
-
678 -
679 //do the binary search for the hash -
680 int l = 0, r = child_count-1;
executed (the execution status of this line is deduced): int l = 0, r = child_count-1;
-
681 int sub_node = (l+r+1)/2;
executed (the execution status of this line is deduced): int sub_node = (l+r+1)/2;
-
682 while(r != l) {
evaluated: r != l
TRUEFALSE
yes
Evaluation Count:55035
yes
Evaluation Count:53682
53682-55035
683 const uint sub_node_hash = hash(child+sub_node);
executed (the execution status of this line is deduced): const uint sub_node_hash = hash(child+sub_node);
-
684 if(h == sub_node_hash)
evaluated: h == sub_node_hash
TRUEFALSE
yes
Evaluation Count:8040
yes
Evaluation Count:46995
8040-46995
685 break;
executed: break;
Execution Count:8040
8040
686 else if(h < sub_node_hash)
evaluated: h < sub_node_hash
TRUEFALSE
yes
Evaluation Count:27640
yes
Evaluation Count:19355
19355-27640
687 r = sub_node - 1;
executed: r = sub_node - 1;
Execution Count:27640
27640
688 else -
689 l = sub_node;
executed: l = sub_node;
Execution Count:19355
19355
690 sub_node = (l + r + 1) / 2;
executed (the execution status of this line is deduced): sub_node = (l + r + 1) / 2;
-
691 }
executed: }
Execution Count:46995
46995
692 sub_node += child;
executed (the execution status of this line is deduced): sub_node += child;
-
693 -
694 //now do the "harder" compares -
695 bool found = false;
executed (the execution status of this line is deduced): bool found = false;
-
696 if(hash(sub_node) == h) {
evaluated: hash(sub_node) == h
TRUEFALSE
yes
Evaluation Count:38420
yes
Evaluation Count:23302
23302-38420
697 while(sub_node > child && hash(sub_node-1) == h) //backup for collisions
evaluated: sub_node > child
TRUEFALSE
yes
Evaluation Count:8040
yes
Evaluation Count:30380
partially evaluated: hash(sub_node-1) == h
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:8040
0-30380
698 --sub_node;
never executed: --sub_node;
0
699 for(; sub_node < child+child_count && hash(sub_node) == h; ++sub_node) { //here we go...
evaluated: sub_node < child+child_count
TRUEFALSE
yes
Evaluation Count:44340
yes
Evaluation Count:190
evaluated: hash(sub_node) == h
TRUEFALSE
yes
Evaluation Count:38420
yes
Evaluation Count:5920
190-44340
700 if(name(sub_node) == segment) {
partially evaluated: name(sub_node) == segment
TRUEFALSE
yes
Evaluation Count:38420
no
Evaluation Count:0
0-38420
701 found = true;
executed (the execution status of this line is deduced): found = true;
-
702 int offset = findOffset(sub_node);
executed (the execution status of this line is deduced): int offset = findOffset(sub_node);
-
703#ifdef DEBUG_RESOURCE_MATCH -
704 qDebug() << " TRY" << sub_node << name(sub_node) << offset; -
705#endif -
706 offset += 4; //jump past name
executed (the execution status of this line is deduced): offset += 4;
-
707 -
708 const short flags = (tree[offset+0] << 8) +
executed (the execution status of this line is deduced): const short flags = (tree[offset+0] << 8) +
-
709 (tree[offset+1] << 0);
executed (the execution status of this line is deduced): (tree[offset+1] << 0);
-
710 offset += 2;
executed (the execution status of this line is deduced): offset += 2;
-
711 -
712 if(!splitter.hasNext()) {
evaluated: !splitter.hasNext()
TRUEFALSE
yes
Evaluation Count:6252
yes
Evaluation Count:32168
6252-32168
713 if(!(flags & Directory)) {
evaluated: !(flags & Directory)
TRUEFALSE
yes
Evaluation Count:6124
yes
Evaluation Count:128
128-6124
714 const short country = (tree[offset+0] << 8) +
executed (the execution status of this line is deduced): const short country = (tree[offset+0] << 8) +
-
715 (tree[offset+1] << 0);
executed (the execution status of this line is deduced): (tree[offset+1] << 0);
-
716 offset += 2;
executed (the execution status of this line is deduced): offset += 2;
-
717 -
718 const short language = (tree[offset+0] << 8) +
executed (the execution status of this line is deduced): const short language = (tree[offset+0] << 8) +
-
719 (tree[offset+1] << 0);
executed (the execution status of this line is deduced): (tree[offset+1] << 0);
-
720 offset += 2;
executed (the execution status of this line is deduced): offset += 2;
-
721#ifdef DEBUG_RESOURCE_MATCH -
722 qDebug() << " " << "LOCALE" << country << language; -
723#endif -
724 if(country == locale.country() && language == locale.language()) {
evaluated: country == locale.country()
TRUEFALSE
yes
Evaluation Count:14
yes
Evaluation Count:6110
partially evaluated: language == locale.language()
TRUEFALSE
yes
Evaluation Count:14
no
Evaluation Count:0
0-6110
725#ifdef DEBUG_RESOURCE_MATCH -
726 qDebug() << "!!!!" << "FINISHED" << __LINE__ << sub_node; -
727#endif -
728 return sub_node;
executed: return sub_node;
Execution Count:14
14
729 } else if((country == QLocale::AnyCountry && language == locale.language()) ||
partially evaluated: country == QLocale::AnyCountry
TRUEFALSE
yes
Evaluation Count:6110
no
Evaluation Count:0
partially evaluated: language == locale.language()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:6110
0-6110
730 (country == QLocale::AnyCountry && language == QLocale::C && node == -1)) {
partially evaluated: country == QLocale::AnyCountry
TRUEFALSE
yes
Evaluation Count:6110
no
Evaluation Count:0
partially evaluated: language == QLocale::C
TRUEFALSE
yes
Evaluation Count:6110
no
Evaluation Count:0
partially evaluated: node == -1
TRUEFALSE
yes
Evaluation Count:6110
no
Evaluation Count:0
0-6110
731 node = sub_node;
executed (the execution status of this line is deduced): node = sub_node;
-
732 }
executed: }
Execution Count:6110
6110
733 continue;
executed: continue;
Execution Count:6110
6110
734 } else { -
735#ifdef DEBUG_RESOURCE_MATCH -
736 qDebug() << "!!!!" << "FINISHED" << __LINE__ << sub_node; -
737#endif -
738 -
739 return sub_node;
executed: return sub_node;
Execution Count:128
128
740 } -
741 } -
742 -
743 if(!(flags & Directory))
partially evaluated: !(flags & Directory)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:32168
0-32168
744 return -1;
never executed: return -1;
0
745 -
746 child_count = (tree[offset+0] << 24) + (tree[offset+1] << 16) +
executed (the execution status of this line is deduced): child_count = (tree[offset+0] << 24) + (tree[offset+1] << 16) +
-
747 (tree[offset+2] << 8) + (tree[offset+3] << 0);
executed (the execution status of this line is deduced): (tree[offset+2] << 8) + (tree[offset+3] << 0);
-
748 offset += 4;
executed (the execution status of this line is deduced): offset += 4;
-
749 child = (tree[offset+0] << 24) + (tree[offset+1] << 16) +
executed (the execution status of this line is deduced): child = (tree[offset+0] << 24) + (tree[offset+1] << 16) +
-
750 (tree[offset+2] << 8) + (tree[offset+3] << 0);
executed (the execution status of this line is deduced): (tree[offset+2] << 8) + (tree[offset+3] << 0);
-
751 break;
executed: break;
Execution Count:32168
32168
752 } -
753 }
never executed: }
0
754 }
executed: }
Execution Count:38278
38278
755 if(!found)
evaluated: !found
TRUEFALSE
yes
Evaluation Count:23302
yes
Evaluation Count:38278
23302-38278
756 break;
executed: break;
Execution Count:23302
23302
757 }
executed: }
Execution Count:38278
38278
758#ifdef DEBUG_RESOURCE_MATCH -
759 qDebug() << "!!!!" << "FINISHED" << __LINE__ << node; -
760#endif -
761 return node;
executed: return node;
Execution Count:29412
29412
762} -
763short QResourceRoot::flags(int node) const -
764{ -
765 if(node == -1)
partially evaluated: node == -1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:12376
0-12376
766 return 0;
never executed: return 0;
0
767 const int offset = findOffset(node) + 4; //jump past name
executed (the execution status of this line is deduced): const int offset = findOffset(node) + 4;
-
768 return (tree[offset+0] << 8) + (tree[offset+1] << 0);
executed: return (tree[offset+0] << 8) + (tree[offset+1] << 0);
Execution Count:12376
12376
769} -
770const uchar *QResourceRoot::data(int node, qint64 *size) const -
771{ -
772 if(node == -1) {
partially evaluated: node == -1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:6124
0-6124
773 *size = 0;
never executed (the execution status of this line is deduced): *size = 0;
-
774 return 0;
never executed: return 0;
0
775 } -
776 int offset = findOffset(node) + 4; //jump past name
executed (the execution status of this line is deduced): int offset = findOffset(node) + 4;
-
777 -
778 const short flags = (tree[offset+0] << 8) + (tree[offset+1] << 0);
executed (the execution status of this line is deduced): const short flags = (tree[offset+0] << 8) + (tree[offset+1] << 0);
-
779 offset += 2;
executed (the execution status of this line is deduced): offset += 2;
-
780 -
781 offset += 4; //jump past locale
executed (the execution status of this line is deduced): offset += 4;
-
782 -
783 if(!(flags & Directory)) {
partially evaluated: !(flags & Directory)
TRUEFALSE
yes
Evaluation Count:6124
no
Evaluation Count:0
0-6124
784 const int data_offset = (tree[offset+0] << 24) + (tree[offset+1] << 16) +
executed (the execution status of this line is deduced): const int data_offset = (tree[offset+0] << 24) + (tree[offset+1] << 16) +
-
785 (tree[offset+2] << 8) + (tree[offset+3] << 0);
executed (the execution status of this line is deduced): (tree[offset+2] << 8) + (tree[offset+3] << 0);
-
786 const uint data_length = (payloads[data_offset+0] << 24) + (payloads[data_offset+1] << 16) +
executed (the execution status of this line is deduced): const uint data_length = (payloads[data_offset+0] << 24) + (payloads[data_offset+1] << 16) +
-
787 (payloads[data_offset+2] << 8) + (payloads[data_offset+3] << 0);
executed (the execution status of this line is deduced): (payloads[data_offset+2] << 8) + (payloads[data_offset+3] << 0);
-
788 const uchar *ret = payloads+data_offset+4;
executed (the execution status of this line is deduced): const uchar *ret = payloads+data_offset+4;
-
789 *size = data_length;
executed (the execution status of this line is deduced): *size = data_length;
-
790 return ret;
executed: return ret;
Execution Count:6124
6124
791 } -
792 *size = 0;
never executed (the execution status of this line is deduced): *size = 0;
-
793 return 0;
never executed: return 0;
0
794} -
795QStringList QResourceRoot::children(int node) const -
796{ -
797 if(node == -1)
partially evaluated: node == -1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:18
0-18
798 return QStringList();
never executed: return QStringList();
0
799 int offset = findOffset(node) + 4; //jump past name
executed (the execution status of this line is deduced): int offset = findOffset(node) + 4;
-
800 -
801 const short flags = (tree[offset+0] << 8) + (tree[offset+1] << 0);
executed (the execution status of this line is deduced): const short flags = (tree[offset+0] << 8) + (tree[offset+1] << 0);
-
802 offset += 2;
executed (the execution status of this line is deduced): offset += 2;
-
803 -
804 QStringList ret;
executed (the execution status of this line is deduced): QStringList ret;
-
805 if(flags & Directory) {
partially evaluated: flags & Directory
TRUEFALSE
yes
Evaluation Count:18
no
Evaluation Count:0
0-18
806 const int child_count = (tree[offset+0] << 24) + (tree[offset+1] << 16) +
executed (the execution status of this line is deduced): const int child_count = (tree[offset+0] << 24) + (tree[offset+1] << 16) +
-
807 (tree[offset+2] << 8) + (tree[offset+3] << 0);
executed (the execution status of this line is deduced): (tree[offset+2] << 8) + (tree[offset+3] << 0);
-
808 offset += 4;
executed (the execution status of this line is deduced): offset += 4;
-
809 const int child_off = (tree[offset+0] << 24) + (tree[offset+1] << 16) +
executed (the execution status of this line is deduced): const int child_off = (tree[offset+0] << 24) + (tree[offset+1] << 16) +
-
810 (tree[offset+2] << 8) + (tree[offset+3] << 0);
executed (the execution status of this line is deduced): (tree[offset+2] << 8) + (tree[offset+3] << 0);
-
811 for(int i = child_off; i < child_off+child_count; ++i)
evaluated: i < child_off+child_count
TRUEFALSE
yes
Evaluation Count:183
yes
Evaluation Count:18
18-183
812 ret << name(i);
executed: ret << name(i);
Execution Count:183
183
813 }
executed: }
Execution Count:18
18
814 return ret;
executed: return ret;
Execution Count:18
18
815} -
816bool QResourceRoot::mappingRootSubdir(const QString &path, QString *match) const -
817{ -
818 const QString root = mappingRoot();
executed (the execution status of this line is deduced): const QString root = mappingRoot();
-
819 if(!root.isEmpty()) {
partially evaluated: !root.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:23320
0-23320
820 const QStringList root_segments = root.split(QLatin1Char('/'), QString::SkipEmptyParts),
never executed (the execution status of this line is deduced): const QStringList root_segments = root.split(QLatin1Char('/'), QString::SkipEmptyParts),
-
821 path_segments = path.split(QLatin1Char('/'), QString::SkipEmptyParts);
never executed (the execution status of this line is deduced): path_segments = path.split(QLatin1Char('/'), QString::SkipEmptyParts);
-
822 if(path_segments.size() <= root_segments.size()) {
never evaluated: path_segments.size() <= root_segments.size()
0
823 int matched = 0;
never executed (the execution status of this line is deduced): int matched = 0;
-
824 for(int i = 0; i < path_segments.size(); ++i) {
never evaluated: i < path_segments.size()
0
825 if(root_segments[i] != path_segments[i])
never evaluated: root_segments[i] != path_segments[i]
0
826 break;
never executed: break;
0
827 ++matched;
never executed (the execution status of this line is deduced): ++matched;
-
828 }
never executed: }
0
829 if(matched == path_segments.size()) {
never evaluated: matched == path_segments.size()
0
830 if(match && root_segments.size() > matched)
never evaluated: match
never evaluated: root_segments.size() > matched
0
831 *match = root_segments.at(matched);
never executed: *match = root_segments.at(matched);
0
832 return true;
never executed: return true;
0
833 } -
834 }
never executed: }
0
835 }
never executed: }
0
836 return false;
executed: return false;
Execution Count:23320
23320
837} -
838 -
839Q_CORE_EXPORT bool qRegisterResourceData(int version, const unsigned char *tree, -
840 const unsigned char *name, const unsigned char *data) -
841{ -
842 QMutexLocker lock(resourceMutex());
executed (the execution status of this line is deduced): QMutexLocker lock(resourceMutex());
-
843 if(version == 0x01 && resourceList()) {
partially evaluated: version == 0x01
TRUEFALSE
yes
Evaluation Count:160
no
Evaluation Count:0
partially evaluated: resourceList()
TRUEFALSE
yes
Evaluation Count:160
no
Evaluation Count:0
0-160
844 bool found = false;
executed (the execution status of this line is deduced): bool found = false;
-
845 QResourceRoot res(tree, name, data);
executed (the execution status of this line is deduced): QResourceRoot res(tree, name, data);
-
846 for(int i = 0; i < resourceList()->size(); ++i) {
partially evaluated: i < resourceList()->size()
TRUEFALSE
yes
Evaluation Count:400
no
Evaluation Count:0
0-400
847 if(*resourceList()->at(i) == res) {
evaluated: *resourceList()->at(i) == res
TRUEFALSE
yes
Evaluation Count:160
yes
Evaluation Count:240
160-240
848 found = true;
executed (the execution status of this line is deduced): found = true;
-
849 break;
executed: break;
Execution Count:160
160
850 } -
851 }
executed: }
Execution Count:240
240
852 if(!found) {
partially evaluated: !found
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:160
0-160
853 QResourceRoot *root = new QResourceRoot(tree, name, data);
never executed (the execution status of this line is deduced): QResourceRoot *root = new QResourceRoot(tree, name, data);
-
854 root->ref.ref();
never executed (the execution status of this line is deduced): root->ref.ref();
-
855 resourceList()->append(root);
never executed (the execution status of this line is deduced): resourceList()->append(root);
-
856 }
never executed: }
0
857 return true;
executed: return true;
Execution Count:160
160
858 } -
859 return false;
never executed: return false;
0
860} -
861 -
862Q_CORE_EXPORT bool qUnregisterResourceData(int version, const unsigned char *tree, -
863 const unsigned char *name, const unsigned char *data) -
864{ -
865 QMutexLocker lock(resourceMutex());
executed (the execution status of this line is deduced): QMutexLocker lock(resourceMutex());
-
866 if(version == 0x01 && resourceList()) {
partially evaluated: version == 0x01
TRUEFALSE
yes
Evaluation Count:23
no
Evaluation Count:0
partially evaluated: resourceList()
TRUEFALSE
yes
Evaluation Count:23
no
Evaluation Count:0
0-23
867 QResourceRoot res(tree, name, data);
executed (the execution status of this line is deduced): QResourceRoot res(tree, name, data);
-
868 for(int i = 0; i < resourceList()->size(); ) {
evaluated: i < resourceList()->size()
TRUEFALSE
yes
Evaluation Count:63
yes
Evaluation Count:23
23-63
869 if(*resourceList()->at(i) == res) {
evaluated: *resourceList()->at(i) == res
TRUEFALSE
yes
Evaluation Count:23
yes
Evaluation Count:40
23-40
870 QResourceRoot *root = resourceList()->takeAt(i);
executed (the execution status of this line is deduced): QResourceRoot *root = resourceList()->takeAt(i);
-
871 if(!root->ref.deref())
partially evaluated: !root->ref.deref()
TRUEFALSE
yes
Evaluation Count:23
no
Evaluation Count:0
0-23
872 delete root;
executed: delete root;
Execution Count:23
23
873 } else {
executed: }
Execution Count:23
23
874 ++i;
executed (the execution status of this line is deduced): ++i;
-
875 }
executed: }
Execution Count:40
40
876 } -
877 return true;
executed: return true;
Execution Count:23
23
878 } -
879 return false;
never executed: return false;
0
880} -
881 -
882//run time resource creation -
883 -
884class QDynamicBufferResourceRoot: public QResourceRoot -
885{ -
886 QString root; -
887 const uchar *buffer; -
888 -
889public: -
890 inline QDynamicBufferResourceRoot(const QString &_root) : root(_root), buffer(0) { }
never executed: }
0
891 inline ~QDynamicBufferResourceRoot() { } -
892 inline const uchar *mappingBuffer() const { return buffer; }
never executed: return buffer;
0
893 virtual QString mappingRoot() const { return root; }
never executed: return root;
0
894 virtual ResourceRootType type() const { return Resource_Buffer; }
never executed: return Resource_Buffer;
0
895 -
896 bool registerSelf(const uchar *b) { -
897 //setup the data now -
898 int offset = 0;
never executed (the execution status of this line is deduced): int offset = 0;
-
899 -
900 //magic number -
901 if(b[offset+0] != 'q' || b[offset+1] != 'r' ||
never evaluated: b[offset+0] != 'q'
never evaluated: b[offset+1] != 'r'
0
902 b[offset+2] != 'e' || b[offset+3] != 's') {
never evaluated: b[offset+2] != 'e'
never evaluated: b[offset+3] != 's'
0
903 return false;
never executed: return false;
0
904 } -
905 offset += 4;
never executed (the execution status of this line is deduced): offset += 4;
-
906 -
907 const int version = (b[offset+0] << 24) + (b[offset+1] << 16) +
never executed (the execution status of this line is deduced): const int version = (b[offset+0] << 24) + (b[offset+1] << 16) +
-
908 (b[offset+2] << 8) + (b[offset+3] << 0);
never executed (the execution status of this line is deduced): (b[offset+2] << 8) + (b[offset+3] << 0);
-
909 offset += 4;
never executed (the execution status of this line is deduced): offset += 4;
-
910 -
911 const int tree_offset = (b[offset+0] << 24) + (b[offset+1] << 16) +
never executed (the execution status of this line is deduced): const int tree_offset = (b[offset+0] << 24) + (b[offset+1] << 16) +
-
912 (b[offset+2] << 8) + (b[offset+3] << 0);
never executed (the execution status of this line is deduced): (b[offset+2] << 8) + (b[offset+3] << 0);
-
913 offset += 4;
never executed (the execution status of this line is deduced): offset += 4;
-
914 -
915 const int data_offset = (b[offset+0] << 24) + (b[offset+1] << 16) +
never executed (the execution status of this line is deduced): const int data_offset = (b[offset+0] << 24) + (b[offset+1] << 16) +
-
916 (b[offset+2] << 8) + (b[offset+3] << 0);
never executed (the execution status of this line is deduced): (b[offset+2] << 8) + (b[offset+3] << 0);
-
917 offset += 4;
never executed (the execution status of this line is deduced): offset += 4;
-
918 -
919 const int name_offset = (b[offset+0] << 24) + (b[offset+1] << 16) +
never executed (the execution status of this line is deduced): const int name_offset = (b[offset+0] << 24) + (b[offset+1] << 16) +
-
920 (b[offset+2] << 8) + (b[offset+3] << 0);
never executed (the execution status of this line is deduced): (b[offset+2] << 8) + (b[offset+3] << 0);
-
921 offset += 4;
never executed (the execution status of this line is deduced): offset += 4;
-
922 -
923 if(version == 0x01) {
never evaluated: version == 0x01
0
924 buffer = b;
never executed (the execution status of this line is deduced): buffer = b;
-
925 setSource(b+tree_offset, b+name_offset, b+data_offset);
never executed (the execution status of this line is deduced): setSource(b+tree_offset, b+name_offset, b+data_offset);
-
926 return true;
never executed: return true;
0
927 } -
928 return false;
never executed: return false;
0
929 } -
930}; -
931 -
932#if defined(Q_OS_UNIX) && !defined (Q_OS_NACL) && !defined(Q_OS_INTEGRITY) -
933#define QT_USE_MMAP -
934#endif -
935 -
936// most of the headers below are already included in qplatformdefs.h -
937// also this lacks Large File support but that's probably irrelevant -
938#if defined(QT_USE_MMAP) -
939// for mmap -
940QT_BEGIN_INCLUDE_NAMESPACE -
941#include <sys/mman.h> -
942#include <errno.h> -
943QT_END_INCLUDE_NAMESPACE -
944#endif -
945 -
946 -
947 -
948class QDynamicFileResourceRoot: public QDynamicBufferResourceRoot -
949{ -
950 QString fileName; -
951 // for mmap'ed files, this is what needs to be unmapped. -
952 uchar *unmapPointer; -
953 unsigned int unmapLength; -
954 -
955public: -
956 inline QDynamicFileResourceRoot(const QString &_root) : QDynamicBufferResourceRoot(_root), unmapPointer(0), unmapLength(0) { }
never executed: }
0
957 ~QDynamicFileResourceRoot() { -
958#if defined(QT_USE_MMAP) -
959 if (unmapPointer) {
never evaluated: unmapPointer
0
960 munmap((char*)unmapPointer, unmapLength);
never executed (the execution status of this line is deduced): munmap((char*)unmapPointer, unmapLength);
-
961 unmapPointer = 0;
never executed (the execution status of this line is deduced): unmapPointer = 0;
-
962 unmapLength = 0;
never executed (the execution status of this line is deduced): unmapLength = 0;
-
963 } else
never executed: }
0
964#endif -
965 { -
966 delete [] (uchar *)mappingBuffer();
never executed (the execution status of this line is deduced): delete [] (uchar *)mappingBuffer();
-
967 }
never executed: }
0
968 } -
969 QString mappingFile() const { return fileName; }
never executed: return fileName;
0
970 virtual ResourceRootType type() const { return Resource_File; }
never executed: return Resource_File;
0
971 -
972 bool registerSelf(const QString &f) { -
973 bool fromMM = false;
never executed (the execution status of this line is deduced): bool fromMM = false;
-
974 uchar *data = 0;
never executed (the execution status of this line is deduced): uchar *data = 0;
-
975 unsigned int data_len = 0;
never executed (the execution status of this line is deduced): unsigned int data_len = 0;
-
976 -
977#ifdef QT_USE_MMAP -
978 -
979#ifndef MAP_FILE -
980#define MAP_FILE 0 -
981#endif -
982#ifndef MAP_FAILED -
983#define MAP_FAILED -1 -
984#endif -
985 -
986 int fd = QT_OPEN(QFile::encodeName(f), O_RDONLY,
never executed (the execution status of this line is deduced): int fd = qt_safe_open(QFile::encodeName(f), 00,
-
987#if defined(Q_OS_WIN)
never executed (the execution status of this line is deduced):
-
988 _S_IREAD | _S_IWRITE
never executed (the execution status of this line is deduced):
-
989#else
never executed (the execution status of this line is deduced):
-
990 0666
never executed (the execution status of this line is deduced): 0666
-
991#endif
never executed (the execution status of this line is deduced):
-
992 );
never executed (the execution status of this line is deduced): );
-
993 if (fd >= 0) {
never evaluated: fd >= 0
0
994 QT_STATBUF st;
never executed (the execution status of this line is deduced): struct stat64 st;
-
995 if (!QT_FSTAT(fd, &st)) {
never evaluated: !::fstat64(fd, &st)
0
996 uchar *ptr;
never executed (the execution status of this line is deduced): uchar *ptr;
-
997 ptr = reinterpret_cast<uchar *>(
never executed (the execution status of this line is deduced): ptr = reinterpret_cast<uchar *>(
-
998 mmap(0, st.st_size, // any address, whole file
never executed (the execution status of this line is deduced): mmap(0, st.st_size,
-
999 PROT_READ, // read-only memory
never executed (the execution status of this line is deduced): 0x1,
-
1000 MAP_FILE | MAP_PRIVATE, // swap-backed map from file
never executed (the execution status of this line is deduced): 0 | 0x02,
-
1001 fd, 0)); // from offset 0 of fd
never executed (the execution status of this line is deduced): fd, 0));
-
1002 if (ptr && ptr != reinterpret_cast<uchar *>(MAP_FAILED)) {
never evaluated: ptr
never evaluated: ptr != reinterpret_cast<uchar *>(((void *) -1))
0
1003 data = ptr;
never executed (the execution status of this line is deduced): data = ptr;
-
1004 data_len = st.st_size;
never executed (the execution status of this line is deduced): data_len = st.st_size;
-
1005 fromMM = true;
never executed (the execution status of this line is deduced): fromMM = true;
-
1006 }
never executed: }
0
1007 }
never executed: }
0
1008 ::close(fd);
never executed (the execution status of this line is deduced): ::close(fd);
-
1009 }
never executed: }
0
1010#endif // QT_USE_MMAP -
1011 if(!data) {
never evaluated: !data
0
1012 QFile file(f);
never executed (the execution status of this line is deduced): QFile file(f);
-
1013 if (!file.exists())
never evaluated: !file.exists()
0
1014 return false;
never executed: return false;
0
1015 data_len = file.size();
never executed (the execution status of this line is deduced): data_len = file.size();
-
1016 data = new uchar[data_len];
never executed (the execution status of this line is deduced): data = new uchar[data_len];
-
1017 -
1018 bool ok = false;
never executed (the execution status of this line is deduced): bool ok = false;
-
1019 if (file.open(QIODevice::ReadOnly))
never evaluated: file.open(QIODevice::ReadOnly)
0
1020 ok = (data_len == (uint)file.read((char*)data, data_len));
never executed: ok = (data_len == (uint)file.read((char*)data, data_len));
0
1021 if (!ok) {
never evaluated: !ok
0
1022 delete [] data;
never executed (the execution status of this line is deduced): delete [] data;
-
1023 data = 0;
never executed (the execution status of this line is deduced): data = 0;
-
1024 data_len = 0;
never executed (the execution status of this line is deduced): data_len = 0;
-
1025 return false;
never executed: return false;
0
1026 } -
1027 fromMM = false;
never executed (the execution status of this line is deduced): fromMM = false;
-
1028 }
never executed: }
0
1029 if(data && QDynamicBufferResourceRoot::registerSelf(data)) {
never evaluated: data
never evaluated: QDynamicBufferResourceRoot::registerSelf(data)
0
1030 if(fromMM) {
never evaluated: fromMM
0
1031 unmapPointer = data;
never executed (the execution status of this line is deduced): unmapPointer = data;
-
1032 unmapLength = data_len;
never executed (the execution status of this line is deduced): unmapLength = data_len;
-
1033 }
never executed: }
0
1034 fileName = f;
never executed (the execution status of this line is deduced): fileName = f;
-
1035 return true;
never executed: return true;
0
1036 } -
1037 return false;
never executed: return false;
0
1038 } -
1039}; -
1040 -
1041static QString qt_resource_fixResourceRoot(QString r) { -
1042 if(!r.isEmpty()) {
never evaluated: !r.isEmpty()
0
1043 if(r.startsWith(QLatin1Char(':')))
never evaluated: r.startsWith(QLatin1Char(':'))
0
1044 r = r.mid(1);
never executed: r = r.mid(1);
0
1045 if(!r.isEmpty())
never evaluated: !r.isEmpty()
0
1046 r = QDir::cleanPath(r);
never executed: r = QDir::cleanPath(r);
0
1047 }
never executed: }
0
1048 return r;
never executed: return r;
0
1049} -
1050 -
1051 -
1052/*! -
1053 \fn bool QResource::registerResource(const QString &rccFileName, const QString &mapRoot) -
1054 -
1055 Registers the resource with the given \a rccFileName at the location in the -
1056 resource tree specified by \a mapRoot, and returns true if the file is -
1057 successfully opened; otherwise returns false. -
1058 -
1059 \sa unregisterResource() -
1060*/ -
1061 -
1062bool -
1063QResource::registerResource(const QString &rccFilename, const QString &resourceRoot) -
1064{ -
1065 QString r = qt_resource_fixResourceRoot(resourceRoot);
never executed (the execution status of this line is deduced): QString r = qt_resource_fixResourceRoot(resourceRoot);
-
1066 if(!r.isEmpty() && r[0] != QLatin1Char('/')) {
never evaluated: !r.isEmpty()
never evaluated: r[0] != QLatin1Char('/')
0
1067 qWarning("QDir::registerResource: Registering a resource [%s] must be rooted in an absolute path (start with /) [%s]",
never executed (the execution status of this line is deduced): QMessageLogger("io/qresource.cpp", 1067, __PRETTY_FUNCTION__).warning("QDir::registerResource: Registering a resource [%s] must be rooted in an absolute path (start with /) [%s]",
-
1068 rccFilename.toLocal8Bit().data(), resourceRoot.toLocal8Bit().data());
never executed (the execution status of this line is deduced): rccFilename.toLocal8Bit().data(), resourceRoot.toLocal8Bit().data());
-
1069 return false;
never executed: return false;
0
1070 } -
1071 -
1072 QDynamicFileResourceRoot *root = new QDynamicFileResourceRoot(r);
never executed (the execution status of this line is deduced): QDynamicFileResourceRoot *root = new QDynamicFileResourceRoot(r);
-
1073 if(root->registerSelf(rccFilename)) {
never evaluated: root->registerSelf(rccFilename)
0
1074 root->ref.ref();
never executed (the execution status of this line is deduced): root->ref.ref();
-
1075 QMutexLocker lock(resourceMutex());
never executed (the execution status of this line is deduced): QMutexLocker lock(resourceMutex());
-
1076 resourceList()->append(root);
never executed (the execution status of this line is deduced): resourceList()->append(root);
-
1077 return true;
never executed: return true;
0
1078 } -
1079 delete root;
never executed (the execution status of this line is deduced): delete root;
-
1080 return false;
never executed: return false;
0
1081} -
1082 -
1083/*! -
1084 \fn bool QResource::unregisterResource(const QString &rccFileName, const QString &mapRoot) -
1085 -
1086 Unregisters the resource with the given \a rccFileName at the location in -
1087 the resource tree specified by \a mapRoot, and returns true if the -
1088 resource is successfully unloaded and no references exist for the -
1089 resource; otherwise returns false. -
1090 -
1091 \sa registerResource() -
1092*/ -
1093 -
1094bool -
1095QResource::unregisterResource(const QString &rccFilename, const QString &resourceRoot) -
1096{ -
1097 QString r = qt_resource_fixResourceRoot(resourceRoot);
never executed (the execution status of this line is deduced): QString r = qt_resource_fixResourceRoot(resourceRoot);
-
1098 -
1099 QMutexLocker lock(resourceMutex());
never executed (the execution status of this line is deduced): QMutexLocker lock(resourceMutex());
-
1100 ResourceList *list = resourceList();
never executed (the execution status of this line is deduced): ResourceList *list = resourceList();
-
1101 for(int i = 0; i < list->size(); ++i) {
never evaluated: i < list->size()
0
1102 QResourceRoot *res = list->at(i);
never executed (the execution status of this line is deduced): QResourceRoot *res = list->at(i);
-
1103 if(res->type() == QResourceRoot::Resource_File) {
never evaluated: res->type() == QResourceRoot::Resource_File
0
1104 QDynamicFileResourceRoot *root = reinterpret_cast<QDynamicFileResourceRoot*>(res);
never executed (the execution status of this line is deduced): QDynamicFileResourceRoot *root = reinterpret_cast<QDynamicFileResourceRoot*>(res);
-
1105 if(root->mappingFile() == rccFilename && root->mappingRoot() == r) {
never evaluated: root->mappingFile() == rccFilename
never evaluated: root->mappingRoot() == r
0
1106 resourceList()->removeAt(i);
never executed (the execution status of this line is deduced): resourceList()->removeAt(i);
-
1107 if(!root->ref.deref()) {
never evaluated: !root->ref.deref()
0
1108 delete root;
never executed (the execution status of this line is deduced): delete root;
-
1109 return true;
never executed: return true;
0
1110 } -
1111 return false;
never executed: return false;
0
1112 } -
1113 }
never executed: }
0
1114 }
never executed: }
0
1115 return false;
never executed: return false;
0
1116} -
1117 -
1118 -
1119/*! -
1120 \fn bool QResource::registerResource(const uchar *rccData, const QString &mapRoot) -
1121 \since 4.3 -
1122 -
1123 Registers the resource with the given \a rccData at the location in the -
1124 resource tree specified by \a mapRoot, and returns true if the file is -
1125 successfully opened; otherwise returns false. -
1126 -
1127 \warning The data must remain valid throughout the life of any QFile -
1128 that may reference the resource data. -
1129 -
1130 \sa unregisterResource() -
1131*/ -
1132 -
1133bool -
1134QResource::registerResource(const uchar *rccData, const QString &resourceRoot) -
1135{ -
1136 QString r = qt_resource_fixResourceRoot(resourceRoot);
never executed (the execution status of this line is deduced): QString r = qt_resource_fixResourceRoot(resourceRoot);
-
1137 if(!r.isEmpty() && r[0] != QLatin1Char('/')) {
never evaluated: !r.isEmpty()
never evaluated: r[0] != QLatin1Char('/')
0
1138 qWarning("QDir::registerResource: Registering a resource [%p] must be rooted in an absolute path (start with /) [%s]",
never executed (the execution status of this line is deduced): QMessageLogger("io/qresource.cpp", 1138, __PRETTY_FUNCTION__).warning("QDir::registerResource: Registering a resource [%p] must be rooted in an absolute path (start with /) [%s]",
-
1139 rccData, resourceRoot.toLocal8Bit().data());
never executed (the execution status of this line is deduced): rccData, resourceRoot.toLocal8Bit().data());
-
1140 return false;
never executed: return false;
0
1141 } -
1142 -
1143 QDynamicBufferResourceRoot *root = new QDynamicBufferResourceRoot(r);
never executed (the execution status of this line is deduced): QDynamicBufferResourceRoot *root = new QDynamicBufferResourceRoot(r);
-
1144 if(root->registerSelf(rccData)) {
never evaluated: root->registerSelf(rccData)
0
1145 root->ref.ref();
never executed (the execution status of this line is deduced): root->ref.ref();
-
1146 QMutexLocker lock(resourceMutex());
never executed (the execution status of this line is deduced): QMutexLocker lock(resourceMutex());
-
1147 resourceList()->append(root);
never executed (the execution status of this line is deduced): resourceList()->append(root);
-
1148 return true;
never executed: return true;
0
1149 } -
1150 delete root;
never executed (the execution status of this line is deduced): delete root;
-
1151 return false;
never executed: return false;
0
1152} -
1153 -
1154/*! -
1155 \fn bool QResource::unregisterResource(const uchar *rccData, const QString &mapRoot) -
1156 \since 4.3 -
1157 -
1158 Unregisters the resource with the given \a rccData at the location in the -
1159 resource tree specified by \a mapRoot, and returns true if the resource is -
1160 successfully unloaded and no references exist into the resource; otherwise returns false. -
1161 -
1162 \sa registerResource() -
1163*/ -
1164 -
1165bool -
1166QResource::unregisterResource(const uchar *rccData, const QString &resourceRoot) -
1167{ -
1168 QString r = qt_resource_fixResourceRoot(resourceRoot);
never executed (the execution status of this line is deduced): QString r = qt_resource_fixResourceRoot(resourceRoot);
-
1169 -
1170 QMutexLocker lock(resourceMutex());
never executed (the execution status of this line is deduced): QMutexLocker lock(resourceMutex());
-
1171 ResourceList *list = resourceList();
never executed (the execution status of this line is deduced): ResourceList *list = resourceList();
-
1172 for(int i = 0; i < list->size(); ++i) {
never evaluated: i < list->size()
0
1173 QResourceRoot *res = list->at(i);
never executed (the execution status of this line is deduced): QResourceRoot *res = list->at(i);
-
1174 if(res->type() == QResourceRoot::Resource_Buffer) {
never evaluated: res->type() == QResourceRoot::Resource_Buffer
0
1175 QDynamicBufferResourceRoot *root = reinterpret_cast<QDynamicBufferResourceRoot*>(res);
never executed (the execution status of this line is deduced): QDynamicBufferResourceRoot *root = reinterpret_cast<QDynamicBufferResourceRoot*>(res);
-
1176 if(root->mappingBuffer() == rccData && root->mappingRoot() == r) {
never evaluated: root->mappingBuffer() == rccData
never evaluated: root->mappingRoot() == r
0
1177 resourceList()->removeAt(i);
never executed (the execution status of this line is deduced): resourceList()->removeAt(i);
-
1178 if(!root->ref.deref()) {
never evaluated: !root->ref.deref()
0
1179 delete root;
never executed (the execution status of this line is deduced): delete root;
-
1180 return true;
never executed: return true;
0
1181 } -
1182 return false;
never executed: return false;
0
1183 } -
1184 }
never executed: }
0
1185 }
never executed: }
0
1186 return false;
never executed: return false;
0
1187} -
1188 -
1189//resource engine -
1190class QResourceFileEnginePrivate : public QAbstractFileEnginePrivate -
1191{ -
1192protected: -
1193 Q_DECLARE_PUBLIC(QResourceFileEngine) -
1194private: -
1195 uchar *map(qint64 offset, qint64 size, QFile::MemoryMapFlags flags); -
1196 bool unmap(uchar *ptr); -
1197 qint64 offset; -
1198 QResource resource; -
1199 QByteArray uncompressed; -
1200protected: -
1201 QResourceFileEnginePrivate() : offset(0) { }
executed: }
Execution Count:8255
8255
1202}; -
1203 -
1204bool QResourceFileEngine::mkdir(const QString &, bool) const -
1205{ -
1206 return false;
never executed: return false;
0
1207} -
1208 -
1209bool QResourceFileEngine::rmdir(const QString &, bool) const -
1210{ -
1211 return false;
never executed: return false;
0
1212} -
1213 -
1214bool QResourceFileEngine::setSize(qint64) -
1215{ -
1216 return false;
never executed: return false;
0
1217} -
1218 -
1219QStringList QResourceFileEngine::entryList(QDir::Filters filters, const QStringList &filterNames) const -
1220{ -
1221 return QAbstractFileEngine::entryList(filters, filterNames);
never executed: return QAbstractFileEngine::entryList(filters, filterNames);
0
1222} -
1223 -
1224bool QResourceFileEngine::caseSensitive() const -
1225{ -
1226 return true;
never executed: return true;
0
1227} -
1228 -
1229QResourceFileEngine::QResourceFileEngine(const QString &file) : -
1230 QAbstractFileEngine(*new QResourceFileEnginePrivate) -
1231{ -
1232 Q_D(QResourceFileEngine);
executed (the execution status of this line is deduced): QResourceFileEnginePrivate * const d = d_func();
-
1233 d->resource.setFileName(file);
executed (the execution status of this line is deduced): d->resource.setFileName(file);
-
1234 if(d->resource.isCompressed() && d->resource.size()) {
evaluated: d->resource.isCompressed()
TRUEFALSE
yes
Evaluation Count:629
yes
Evaluation Count:7626
partially evaluated: d->resource.size()
TRUEFALSE
yes
Evaluation Count:629
no
Evaluation Count:0
0-7626
1235#ifndef QT_NO_COMPRESS -
1236 d->uncompressed = qUncompress(d->resource.data(), d->resource.size());
executed (the execution status of this line is deduced): d->uncompressed = qUncompress(d->resource.data(), d->resource.size());
-
1237#else -
1238 Q_ASSERT(!"QResourceFileEngine::open: Qt built without support for compression"); -
1239#endif -
1240 }
executed: }
Execution Count:629
629
1241}
executed: }
Execution Count:8255
8255
1242 -
1243QResourceFileEngine::~QResourceFileEngine() -
1244{ -
1245} -
1246 -
1247void QResourceFileEngine::setFileName(const QString &file) -
1248{ -
1249 Q_D(QResourceFileEngine);
executed (the execution status of this line is deduced): QResourceFileEnginePrivate * const d = d_func();
-
1250 d->resource.setFileName(file);
executed (the execution status of this line is deduced): d->resource.setFileName(file);
-
1251}
executed: }
Execution Count:17
17
1252 -
1253bool QResourceFileEngine::open(QIODevice::OpenMode flags) -
1254{ -
1255 Q_D(QResourceFileEngine);
executed (the execution status of this line is deduced): QResourceFileEnginePrivate * const d = d_func();
-
1256 if (d->resource.fileName().isEmpty()) {
partially evaluated: d->resource.fileName().isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1699
0-1699
1257 qWarning("QResourceFileEngine::open: Missing file name");
never executed (the execution status of this line is deduced): QMessageLogger("io/qresource.cpp", 1257, __PRETTY_FUNCTION__).warning("QResourceFileEngine::open: Missing file name");
-
1258 return false;
never executed: return false;
0
1259 } -
1260 if(flags & QIODevice::WriteOnly)
evaluated: flags & QIODevice::WriteOnly
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:1696
3-1696
1261 return false;
executed: return false;
Execution Count:3
3
1262 if(!d->resource.isValid())
evaluated: !d->resource.isValid()
TRUEFALSE
yes
Evaluation Count:201
yes
Evaluation Count:1495
201-1495
1263 return false;
executed: return false;
Execution Count:201
201
1264 return true;
executed: return true;
Execution Count:1495
1495
1265} -
1266 -
1267bool QResourceFileEngine::close() -
1268{ -
1269 Q_D(QResourceFileEngine);
executed (the execution status of this line is deduced): QResourceFileEnginePrivate * const d = d_func();
-
1270 d->offset = 0;
executed (the execution status of this line is deduced): d->offset = 0;
-
1271 d->uncompressed.clear();
executed (the execution status of this line is deduced): d->uncompressed.clear();
-
1272 return true;
executed: return true;
Execution Count:1495
1495
1273} -
1274 -
1275bool QResourceFileEngine::flush() -
1276{ -
1277 return true;
executed: return true;
Execution Count:1495
1495
1278} -
1279 -
1280qint64 QResourceFileEngine::read(char *data, qint64 len) -
1281{ -
1282 Q_D(QResourceFileEngine);
executed (the execution status of this line is deduced): QResourceFileEnginePrivate * const d = d_func();
-
1283 if(len > size()-d->offset)
evaluated: len > size()-d->offset
TRUEFALSE
yes
Evaluation Count:34336
yes
Evaluation Count:1421
1421-34336
1284 len = size()-d->offset;
executed: len = size()-d->offset;
Execution Count:34336
34336
1285 if(len <= 0)
evaluated: len <= 0
TRUEFALSE
yes
Evaluation Count:32873
yes
Evaluation Count:2884
2884-32873
1286 return 0;
executed: return 0;
Execution Count:32873
32873
1287 if(d->resource.isCompressed())
evaluated: d->resource.isCompressed()
TRUEFALSE
yes
Evaluation Count:977
yes
Evaluation Count:1907
977-1907
1288 memcpy(data, d->uncompressed.constData()+d->offset, len);
executed: memcpy(data, d->uncompressed.constData()+d->offset, len);
Execution Count:977
977
1289 else -
1290 memcpy(data, d->resource.data()+d->offset, len);
executed: memcpy(data, d->resource.data()+d->offset, len);
Execution Count:1907
1907
1291 d->offset += len;
executed (the execution status of this line is deduced): d->offset += len;
-
1292 return len;
executed: return len;
Execution Count:2884
2884
1293} -
1294 -
1295qint64 QResourceFileEngine::write(const char *, qint64) -
1296{ -
1297 return -1;
never executed: return -1;
0
1298} -
1299 -
1300bool QResourceFileEngine::remove() -
1301{ -
1302 return false;
executed: return false;
Execution Count:1
1
1303} -
1304 -
1305bool QResourceFileEngine::copy(const QString &) -
1306{ -
1307 return false;
executed: return false;
Execution Count:2
2
1308} -
1309 -
1310bool QResourceFileEngine::rename(const QString &) -
1311{ -
1312 return false;
executed: return false;
Execution Count:1
1
1313} -
1314 -
1315bool QResourceFileEngine::link(const QString &) -
1316{ -
1317 return false;
never executed: return false;
0
1318} -
1319 -
1320qint64 QResourceFileEngine::size() const -
1321{ -
1322 Q_D(const QResourceFileEngine);
executed (the execution status of this line is deduced): const QResourceFileEnginePrivate * const d = d_func();
-
1323 if(!d->resource.isValid())
evaluated: !d->resource.isValid()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:74021
2-74021
1324 return 0;
executed: return 0;
Execution Count:2
2
1325 if(d->resource.isCompressed())
evaluated: d->resource.isCompressed()
TRUEFALSE
yes
Evaluation Count:2153
yes
Evaluation Count:71868
2153-71868
1326 return d->uncompressed.size();
executed: return d->uncompressed.size();
Execution Count:2153
2153
1327 return d->resource.size();
executed: return d->resource.size();
Execution Count:71868
71868
1328} -
1329 -
1330qint64 QResourceFileEngine::pos() const -
1331{ -
1332 Q_D(const QResourceFileEngine);
never executed (the execution status of this line is deduced): const QResourceFileEnginePrivate * const d = d_func();
-
1333 return d->offset;
never executed: return d->offset;
0
1334} -
1335 -
1336bool QResourceFileEngine::atEnd() const -
1337{ -
1338 Q_D(const QResourceFileEngine);
never executed (the execution status of this line is deduced): const QResourceFileEnginePrivate * const d = d_func();
-
1339 if(!d->resource.isValid())
never evaluated: !d->resource.isValid()
0
1340 return true;
never executed: return true;
0
1341 return d->offset == size();
never executed: return d->offset == size();
0
1342} -
1343 -
1344bool QResourceFileEngine::seek(qint64 pos) -
1345{ -
1346 Q_D(QResourceFileEngine);
executed (the execution status of this line is deduced): QResourceFileEnginePrivate * const d = d_func();
-
1347 if(!d->resource.isValid())
partially evaluated: !d->resource.isValid()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:701
0-701
1348 return false;
never executed: return false;
0
1349 -
1350 if(d->offset > size())
partially evaluated: d->offset > size()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:701
0-701
1351 return false;
never executed: return false;
0
1352 d->offset = pos;
executed (the execution status of this line is deduced): d->offset = pos;
-
1353 return true;
executed: return true;
Execution Count:701
701
1354} -
1355 -
1356bool QResourceFileEngine::isSequential() const -
1357{ -
1358 return false;
executed: return false;
Execution Count:3128
3128
1359} -
1360 -
1361QAbstractFileEngine::FileFlags QResourceFileEngine::fileFlags(QAbstractFileEngine::FileFlags type) const -
1362{ -
1363 Q_D(const QResourceFileEngine);
executed (the execution status of this line is deduced): const QResourceFileEnginePrivate * const d = d_func();
-
1364 QAbstractFileEngine::FileFlags ret = 0;
executed (the execution status of this line is deduced): QAbstractFileEngine::FileFlags ret = 0;
-
1365 if(!d->resource.isValid())
evaluated: !d->resource.isValid()
TRUEFALSE
yes
Evaluation Count:959
yes
Evaluation Count:1893
959-1893
1366 return ret;
executed: return ret;
Execution Count:959
959
1367 -
1368 if(type & PermsMask)
evaluated: type & PermsMask
TRUEFALSE
yes
Evaluation Count:11
yes
Evaluation Count:1882
11-1882
1369 ret |= QAbstractFileEngine::FileFlags(ReadOwnerPerm|ReadUserPerm|ReadGroupPerm|ReadOtherPerm);
executed: ret |= QAbstractFileEngine::FileFlags(ReadOwnerPerm|ReadUserPerm|ReadGroupPerm|ReadOtherPerm);
Execution Count:11
11
1370 if(type & TypesMask) {
evaluated: type & TypesMask
TRUEFALSE
yes
Evaluation Count:1861
yes
Evaluation Count:32
32-1861
1371 if(d->resource.isDir())
evaluated: d->resource.isDir()
TRUEFALSE
yes
Evaluation Count:17
yes
Evaluation Count:1844
17-1844
1372 ret |= DirectoryType;
executed: ret |= DirectoryType;
Execution Count:17
17
1373 else -
1374 ret |= FileType;
executed: ret |= FileType;
Execution Count:1844
1844
1375 } -
1376 if(type & FlagsMask) {
evaluated: type & FlagsMask
TRUEFALSE
yes
Evaluation Count:1878
yes
Evaluation Count:15
15-1878
1377 ret |= ExistsFlag;
executed (the execution status of this line is deduced): ret |= ExistsFlag;
-
1378 if(d->resource.absoluteFilePath() == QLatin1String(":/"))
evaluated: d->resource.absoluteFilePath() == QLatin1String(":/")
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1877
1-1877
1379 ret |= RootFlag;
executed: ret |= RootFlag;
Execution Count:1
1
1380 }
executed: }
Execution Count:1878
1878
1381 return ret;
executed: return ret;
Execution Count:1893
1893
1382} -
1383 -
1384bool QResourceFileEngine::setPermissions(uint) -
1385{ -
1386 return false;
never executed: return false;
0
1387} -
1388 -
1389QString QResourceFileEngine::fileName(FileName file) const -
1390{ -
1391 Q_D(const QResourceFileEngine);
executed (the execution status of this line is deduced): const QResourceFileEnginePrivate * const d = d_func();
-
1392 if(file == BaseName) {
partially evaluated: file == BaseName
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2436
0-2436
1393 int slash = d->resource.fileName().lastIndexOf(QLatin1Char('/'));
never executed (the execution status of this line is deduced): int slash = d->resource.fileName().lastIndexOf(QLatin1Char('/'));
-
1394 if (slash == -1)
never evaluated: slash == -1
0
1395 return d->resource.fileName();
never executed: return d->resource.fileName();
0
1396 return d->resource.fileName().mid(slash + 1);
never executed: return d->resource.fileName().mid(slash + 1);
0
1397 } else if(file == PathName || file == AbsolutePathName) {
partially evaluated: file == PathName
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2436
partially evaluated: file == AbsolutePathName
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2436
0-2436
1398 const QString path = (file == AbsolutePathName) ? d->resource.absoluteFilePath() : d->resource.fileName();
never evaluated: (file == AbsolutePathName)
0
1399 const int slash = path.lastIndexOf(QLatin1Char('/'));
never executed (the execution status of this line is deduced): const int slash = path.lastIndexOf(QLatin1Char('/'));
-
1400 if (slash == -1)
never evaluated: slash == -1
0
1401 return QLatin1String(":");
never executed: return QLatin1String(":");
0
1402 else if (slash <= 1)
never evaluated: slash <= 1
0
1403 return QLatin1String(":/");
never executed: return QLatin1String(":/");
0
1404 return path.left(slash);
never executed: return path.left(slash);
0
1405 -
1406 } else if(file == CanonicalName || file == CanonicalPathName) {
evaluated: file == CanonicalName
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:2435
partially evaluated: file == CanonicalPathName
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2435
0-2435
1407 const QString absoluteFilePath = d->resource.absoluteFilePath();
executed (the execution status of this line is deduced): const QString absoluteFilePath = d->resource.absoluteFilePath();
-
1408 if(file == CanonicalPathName) {
partially evaluated: file == CanonicalPathName
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
1409 const int slash = absoluteFilePath.lastIndexOf(QLatin1Char('/'));
never executed (the execution status of this line is deduced): const int slash = absoluteFilePath.lastIndexOf(QLatin1Char('/'));
-
1410 if (slash != -1)
never evaluated: slash != -1
0
1411 return absoluteFilePath.left(slash);
never executed: return absoluteFilePath.left(slash);
0
1412 }
never executed: }
0
1413 return absoluteFilePath;
executed: return absoluteFilePath;
Execution Count:1
1
1414 } -
1415 return d->resource.fileName();
executed: return d->resource.fileName();
Execution Count:2435
2435
1416} -
1417 -
1418bool QResourceFileEngine::isRelativePath() const -
1419{ -
1420 return false;
executed: return false;
Execution Count:13
13
1421} -
1422 -
1423uint QResourceFileEngine::ownerId(FileOwner) const -
1424{ -
1425 static const uint nobodyID = (uint) -2; -
1426 return nobodyID;
never executed: return nobodyID;
0
1427} -
1428 -
1429QString QResourceFileEngine::owner(FileOwner) const -
1430{ -
1431 return QString();
never executed: return QString();
0
1432} -
1433 -
1434QDateTime QResourceFileEngine::fileTime(FileTime) const -
1435{ -
1436 return QDateTime();
executed: return QDateTime();
Execution Count:1658
1658
1437} -
1438 -
1439/*! -
1440 \internal -
1441*/ -
1442QAbstractFileEngine::Iterator *QResourceFileEngine::beginEntryList(QDir::Filters filters, -
1443 const QStringList &filterNames) -
1444{ -
1445 return new QResourceFileEngineIterator(filters, filterNames);
executed: return new QResourceFileEngineIterator(filters, filterNames);
Execution Count:17
17
1446} -
1447 -
1448/*! -
1449 \internal -
1450*/ -
1451QAbstractFileEngine::Iterator *QResourceFileEngine::endEntryList() -
1452{ -
1453 return 0;
never executed: return 0;
0
1454} -
1455 -
1456bool QResourceFileEngine::extension(Extension extension, const ExtensionOption *option, ExtensionReturn *output) -
1457{ -
1458 Q_D(QResourceFileEngine);
executed (the execution status of this line is deduced): QResourceFileEnginePrivate * const d = d_func();
-
1459 if (extension == MapExtension) {
evaluated: extension == MapExtension
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:9
9-10
1460 const MapExtensionOption *options = (MapExtensionOption*)(option);
executed (the execution status of this line is deduced): const MapExtensionOption *options = (MapExtensionOption*)(option);
-
1461 MapExtensionReturn *returnValue = static_cast<MapExtensionReturn*>(output);
executed (the execution status of this line is deduced): MapExtensionReturn *returnValue = static_cast<MapExtensionReturn*>(output);
-
1462 returnValue->address = d->map(options->offset, options->size, options->flags);
executed (the execution status of this line is deduced): returnValue->address = d->map(options->offset, options->size, options->flags);
-
1463 return (returnValue->address != 0);
executed: return (returnValue->address != 0);
Execution Count:10
10
1464 } -
1465 if (extension == UnMapExtension) {
partially evaluated: extension == UnMapExtension
TRUEFALSE
yes
Evaluation Count:9
no
Evaluation Count:0
0-9
1466 UnMapExtensionOption *options = (UnMapExtensionOption*)option;
executed (the execution status of this line is deduced): UnMapExtensionOption *options = (UnMapExtensionOption*)option;
-
1467 return d->unmap(options->address);
executed: return d->unmap(options->address);
Execution Count:9
9
1468 } -
1469 return false;
never executed: return false;
0
1470} -
1471 -
1472bool QResourceFileEngine::supportsExtension(Extension extension) const -
1473{ -
1474 return (extension == UnMapExtension || extension == MapExtension);
executed: return (extension == UnMapExtension || extension == MapExtension);
Execution Count:47
47
1475} -
1476 -
1477uchar *QResourceFileEnginePrivate::map(qint64 offset, qint64 size, QFile::MemoryMapFlags flags) -
1478{ -
1479 Q_Q(QResourceFileEngine);
executed (the execution status of this line is deduced): QResourceFileEngine * const q = q_func();
-
1480 Q_UNUSED(flags);
executed (the execution status of this line is deduced): (void)flags;;
-
1481 if (offset < 0 || size <= 0 || !resource.isValid() || offset + size > resource.size()) {
evaluated: offset < 0
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:8
evaluated: size <= 0
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:4
evaluated: !resource.isValid()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:3
evaluated: offset + size > resource.size()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:2
1-8
1482 q->setError(QFile::UnspecifiedError, QString());
executed (the execution status of this line is deduced): q->setError(QFile::UnspecifiedError, QString());
-
1483 return 0;
executed: return 0;
Execution Count:8
8
1484 } -
1485 uchar *address = const_cast<uchar *>(resource.data());
executed (the execution status of this line is deduced): uchar *address = const_cast<uchar *>(resource.data());
-
1486 return (address + offset);
executed: return (address + offset);
Execution Count:2
2
1487} -
1488 -
1489bool QResourceFileEnginePrivate::unmap(uchar *ptr) -
1490{ -
1491 Q_UNUSED(ptr);
executed (the execution status of this line is deduced): (void)ptr;;
-
1492 return true;
executed: return true;
Execution Count:9
9
1493} -
1494 -
1495QT_END_NAMESPACE -
1496 -
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial