Line | Source Code | Coverage |
---|
1 | | - |
2 | | - |
3 | | - |
4 | | - |
5 | | - |
6 | | - |
7 | | - |
8 | | - |
9 | | - |
10 | | - |
11 | | - |
12 | | - |
13 | | - |
14 | | - |
15 | QFSFileEnginePrivate::QFSFileEnginePrivate() : QAbstractFileEnginePrivate() | - |
16 | { | - |
17 | init(); | - |
18 | } executed: } Execution Count:26532 | 26532 |
19 | | - |
20 | | - |
21 | | - |
22 | | - |
23 | void QFSFileEnginePrivate::init() | - |
24 | { | - |
25 | is_sequential = 0; | - |
26 | tried_stat = 0; | - |
27 | | - |
28 | need_lstat = 1; | - |
29 | is_link = 0; | - |
30 | | - |
31 | openMode = QIODevice::NotOpen; | - |
32 | fd = -1; | - |
33 | fh = 0; | - |
34 | lastIOCommand = IOFlushCommand; | - |
35 | lastFlushFailed = false; | - |
36 | closeFileHandle = false; | - |
37 | } executed: } Execution Count:26732 | 26732 |
38 | | - |
39 | | - |
40 | | - |
41 | | - |
42 | QFSFileEngine::QFSFileEngine(const QString &file) | - |
43 | : QAbstractFileEngine(*new QFSFileEnginePrivate) | - |
44 | { | - |
45 | QFSFileEnginePrivate * const d = d_func(); | - |
46 | d->fileEntry = QFileSystemEntry(file); | - |
47 | } executed: } Execution Count:24994 | 24994 |
48 | | - |
49 | | - |
50 | | - |
51 | | - |
52 | QFSFileEngine::QFSFileEngine() : QAbstractFileEngine(*new QFSFileEnginePrivate) | - |
53 | { | - |
54 | } executed: } Execution Count:1539 | 1539 |
55 | | - |
56 | | - |
57 | | - |
58 | | - |
59 | QFSFileEngine::QFSFileEngine(QFSFileEnginePrivate &dd) | - |
60 | : QAbstractFileEngine(dd) | - |
61 | { | - |
62 | } | 0 |
63 | | - |
64 | | - |
65 | | - |
66 | | - |
67 | QFSFileEngine::~QFSFileEngine() | - |
68 | { | - |
69 | QFSFileEnginePrivate * const d = d_func(); | - |
70 | if (d->closeFileHandle) { evaluated: d->closeFileHandle yes Evaluation Count:16052 | yes Evaluation Count:10472 |
| 10472-16052 |
71 | if (d->fh) { partially evaluated: d->fh no Evaluation Count:0 | yes Evaluation Count:16052 |
| 0-16052 |
72 | int ret; | - |
73 | do { | - |
74 | ret = fclose(d->fh); | - |
75 | } while (ret == (-1) && (*__errno_location ()) == 4); never evaluated: ret == (-1) never evaluated: (*__errno_location ()) == 4 | 0 |
76 | } else if (d->fd != -1) { partially evaluated: d->fd != -1 no Evaluation Count:0 | yes Evaluation Count:16052 |
| 0-16052 |
77 | int ret; | - |
78 | do { | - |
79 | ret = qt_safe_close(d->fd); | - |
80 | } while (ret == -1 && (*__errno_location ()) == 4); never evaluated: ret == -1 never evaluated: (*__errno_location ()) == 4 | 0 |
81 | } | 0 |
82 | } | - |
83 | QList<uchar*> keys = d->maps.keys(); | - |
84 | for (int i = 0; i < keys.count(); ++i) evaluated: i < keys.count() yes Evaluation Count:523 | yes Evaluation Count:26524 |
| 523-26524 |
85 | unmap(keys.at(i)); executed: unmap(keys.at(i)); Execution Count:523 | 523 |
86 | } executed: } Execution Count:26524 | 26524 |
87 | | - |
88 | | - |
89 | | - |
90 | | - |
91 | void QFSFileEngine::setFileName(const QString &file) | - |
92 | { | - |
93 | QFSFileEnginePrivate * const d = d_func(); | - |
94 | d->init(); | - |
95 | d->fileEntry = QFileSystemEntry(file); | - |
96 | } executed: } Execution Count:200 | 200 |
97 | | - |
98 | | - |
99 | | - |
100 | | - |
101 | bool QFSFileEngine::open(QIODevice::OpenMode openMode) | - |
102 | { | - |
103 | QFSFileEnginePrivate * const d = d_func(); | - |
104 | if (d->fileEntry.isEmpty()) { evaluated: d->fileEntry.isEmpty() yes Evaluation Count:3 | yes Evaluation Count:18120 |
| 3-18120 |
105 | QMessageLogger("io/qfsfileengine.cpp", 204, __PRETTY_FUNCTION__).warning("QFSFileEngine::open: No file name specified"); | - |
106 | setError(QFile::OpenError, QLatin1String("No file name specified")); | - |
107 | return false; executed: return false; Execution Count:3 | 3 |
108 | } | - |
109 | | - |
110 | | - |
111 | if (openMode & QFile::Append) evaluated: openMode & QFile::Append yes Evaluation Count:248 | yes Evaluation Count:17872 |
| 248-17872 |
112 | openMode |= QFile::WriteOnly; executed: openMode |= QFile::WriteOnly; Execution Count:248 | 248 |
113 | | - |
114 | | - |
115 | if ((openMode & QFile::WriteOnly) && !(openMode & (QFile::ReadOnly | QFile::Append))) evaluated: (openMode & QFile::WriteOnly) yes Evaluation Count:2571 | yes Evaluation Count:15549 |
evaluated: !(openMode & (QFile::ReadOnly | QFile::Append)) yes Evaluation Count:1273 | yes Evaluation Count:1298 |
| 1273-15549 |
116 | openMode |= QFile::Truncate; executed: openMode |= QFile::Truncate; Execution Count:1273 | 1273 |
117 | | - |
118 | d->openMode = openMode; | - |
119 | d->lastFlushFailed = false; | - |
120 | d->tried_stat = 0; | - |
121 | d->fh = 0; | - |
122 | d->fd = -1; | - |
123 | | - |
124 | return d->nativeOpen(openMode); executed: return d->nativeOpen(openMode); Execution Count:18120 | 18120 |
125 | } | - |
126 | | - |
127 | | - |
128 | | - |
129 | | - |
130 | | - |
131 | bool QFSFileEngine::open(QIODevice::OpenMode openMode, FILE *fh) | - |
132 | { | - |
133 | return open(openMode, fh, QFile::DontCloseHandle); never executed: return open(openMode, fh, QFile::DontCloseHandle); | 0 |
134 | } | - |
135 | | - |
136 | bool QFSFileEngine::open(QIODevice::OpenMode openMode, FILE *fh, QFile::FileHandleFlags handleFlags) | - |
137 | { | - |
138 | QFSFileEnginePrivate * const d = d_func(); | - |
139 | | - |
140 | | - |
141 | if (openMode & QFile::Append) partially evaluated: openMode & QFile::Append no Evaluation Count:0 | yes Evaluation Count:31 |
| 0-31 |
142 | openMode |= QFile::WriteOnly; never executed: openMode |= QFile::WriteOnly; | 0 |
143 | | - |
144 | | - |
145 | if ((openMode & QFile::WriteOnly) && !(openMode & (QFile::ReadOnly | QFile::Append))) evaluated: (openMode & QFile::WriteOnly) yes Evaluation Count:8 | yes Evaluation Count:23 |
evaluated: !(openMode & (QFile::ReadOnly | QFile::Append)) yes Evaluation Count:6 | yes Evaluation Count:2 |
| 2-23 |
146 | openMode |= QFile::Truncate; executed: openMode |= QFile::Truncate; Execution Count:6 | 6 |
147 | | - |
148 | d->openMode = openMode; | - |
149 | d->lastFlushFailed = false; | - |
150 | d->closeFileHandle = (handleFlags & QFile::AutoCloseHandle); | - |
151 | d->fileEntry.clear(); | - |
152 | d->tried_stat = 0; | - |
153 | d->fd = -1; | - |
154 | | - |
155 | return d->openFh(openMode, fh); executed: return d->openFh(openMode, fh); Execution Count:31 | 31 |
156 | } | - |
157 | | - |
158 | | - |
159 | | - |
160 | | - |
161 | bool QFSFileEnginePrivate::openFh(QIODevice::OpenMode openMode, FILE *fh) | - |
162 | { | - |
163 | QFSFileEngine * const q = q_func(); | - |
164 | this->fh = fh; | - |
165 | fd = -1; | - |
166 | | - |
167 | | - |
168 | if (openMode & QIODevice::Append) { partially evaluated: openMode & QIODevice::Append no Evaluation Count:0 | yes Evaluation Count:31 |
| 0-31 |
169 | int ret; | - |
170 | do { | - |
171 | ret = ::fseeko64(fh, 0, 2); | - |
172 | } while (ret != 0 && (*__errno_location ()) == 4); never evaluated: ret != 0 never evaluated: (*__errno_location ()) == 4 | 0 |
173 | | - |
174 | if (ret != 0) { never evaluated: ret != 0 | 0 |
175 | q->setError((*__errno_location ()) == 24 ? QFile::ResourceError : QFile::OpenError, | - |
176 | qt_error_string(int((*__errno_location ())))); | - |
177 | | - |
178 | this->openMode = QIODevice::NotOpen; | - |
179 | this->fh = 0; | - |
180 | | - |
181 | return false; never executed: return false; | 0 |
182 | } | - |
183 | } | 0 |
184 | | - |
185 | return true; executed: return true; Execution Count:31 | 31 |
186 | } | - |
187 | | - |
188 | | - |
189 | | - |
190 | | - |
191 | | - |
192 | bool QFSFileEngine::open(QIODevice::OpenMode openMode, int fd) | - |
193 | { | - |
194 | return open(openMode, fd, QFile::DontCloseHandle); never executed: return open(openMode, fd, QFile::DontCloseHandle); | 0 |
195 | } | - |
196 | | - |
197 | bool QFSFileEngine::open(QIODevice::OpenMode openMode, int fd, QFile::FileHandleFlags handleFlags) | - |
198 | { | - |
199 | QFSFileEnginePrivate * const d = d_func(); | - |
200 | | - |
201 | | - |
202 | if (openMode & QFile::Append) partially evaluated: openMode & QFile::Append no Evaluation Count:0 | yes Evaluation Count:30 |
| 0-30 |
203 | openMode |= QFile::WriteOnly; never executed: openMode |= QFile::WriteOnly; | 0 |
204 | | - |
205 | | - |
206 | if ((openMode & QFile::WriteOnly) && !(openMode & (QFile::ReadOnly | QFile::Append))) evaluated: (openMode & QFile::WriteOnly) yes Evaluation Count:5 | yes Evaluation Count:25 |
evaluated: !(openMode & (QFile::ReadOnly | QFile::Append)) yes Evaluation Count:4 | yes Evaluation Count:1 |
| 1-25 |
207 | openMode |= QFile::Truncate; executed: openMode |= QFile::Truncate; Execution Count:4 | 4 |
208 | | - |
209 | d->openMode = openMode; | - |
210 | d->lastFlushFailed = false; | - |
211 | d->closeFileHandle = (handleFlags & QFile::AutoCloseHandle); | - |
212 | d->fileEntry.clear(); | - |
213 | d->fh = 0; | - |
214 | d->fd = -1; | - |
215 | d->tried_stat = 0; | - |
216 | | - |
217 | return d->openFd(openMode, fd); executed: return d->openFd(openMode, fd); Execution Count:30 | 30 |
218 | } | - |
219 | | - |
220 | | - |
221 | | - |
222 | | - |
223 | | - |
224 | | - |
225 | bool QFSFileEnginePrivate::openFd(QIODevice::OpenMode openMode, int fd) | - |
226 | { | - |
227 | QFSFileEngine * const q = q_func(); | - |
228 | this->fd = fd; | - |
229 | fh = 0; | - |
230 | | - |
231 | | - |
232 | if (openMode & QFile::Append) { partially evaluated: openMode & QFile::Append no Evaluation Count:0 | yes Evaluation Count:30 |
| 0-30 |
233 | int ret; | - |
234 | do { | - |
235 | ret = ::lseek64(fd, 0, 2); | - |
236 | } while (ret == -1 && (*__errno_location ()) == 4); never evaluated: ret == -1 never evaluated: (*__errno_location ()) == 4 | 0 |
237 | | - |
238 | if (ret == -1) { never evaluated: ret == -1 | 0 |
239 | q->setError((*__errno_location ()) == 24 ? QFile::ResourceError : QFile::OpenError, | - |
240 | qt_error_string(int((*__errno_location ())))); | - |
241 | | - |
242 | this->openMode = QIODevice::NotOpen; | - |
243 | this->fd = -1; | - |
244 | | - |
245 | return false; never executed: return false; | 0 |
246 | } | - |
247 | } | 0 |
248 | | - |
249 | return true; executed: return true; Execution Count:30 | 30 |
250 | } | - |
251 | | - |
252 | | - |
253 | | - |
254 | | - |
255 | bool QFSFileEngine::close() | - |
256 | { | - |
257 | QFSFileEnginePrivate * const d = d_func(); | - |
258 | d->openMode = QIODevice::NotOpen; | - |
259 | return d->nativeClose(); executed: return d->nativeClose(); Execution Count:17226 | 17226 |
260 | } | - |
261 | | - |
262 | | - |
263 | | - |
264 | | - |
265 | bool QFSFileEnginePrivate::closeFdFh() | - |
266 | { | - |
267 | QFSFileEngine * const q = q_func(); | - |
268 | if (fd == -1 && !fh) evaluated: fd == -1 yes Evaluation Count:691 | yes Evaluation Count:16535 |
evaluated: !fh yes Evaluation Count:660 | yes Evaluation Count:31 |
| 31-16535 |
269 | return false; executed: return false; Execution Count:660 | 660 |
270 | | - |
271 | | - |
272 | bool flushed = !fh || (!lastFlushFailed && q->flush()); evaluated: !fh yes Evaluation Count:16535 | yes Evaluation Count:31 |
partially evaluated: !lastFlushFailed yes Evaluation Count:31 | no Evaluation Count:0 |
partially evaluated: q->flush() yes Evaluation Count:31 | no Evaluation Count:0 |
| 0-16535 |
273 | bool closed = true; | - |
274 | tried_stat = 0; | - |
275 | | - |
276 | | - |
277 | if (closeFileHandle) { evaluated: closeFileHandle yes Evaluation Count:16507 | yes Evaluation Count:59 |
| 59-16507 |
278 | int ret; | - |
279 | do { | - |
280 | if (fh) { evaluated: fh yes Evaluation Count:1 | yes Evaluation Count:16506 |
| 1-16506 |
281 | | - |
282 | ret = fclose(fh) != 0 ? -1 : 0; partially evaluated: fclose(fh) != 0 no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
283 | } else { executed: } Execution Count:1 | 1 |
284 | | - |
285 | ret = qt_safe_close(fd); | - |
286 | } executed: } Execution Count:16506 | 16506 |
287 | } while (ret == -1 && (*__errno_location ()) == 4); partially evaluated: ret == -1 no Evaluation Count:0 | yes Evaluation Count:16507 |
never evaluated: (*__errno_location ()) == 4 | 0-16507 |
288 | | - |
289 | | - |
290 | | - |
291 | fh = 0; | - |
292 | fd = -1; | - |
293 | closed = (ret == 0); | - |
294 | } executed: } Execution Count:16507 | 16507 |
295 | | - |
296 | | - |
297 | if (!flushed || !closed) { partially evaluated: !flushed no Evaluation Count:0 | yes Evaluation Count:16566 |
partially evaluated: !closed no Evaluation Count:0 | yes Evaluation Count:16566 |
| 0-16566 |
298 | if (flushed) { | 0 |
299 | | - |
300 | q->setError(QFile::UnspecifiedError, qt_error_string((*__errno_location ()))); | - |
301 | } | 0 |
302 | return false; never executed: return false; | 0 |
303 | } | - |
304 | | - |
305 | return true; executed: return true; Execution Count:16566 | 16566 |
306 | } | - |
307 | | - |
308 | | - |
309 | | - |
310 | | - |
311 | bool QFSFileEngine::flush() | - |
312 | { | - |
313 | QFSFileEnginePrivate * const d = d_func(); | - |
314 | if ((d->openMode & QIODevice::WriteOnly) == 0) { evaluated: (d->openMode & QIODevice::WriteOnly) == 0 yes Evaluation Count:149489 | yes Evaluation Count:23302 |
| 23302-149489 |
315 | | - |
316 | | - |
317 | return true; executed: return true; Execution Count:149489 | 149489 |
318 | } | - |
319 | return d->nativeFlush(); executed: return d->nativeFlush(); Execution Count:23302 | 23302 |
320 | } | - |
321 | | - |
322 | | - |
323 | | - |
324 | | - |
325 | bool QFSFileEnginePrivate::flushFh() | - |
326 | { | - |
327 | QFSFileEngine * const q = q_func(); | - |
328 | | - |
329 | | - |
330 | | - |
331 | if (lastFlushFailed) partially evaluated: lastFlushFailed no Evaluation Count:0 | yes Evaluation Count:32 |
| 0-32 |
332 | return false; never executed: return false; | 0 |
333 | | - |
334 | int ret = fflush(fh); | - |
335 | | - |
336 | lastFlushFailed = (ret != 0); | - |
337 | lastIOCommand = QFSFileEnginePrivate::IOFlushCommand; | - |
338 | | - |
339 | if (ret != 0) { partially evaluated: ret != 0 no Evaluation Count:0 | yes Evaluation Count:32 |
| 0-32 |
340 | q->setError((*__errno_location ()) == 28 ? QFile::ResourceError : QFile::WriteError, | - |
341 | qt_error_string((*__errno_location ()))); | - |
342 | return false; never executed: return false; | 0 |
343 | } | - |
344 | return true; executed: return true; Execution Count:32 | 32 |
345 | } | - |
346 | | - |
347 | | - |
348 | | - |
349 | | - |
350 | qint64 QFSFileEngine::size() const | - |
351 | { | - |
352 | const QFSFileEnginePrivate * const d = d_func(); | - |
353 | return d->nativeSize(); executed: return d->nativeSize(); Execution Count:122314 | 122314 |
354 | } | - |
355 | | - |
356 | | - |
357 | | - |
358 | | - |
359 | | - |
360 | qint64 QFSFileEnginePrivate::sizeFdFh() const | - |
361 | { | - |
362 | const QFSFileEngine * const q = q_func(); | - |
363 | const_cast<QFSFileEngine *>(q)->flush(); | - |
364 | | - |
365 | tried_stat = 0; | - |
366 | metaData.clearFlags(QFileSystemMetaData::SizeAttribute); | - |
367 | if (!doStat(QFileSystemMetaData::SizeAttribute)) evaluated: !doStat(QFileSystemMetaData::SizeAttribute) yes Evaluation Count:2 | yes Evaluation Count:122312 |
| 2-122312 |
368 | return 0; executed: return 0; Execution Count:2 | 2 |
369 | return metaData.size(); executed: return metaData.size(); Execution Count:122312 | 122312 |
370 | } | - |
371 | | - |
372 | | - |
373 | | - |
374 | | - |
375 | | - |
376 | qint64 QFSFileEngine::pos() const | - |
377 | { | - |
378 | const QFSFileEnginePrivate * const d = d_func(); | - |
379 | return d->nativePos(); executed: return d->nativePos(); Execution Count:768 | 768 |
380 | } | - |
381 | | - |
382 | | - |
383 | | - |
384 | | - |
385 | qint64 QFSFileEnginePrivate::posFdFh() const | - |
386 | { | - |
387 | if (fh) evaluated: fh yes Evaluation Count:1 | yes Evaluation Count:767 |
| 1-767 |
388 | return qint64(::ftello64(fh)); executed: return qint64(::ftello64(fh)); Execution Count:1 | 1 |
389 | return ::lseek64(fd, 0, 1); executed: return ::lseek64(fd, 0, 1); Execution Count:767 | 767 |
390 | } | - |
391 | | - |
392 | | - |
393 | | - |
394 | | - |
395 | bool QFSFileEngine::seek(qint64 pos) | - |
396 | { | - |
397 | QFSFileEnginePrivate * const d = d_func(); | - |
398 | return d->nativeSeek(pos); executed: return d->nativeSeek(pos); Execution Count:221320 | 221320 |
399 | } | - |
400 | | - |
401 | | - |
402 | | - |
403 | | - |
404 | bool QFSFileEnginePrivate::seekFdFh(qint64 pos) | - |
405 | { | - |
406 | QFSFileEngine * const q = q_func(); | - |
407 | | - |
408 | | - |
409 | | - |
410 | | - |
411 | if (lastIOCommand != QFSFileEnginePrivate::IOFlushCommand && !q->flush()) evaluated: lastIOCommand != QFSFileEnginePrivate::IOFlushCommand yes Evaluation Count:4587 | yes Evaluation Count:216733 |
partially evaluated: !q->flush() no Evaluation Count:0 | yes Evaluation Count:4587 |
| 0-216733 |
412 | return false; never executed: return false; | 0 |
413 | | - |
414 | if (pos < 0 || pos != qint64(off64_t(pos))) partially evaluated: pos < 0 no Evaluation Count:0 | yes Evaluation Count:221320 |
partially evaluated: pos != qint64(off64_t(pos)) no Evaluation Count:0 | yes Evaluation Count:221320 |
| 0-221320 |
415 | return false; never executed: return false; | 0 |
416 | | - |
417 | if (fh) { evaluated: fh yes Evaluation Count:19 | yes Evaluation Count:221301 |
| 19-221301 |
418 | | - |
419 | int ret; | - |
420 | do { | - |
421 | ret = ::fseeko64(fh, off64_t(pos), 0); | - |
422 | } while (ret != 0 && (*__errno_location ()) == 4); partially evaluated: ret != 0 no Evaluation Count:0 | yes Evaluation Count:19 |
never evaluated: (*__errno_location ()) == 4 executed: } Execution Count:19 | 0-19 |
423 | | - |
424 | if (ret != 0) { partially evaluated: ret != 0 no Evaluation Count:0 | yes Evaluation Count:19 |
| 0-19 |
425 | q->setError(QFile::ReadError, qt_error_string(int((*__errno_location ())))); | - |
426 | return false; never executed: return false; | 0 |
427 | } | - |
428 | } else { executed: } Execution Count:19 | 19 |
429 | | - |
430 | if (::lseek64(fd, off64_t(pos), 0) == -1) { partially evaluated: ::lseek64(fd, off64_t(pos), 0) == -1 no Evaluation Count:0 | yes Evaluation Count:221301 |
| 0-221301 |
431 | QMessageLogger("io/qfsfileengine.cpp", 530, __PRETTY_FUNCTION__).warning() << "QFile::at: Cannot set file position" << pos; | - |
432 | q->setError(QFile::PositionError, qt_error_string((*__errno_location ()))); | - |
433 | return false; never executed: return false; | 0 |
434 | } | - |
435 | } executed: } Execution Count:221301 | 221301 |
436 | return true; executed: return true; Execution Count:221320 | 221320 |
437 | } | - |
438 | | - |
439 | | - |
440 | | - |
441 | | - |
442 | int QFSFileEngine::handle() const | - |
443 | { | - |
444 | const QFSFileEnginePrivate * const d = d_func(); | - |
445 | return d->nativeHandle(); executed: return d->nativeHandle(); Execution Count:969 | 969 |
446 | } | - |
447 | | - |
448 | | - |
449 | | - |
450 | | - |
451 | qint64 QFSFileEngine::read(char *data, qint64 maxlen) | - |
452 | { | - |
453 | QFSFileEnginePrivate * const d = d_func(); | - |
454 | | - |
455 | | - |
456 | | - |
457 | | - |
458 | if (d->lastIOCommand != QFSFileEnginePrivate::IOReadCommand) { evaluated: d->lastIOCommand != QFSFileEnginePrivate::IOReadCommand yes Evaluation Count:11402 | yes Evaluation Count:104251 |
| 11402-104251 |
459 | flush(); | - |
460 | d->lastIOCommand = QFSFileEnginePrivate::IOReadCommand; | - |
461 | } executed: } Execution Count:11402 | 11402 |
462 | | - |
463 | return d->nativeRead(data, maxlen); executed: return d->nativeRead(data, maxlen); Execution Count:115654 | 115654 |
464 | } | - |
465 | | - |
466 | | - |
467 | | - |
468 | | - |
469 | qint64 QFSFileEnginePrivate::readFdFh(char *data, qint64 len) | - |
470 | { | - |
471 | QFSFileEngine * const q = q_func(); | - |
472 | | - |
473 | if (len < 0 || len != qint64(size_t(len))) { partially evaluated: len < 0 no Evaluation Count:0 | yes Evaluation Count:115653 |
partially evaluated: len != qint64(size_t(len)) no Evaluation Count:0 | yes Evaluation Count:115653 |
| 0-115653 |
474 | q->setError(QFile::ReadError, qt_error_string(22)); | - |
475 | return -1; never executed: return -1; | 0 |
476 | } | - |
477 | | - |
478 | qint64 readBytes = 0; | - |
479 | bool eof = false; | - |
480 | | - |
481 | if (fh) { evaluated: fh yes Evaluation Count:5 | yes Evaluation Count:115648 |
| 5-115648 |
482 | | - |
483 | | - |
484 | size_t result; | - |
485 | bool retry = true; | - |
486 | do { | - |
487 | result = fread(data + readBytes, 1, size_t(len - readBytes), fh); | - |
488 | eof = feof(fh); | - |
489 | if (retry && eof && result == 0) { partially evaluated: retry yes Evaluation Count:5 | no Evaluation Count:0 |
evaluated: eof yes Evaluation Count:4 | yes Evaluation Count:1 |
partially evaluated: result == 0 no Evaluation Count:0 | yes Evaluation Count:4 |
| 0-5 |
490 | | - |
491 | | - |
492 | | - |
493 | ::fseeko64(fh, ::ftello64(fh), 0); | - |
494 | retry = false; | - |
495 | continue; never executed: continue; | 0 |
496 | } | - |
497 | readBytes += result; | - |
498 | } while (!eof && (result == 0 ? (*__errno_location ()) == 4 : readBytes < len)); evaluated: !eof yes Evaluation Count:1 | yes Evaluation Count:4 |
partially evaluated: result == 0 no Evaluation Count:0 | yes Evaluation Count:1 |
executed: } Execution Count:5 | 0-5 |
499 | | - |
500 | } else if (fd != -1) { partially evaluated: fd != -1 yes Evaluation Count:115648 | no Evaluation Count:0 |
executed: } Execution Count:5 | 0-115648 |
501 | | - |
502 | | - |
503 | | - |
504 | | - |
505 | | - |
506 | ssize_t result; | - |
507 | | - |
508 | do { | - |
509 | result = qt_safe_read(fd, data + readBytes, size_t(len - readBytes)); | - |
510 | } while ((result == -1 && (*__errno_location ()) == 4) partially evaluated: result == -1 no Evaluation Count:0 | yes Evaluation Count:126403 |
never evaluated: (*__errno_location ()) == 4 executed: } Execution Count:126403 | 0-126403 |
511 | || (result > 0 && (readBytes += result) < len)); evaluated: result > 0 yes Evaluation Count:26523 | yes Evaluation Count:99880 |
evaluated: (readBytes += result) < len yes Evaluation Count:10754 | yes Evaluation Count:15769 |
| 10754-99880 |
512 | | - |
513 | eof = !(result == -1); | - |
514 | } executed: } Execution Count:115649 | 115649 |
515 | | - |
516 | if (!eof && readBytes == 0) { evaluated: !eof yes Evaluation Count:1 | yes Evaluation Count:115653 |
partially evaluated: readBytes == 0 no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-115653 |
517 | readBytes = -1; | - |
518 | q->setError(QFile::ReadError, qt_error_string((*__errno_location ()))); | - |
519 | } | 0 |
520 | | - |
521 | return readBytes; executed: return readBytes; Execution Count:115654 | 115654 |
522 | } | - |
523 | | - |
524 | | - |
525 | | - |
526 | | - |
527 | qint64 QFSFileEngine::readLine(char *data, qint64 maxlen) | - |
528 | { | - |
529 | QFSFileEnginePrivate * const d = d_func(); | - |
530 | | - |
531 | | - |
532 | | - |
533 | | - |
534 | if (d->lastIOCommand != QFSFileEnginePrivate::IOReadCommand) { evaluated: d->lastIOCommand != QFSFileEnginePrivate::IOReadCommand yes Evaluation Count:4 | yes Evaluation Count:4 |
| 4 |
535 | flush(); | - |
536 | d->lastIOCommand = QFSFileEnginePrivate::IOReadCommand; | - |
537 | } executed: } Execution Count:4 | 4 |
538 | | - |
539 | return d->nativeReadLine(data, maxlen); executed: return d->nativeReadLine(data, maxlen); Execution Count:8 | 8 |
540 | } | - |
541 | | - |
542 | | - |
543 | | - |
544 | | - |
545 | qint64 QFSFileEnginePrivate::readLineFdFh(char *data, qint64 maxlen) | - |
546 | { | - |
547 | QFSFileEngine * const q = q_func(); | - |
548 | if (!fh) partially evaluated: !fh yes Evaluation Count:8 | no Evaluation Count:0 |
| 0-8 |
549 | return q->QAbstractFileEngine::readLine(data, maxlen); executed: return q->QAbstractFileEngine::readLine(data, maxlen); Execution Count:8 | 8 |
550 | | - |
551 | off64_t oldPos = 0; | - |
552 | | - |
553 | | - |
554 | | - |
555 | | - |
556 | oldPos = ::ftello64(fh); | - |
557 | | - |
558 | | - |
559 | | - |
560 | | - |
561 | | - |
562 | if (!fgets(data, int(maxlen + 1), fh)) { never evaluated: !fgets(data, int(maxlen + 1), fh) | 0 |
563 | if (!feof(fh)) never evaluated: !feof(fh) | 0 |
564 | q->setError(QFile::ReadError, qt_error_string(int((*__errno_location ())))); never executed: q->setError(QFile::ReadError, qt_error_string(int((*__errno_location ())))); | 0 |
565 | return -1; never executed: return -1; | 0 |
566 | } | - |
567 | | - |
568 | | - |
569 | | - |
570 | | - |
571 | | - |
572 | | - |
573 | qint64 lineLength = ::ftello64(fh) - oldPos; | - |
574 | return lineLength > 0 ? lineLength : qstrlen(data); never executed: return lineLength > 0 ? lineLength : qstrlen(data); | 0 |
575 | } | - |
576 | | - |
577 | | - |
578 | | - |
579 | | - |
580 | qint64 QFSFileEngine::write(const char *data, qint64 len) | - |
581 | { | - |
582 | QFSFileEnginePrivate * const d = d_func(); | - |
583 | | - |
584 | | - |
585 | | - |
586 | | - |
587 | if (d->lastIOCommand != QFSFileEnginePrivate::IOWriteCommand) { evaluated: d->lastIOCommand != QFSFileEnginePrivate::IOWriteCommand yes Evaluation Count:1931 | yes Evaluation Count:14770 |
| 1931-14770 |
588 | flush(); | - |
589 | d->lastIOCommand = QFSFileEnginePrivate::IOWriteCommand; | - |
590 | } executed: } Execution Count:1931 | 1931 |
591 | | - |
592 | return d->nativeWrite(data, len); executed: return d->nativeWrite(data, len); Execution Count:16701 | 16701 |
593 | } | - |
594 | | - |
595 | | - |
596 | | - |
597 | | - |
598 | qint64 QFSFileEnginePrivate::writeFdFh(const char *data, qint64 len) | - |
599 | { | - |
600 | QFSFileEngine * const q = q_func(); | - |
601 | | - |
602 | if (len < 0 || len != qint64(size_t(len))) { partially evaluated: len < 0 no Evaluation Count:0 | yes Evaluation Count:16701 |
partially evaluated: len != qint64(size_t(len)) no Evaluation Count:0 | yes Evaluation Count:16701 |
| 0-16701 |
603 | q->setError(QFile::WriteError, qt_error_string(22)); | - |
604 | return -1; never executed: return -1; | 0 |
605 | } | - |
606 | | - |
607 | qint64 writtenBytes = 0; | - |
608 | | - |
609 | if (fh) { evaluated: fh yes Evaluation Count:6 | yes Evaluation Count:16695 |
| 6-16695 |
610 | | - |
611 | | - |
612 | size_t result; | - |
613 | do { | - |
614 | result = fwrite(data + writtenBytes, 1, size_t(len - writtenBytes), fh); | - |
615 | writtenBytes += result; | - |
616 | } while (result == 0 ? (*__errno_location ()) == 4 : writtenBytes < len); evaluated: result == 0 yes Evaluation Count:1 | yes Evaluation Count:5 |
executed: } Execution Count:6 | 1-6 |
617 | | - |
618 | } else if (fd != -1) { partially evaluated: fd != -1 yes Evaluation Count:16695 | no Evaluation Count:0 |
executed: } Execution Count:6 | 0-16695 |
619 | | - |
620 | | - |
621 | | - |
622 | | - |
623 | | - |
624 | ssize_t result; | - |
625 | | - |
626 | do { | - |
627 | result = qt_safe_write(fd, data + writtenBytes, size_t(len - writtenBytes)); | - |
628 | } while ((result == -1 && (*__errno_location ()) == 4) evaluated: result == -1 yes Evaluation Count:6 | yes Evaluation Count:16689 |
partially evaluated: (*__errno_location ()) == 4 no Evaluation Count:0 | yes Evaluation Count:6 |
executed: } Execution Count:16695 | 0-16695 |
629 | || (result > 0 && (writtenBytes += result) < len)); evaluated: result > 0 yes Evaluation Count:16687 | yes Evaluation Count:8 |
partially evaluated: (writtenBytes += result) < len no Evaluation Count:0 | yes Evaluation Count:16687 |
| 0-16687 |
630 | } executed: } Execution Count:16695 | 16695 |
631 | | - |
632 | if (len && writtenBytes == 0) { evaluated: len yes Evaluation Count:16698 | yes Evaluation Count:3 |
evaluated: writtenBytes == 0 yes Evaluation Count:6 | yes Evaluation Count:16692 |
| 3-16698 |
633 | writtenBytes = -1; | - |
634 | q->setError((*__errno_location ()) == 28 ? QFile::ResourceError : QFile::WriteError, qt_error_string((*__errno_location ()))); | - |
635 | } executed: } Execution Count:6 | 6 |
636 | | - |
637 | return writtenBytes; executed: return writtenBytes; Execution Count:16701 | 16701 |
638 | } | - |
639 | | - |
640 | | - |
641 | | - |
642 | | - |
643 | | - |
644 | QAbstractFileEngine::Iterator *QFSFileEngine::beginEntryList(QDir::Filters filters, const QStringList &filterNames) | - |
645 | { | - |
646 | return new QFSFileEngineIterator(filters, filterNames); never executed: return new QFSFileEngineIterator(filters, filterNames); | 0 |
647 | } | - |
648 | | - |
649 | | - |
650 | | - |
651 | | - |
652 | QAbstractFileEngine::Iterator *QFSFileEngine::endEntryList() | - |
653 | { | - |
654 | return 0; never executed: return 0; | 0 |
655 | } | - |
656 | | - |
657 | | - |
658 | | - |
659 | | - |
660 | | - |
661 | QStringList QFSFileEngine::entryList(QDir::Filters filters, const QStringList &filterNames) const | - |
662 | { | - |
663 | return QAbstractFileEngine::entryList(filters, filterNames); never executed: return QAbstractFileEngine::entryList(filters, filterNames); | 0 |
664 | } | - |
665 | | - |
666 | | - |
667 | | - |
668 | | - |
669 | bool QFSFileEngine::isSequential() const | - |
670 | { | - |
671 | const QFSFileEnginePrivate * const d = d_func(); | - |
672 | if (d->is_sequential == 0) evaluated: d->is_sequential == 0 yes Evaluation Count:13526 | yes Evaluation Count:12757 |
| 12757-13526 |
673 | d->is_sequential = d->nativeIsSequential() ? 1 : 2; evaluated: d->nativeIsSequential() yes Evaluation Count:32 | yes Evaluation Count:13495 |
executed: d->is_sequential = d->nativeIsSequential() ? 1 : 2; Execution Count:13526 | 32-13526 |
674 | return d->is_sequential == 1; executed: return d->is_sequential == 1; Execution Count:26284 | 26284 |
675 | } | - |
676 | | - |
677 | | - |
678 | | - |
679 | | - |
680 | | - |
681 | bool QFSFileEnginePrivate::isSequentialFdFh() const | - |
682 | { | - |
683 | if (doStat(QFileSystemMetaData::SequentialType)) partially evaluated: doStat(QFileSystemMetaData::SequentialType) yes Evaluation Count:13532 | no Evaluation Count:0 |
| 0-13532 |
684 | return metaData.isSequential(); executed: return metaData.isSequential(); Execution Count:13532 | 13532 |
685 | return true; never executed: return true; | 0 |
686 | } | - |
687 | | - |
688 | | - |
689 | | - |
690 | | - |
691 | | - |
692 | bool QFSFileEngine::extension(Extension extension, const ExtensionOption *option, ExtensionReturn *output) | - |
693 | { | - |
694 | QFSFileEnginePrivate * const d = d_func(); | - |
695 | if (extension == AtEndExtension && d->fh && isSequential()) partially evaluated: extension == AtEndExtension no Evaluation Count:0 | yes Evaluation Count:66660 |
never evaluated: isSequential() | 0-66660 |
696 | return feof(d->fh); never executed: return feof(d->fh); | 0 |
697 | | - |
698 | if (extension == MapExtension) { evaluated: extension == MapExtension yes Evaluation Count:33334 | yes Evaluation Count:33326 |
| 33326-33334 |
699 | const MapExtensionOption *options = (MapExtensionOption*)(option); | - |
700 | MapExtensionReturn *returnValue = static_cast<MapExtensionReturn*>(output); | - |
701 | returnValue->address = d->map(options->offset, options->size, options->flags); | - |
702 | return (returnValue->address != 0); executed: return (returnValue->address != 0); Execution Count:33334 | 33334 |
703 | } | - |
704 | if (extension == UnMapExtension) { partially evaluated: extension == UnMapExtension yes Evaluation Count:33326 | no Evaluation Count:0 |
| 0-33326 |
705 | UnMapExtensionOption *options = (UnMapExtensionOption*)option; | - |
706 | return d->unmap(options->address); executed: return d->unmap(options->address); Execution Count:33326 | 33326 |
707 | } | - |
708 | | - |
709 | return false; never executed: return false; | 0 |
710 | } | - |
711 | | - |
712 | | - |
713 | | - |
714 | | - |
715 | bool QFSFileEngine::supportsExtension(Extension extension) const | - |
716 | { | - |
717 | const QFSFileEnginePrivate * const d = d_func(); | - |
718 | if (extension == AtEndExtension && d->fh && isSequential()) evaluated: extension == AtEndExtension yes Evaluation Count:4251 | yes Evaluation Count:66486 |
evaluated: d->fh yes Evaluation Count:4 | yes Evaluation Count:4247 |
partially evaluated: isSequential() no Evaluation Count:0 | yes Evaluation Count:4 |
| 0-66486 |
719 | return true; never executed: return true; | 0 |
720 | if (extension == FastReadLineExtension && d->fh) evaluated: extension == FastReadLineExtension yes Evaluation Count:349 | yes Evaluation Count:70388 |
partially evaluated: d->fh no Evaluation Count:0 | yes Evaluation Count:349 |
| 0-70388 |
721 | return true; never executed: return true; | 0 |
722 | if (extension == FastReadLineExtension && d->fd != -1 && isSequential()) evaluated: extension == FastReadLineExtension yes Evaluation Count:349 | yes Evaluation Count:70388 |
partially evaluated: d->fd != -1 yes Evaluation Count:349 | no Evaluation Count:0 |
evaluated: isSequential() yes Evaluation Count:8 | yes Evaluation Count:341 |
| 0-70388 |
723 | return true; executed: return true; Execution Count:8 | 8 |
724 | if (extension == UnMapExtension || extension == MapExtension) evaluated: extension == UnMapExtension yes Evaluation Count:32803 | yes Evaluation Count:37926 |
evaluated: extension == MapExtension yes Evaluation Count:33334 | yes Evaluation Count:4592 |
| 4592-37926 |
725 | return true; executed: return true; Execution Count:66137 | 66137 |
726 | return false; executed: return false; Execution Count:4592 | 4592 |
727 | } | - |
728 | | - |
729 | | - |
| | |