io/qfsfileengine.cpp

Switch to Source codePreprocessed file
LineSource CodeCoverage
1 -
2 -
3 -
4 -
5 -
6 -
7 -
8 -
9 -
10 -
11 -
12 -
13 -
14 -
15QFSFileEnginePrivate::QFSFileEnginePrivate() : QAbstractFileEnginePrivate() -
16{ -
17 init(); -
18}
executed: }
Execution Count:26231
26231
19 -
20 -
21 -
22 -
23void 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:26430
26430
38 -
39 -
40 -
41 -
42QFSFileEngine::QFSFileEngine(const QString &file) -
43 : QAbstractFileEngine(*new QFSFileEnginePrivate) -
44{ -
45 QFSFileEnginePrivate * const d = d_func(); -
46 d->fileEntry = QFileSystemEntry(file); -
47}
executed: }
Execution Count:24694
24694
48 -
49 -
50 -
51 -
52QFSFileEngine::QFSFileEngine() : QAbstractFileEngine(*new QFSFileEnginePrivate) -
53{ -
54}
executed: }
Execution Count:1536
1536
55 -
56 -
57 -
58 -
59QFSFileEngine::QFSFileEngine(QFSFileEnginePrivate &dd) -
60 : QAbstractFileEngine(dd) -
61{ -
62}
never executed: }
0
63 -
64 -
65 -
66 -
67QFSFileEngine::~QFSFileEngine() -
68{ -
69 QFSFileEnginePrivate * const d = d_func(); -
70 if (d->closeFileHandle) {
evaluated: d->closeFileHandle
TRUEFALSE
yes
Evaluation Count:15787
yes
Evaluation Count:10435
10435-15787
71 if (d->fh) {
partially evaluated: d->fh
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:15787
0-15787
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
never executed: }
0
76 } else if (d->fd != -1) {
partially evaluated: d->fd != -1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:15786
never executed: }
0-15786
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
never executed: }
0
81 }
never executed: }
0
82 } -
83 QList<uchar*> keys = d->maps.keys(); -
84 for (int i = 0; i < keys.count(); ++i)
evaluated: i < keys.count()
TRUEFALSE
yes
Evaluation Count:495
yes
Evaluation Count:26222
495-26222
85 unmap(keys.at(i));
executed: unmap(keys.at(i));
Execution Count:495
495
86}
executed: }
Execution Count:26222
26222
87 -
88 -
89 -
90 -
91void QFSFileEngine::setFileName(const QString &file) -
92{ -
93 QFSFileEnginePrivate * const d = d_func(); -
94 d->init(); -
95 d->fileEntry = QFileSystemEntry(file); -
96}
executed: }
Execution Count:199
199
97 -
98 -
99 -
100 -
101bool QFSFileEngine::open(QIODevice::OpenMode openMode) -
102{ -
103 QFSFileEnginePrivate * const d = d_func(); -
104 if (d->fileEntry.isEmpty()) {
evaluated: d->fileEntry.isEmpty()
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:17688
3-17688
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
TRUEFALSE
yes
Evaluation Count:248
yes
Evaluation Count:17440
248-17440
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)
TRUEFALSE
yes
Evaluation Count:2483
yes
Evaluation Count:15205
evaluated: !(openMode & (QFile::ReadOnly | QFile::Append))
TRUEFALSE
yes
Evaluation Count:1271
yes
Evaluation Count:1212
1212-15205
116 openMode |= QFile::Truncate;
executed: openMode |= QFile::Truncate;
Execution Count:1271
1271
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:17688
17688
125} -
126 -
127 -
128 -
129 -
130 -
131bool 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 -
136bool 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
TRUEFALSE
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)
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:23
evaluated: !(openMode & (QFile::ReadOnly | QFile::Append))
TRUEFALSE
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 -
161bool 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
TRUEFALSE
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
never executed: }
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 }
never executed: }
0
184 -
185 return true;
executed: return true;
Execution Count:31
31
186} -
187 -
188 -
189 -
190 -
191 -
192bool 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 -
197bool 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
TRUEFALSE
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)
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:25
evaluated: !(openMode & (QFile::ReadOnly | QFile::Append))
TRUEFALSE
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 -
225bool 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
TRUEFALSE
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
never executed: }
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 }
never executed: }
0
248 -
249 return true;
executed: return true;
Execution Count:30
30
250} -
251 -
252 -
253 -
254 -
255bool QFSFileEngine::close() -
256{ -
257 QFSFileEnginePrivate * const d = d_func(); -
258 d->openMode = QIODevice::NotOpen; -
259 return d->nativeClose();
executed: return d->nativeClose();
Execution Count:16960
16960
260} -
261 -
262 -
263 -
264 -
265bool QFSFileEnginePrivate::closeFdFh() -
266{ -
267 QFSFileEngine * const q = q_func(); -
268 if (fd == -1 && !fh)
evaluated: fd == -1
TRUEFALSE
yes
Evaluation Count:689
yes
Evaluation Count:16271
evaluated: !fh
TRUEFALSE
yes
Evaluation Count:658
yes
Evaluation Count:31
31-16271
269 return false;
executed: return false;
Execution Count:658
658
270 -
271 -
272 bool flushed = !fh || (!lastFlushFailed && q->flush());
evaluated: !fh
TRUEFALSE
yes
Evaluation Count:16271
yes
Evaluation Count:31
partially evaluated: !lastFlushFailed
TRUEFALSE
yes
Evaluation Count:31
no
Evaluation Count:0
partially evaluated: q->flush()
TRUEFALSE
yes
Evaluation Count:31
no
Evaluation Count:0
0-16271
273 bool closed = true; -
274 tried_stat = 0; -
275 -
276 -
277 if (closeFileHandle) {
evaluated: closeFileHandle
TRUEFALSE
yes
Evaluation Count:16243
yes
Evaluation Count:59
59-16243
278 int ret; -
279 do { -
280 if (fh) {
evaluated: fh
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:16242
1-16242
281 -
282 ret = fclose(fh) != 0 ? -1 : 0;
partially evaluated: fclose(fh) != 0
TRUEFALSE
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:16242
16242
287 } while (ret == -1 && (*__errno_location ()) == 4);
partially evaluated: ret == -1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:16243
never evaluated: (*__errno_location ()) == 4
0-16243
288 -
289 -
290 -
291 fh = 0; -
292 fd = -1; -
293 closed = (ret == 0); -
294 }
executed: }
Execution Count:16243
16243
295 -
296 -
297 if (!flushed || !closed) {
partially evaluated: !flushed
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:16302
partially evaluated: !closed
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:16302
0-16302
298 if (flushed) {
never evaluated: flushed
0
299 -
300 q->setError(QFile::UnspecifiedError, qt_error_string((*__errno_location ()))); -
301 }
never executed: }
0
302 return false;
never executed: return false;
0
303 } -
304 -
305 return true;
executed: return true;
Execution Count:16302
16302
306} -
307 -
308 -
309 -
310 -
311bool QFSFileEngine::flush() -
312{ -
313 QFSFileEnginePrivate * const d = d_func(); -
314 if ((d->openMode & QIODevice::WriteOnly) == 0) {
evaluated: (d->openMode & QIODevice::WriteOnly) == 0
TRUEFALSE
yes
Evaluation Count:147473
yes
Evaluation Count:23169
23169-147473
315 -
316 -
317 return true;
executed: return true;
Execution Count:147473
147473
318 } -
319 return d->nativeFlush();
executed: return d->nativeFlush();
Execution Count:23169
23169
320} -
321 -
322 -
323 -
324 -
325bool QFSFileEnginePrivate::flushFh() -
326{ -
327 QFSFileEngine * const q = q_func(); -
328 -
329 -
330 -
331 if (lastFlushFailed)
partially evaluated: lastFlushFailed
TRUEFALSE
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
TRUEFALSE
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 -
350qint64 QFSFileEngine::size() const -
351{ -
352 const QFSFileEnginePrivate * const d = d_func(); -
353 return d->nativeSize();
executed: return d->nativeSize();
Execution Count:120645
120645
354} -
355 -
356 -
357 -
358 -
359 -
360qint64 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)
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:120643
2-120643
368 return 0;
executed: return 0;
Execution Count:2
2
369 return metaData.size();
executed: return metaData.size();
Execution Count:120643
120643
370} -
371 -
372 -
373 -
374 -
375 -
376qint64 QFSFileEngine::pos() const -
377{ -
378 const QFSFileEnginePrivate * const d = d_func(); -
379 return d->nativePos();
executed: return d->nativePos();
Execution Count:725
725
380} -
381 -
382 -
383 -
384 -
385qint64 QFSFileEnginePrivate::posFdFh() const -
386{ -
387 if (fh)
evaluated: fh
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:724
1-724
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:724
724
390} -
391 -
392 -
393 -
394 -
395bool QFSFileEngine::seek(qint64 pos) -
396{ -
397 QFSFileEnginePrivate * const d = d_func(); -
398 return d->nativeSeek(pos);
executed: return d->nativeSeek(pos);
Execution Count:221248
221248
399} -
400 -
401 -
402 -
403 -
404bool 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
TRUEFALSE
yes
Evaluation Count:4561
yes
Evaluation Count:216687
partially evaluated: !q->flush()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4561
0-216687
412 return false;
never executed: return false;
0
413 -
414 if (pos < 0 || pos != qint64(off64_t(pos)))
partially evaluated: pos < 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:221248
partially evaluated: pos != qint64(off64_t(pos))
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:221248
0-221248
415 return false;
never executed: return false;
0
416 -
417 if (fh) {
evaluated: fh
TRUEFALSE
yes
Evaluation Count:19
yes
Evaluation Count:221229
19-221229
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
TRUEFALSE
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
TRUEFALSE
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
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:221229
0-221229
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:221229
221229
436 return true;
executed: return true;
Execution Count:221248
221248
437} -
438 -
439 -
440 -
441 -
442int QFSFileEngine::handle() const -
443{ -
444 const QFSFileEnginePrivate * const d = d_func(); -
445 return d->nativeHandle();
executed: return d->nativeHandle();
Execution Count:883
883
446} -
447 -
448 -
449 -
450 -
451qint64 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
TRUEFALSE
yes
Evaluation Count:11258
yes
Evaluation Count:103864
11258-103864
459 flush(); -
460 d->lastIOCommand = QFSFileEnginePrivate::IOReadCommand; -
461 }
executed: }
Execution Count:11258
11258
462 -
463 return d->nativeRead(data, maxlen);
executed: return d->nativeRead(data, maxlen);
Execution Count:115122
115122
464} -
465 -
466 -
467 -
468 -
469qint64 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
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:115122
partially evaluated: len != qint64(size_t(len))
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:115122
0-115122
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
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:115117
5-115117
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
TRUEFALSE
yes
Evaluation Count:5
no
Evaluation Count:0
evaluated: eof
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:1
partially evaluated: result == 0
TRUEFALSE
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
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:4
partially evaluated: result == 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
executed: }
Execution Count:5
0-5
499 -
500 } else if (fd != -1) {
partially evaluated: fd != -1
TRUEFALSE
yes
Evaluation Count:115117
no
Evaluation Count:0
executed: }
Execution Count:5
0-115117
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
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:125734
never evaluated: (*__errno_location ()) == 4
executed: }
Execution Count:125734
0-125734
511 || (result > 0 && (readBytes += result) < len));
evaluated: result > 0
TRUEFALSE
yes
Evaluation Count:26009
yes
Evaluation Count:99725
evaluated: (readBytes += result) < len
TRUEFALSE
yes
Evaluation Count:10617
yes
Evaluation Count:15392
10617-99725
512 -
513 eof = !(result == -1); -
514 }
executed: }
Execution Count:115117
115117
515 -
516 if (!eof && readBytes == 0) {
evaluated: !eof
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:115121
partially evaluated: readBytes == 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-115121
517 readBytes = -1; -
518 q->setError(QFile::ReadError, qt_error_string((*__errno_location ()))); -
519 }
never executed: }
0
520 -
521 return readBytes;
executed: return readBytes;
Execution Count:115122
115122
522} -
523 -
524 -
525 -
526 -
527qint64 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
TRUEFALSE
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 -
545qint64 QFSFileEnginePrivate::readLineFdFh(char *data, qint64 maxlen) -
546{ -
547 QFSFileEngine * const q = q_func(); -
548 if (!fh)
partially evaluated: !fh
TRUEFALSE
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 -
580qint64 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
TRUEFALSE
yes
Evaluation Count:1886
yes
Evaluation Count:14770
1886-14770
588 flush(); -
589 d->lastIOCommand = QFSFileEnginePrivate::IOWriteCommand; -
590 }
executed: }
Execution Count:1886
1886
591 -
592 return d->nativeWrite(data, len);
executed: return d->nativeWrite(data, len);
Execution Count:16656
16656
593} -
594 -
595 -
596 -
597 -
598qint64 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
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:16656
partially evaluated: len != qint64(size_t(len))
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:16656
0-16656
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
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:16650
6-16650
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
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:5
executed: }
Execution Count:6
1-6
617 -
618 } else if (fd != -1) {
partially evaluated: fd != -1
TRUEFALSE
yes
Evaluation Count:16650
no
Evaluation Count:0
executed: }
Execution Count:6
0-16650
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
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:16644
partially evaluated: (*__errno_location ()) == 4
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:6
executed: }
Execution Count:16650
0-16650
629 || (result > 0 && (writtenBytes += result) < len));
evaluated: result > 0
TRUEFALSE
yes
Evaluation Count:16642
yes
Evaluation Count:8
partially evaluated: (writtenBytes += result) < len
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:16642
0-16642
630 }
executed: }
Execution Count:16650
16650
631 -
632 if (len && writtenBytes == 0) {
evaluated: len
TRUEFALSE
yes
Evaluation Count:16653
yes
Evaluation Count:3
evaluated: writtenBytes == 0
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:16647
3-16653
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:16656
16656
638} -
639 -
640 -
641 -
642 -
643 -
644QAbstractFileEngine::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 -
652QAbstractFileEngine::Iterator *QFSFileEngine::endEntryList() -
653{ -
654 return 0;
never executed: return 0;
0
655} -
656 -
657 -
658 -
659 -
660 -
661QStringList 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 -
669bool QFSFileEngine::isSequential() const -
670{ -
671 const QFSFileEnginePrivate * const d = d_func(); -
672 if (d->is_sequential == 0)
evaluated: d->is_sequential == 0
TRUEFALSE
yes
Evaluation Count:13337
yes
Evaluation Count:10261
10261-13337
673 d->is_sequential = d->nativeIsSequential() ? 1 : 2;
evaluated: d->nativeIsSequential()
TRUEFALSE
yes
Evaluation Count:33
yes
Evaluation Count:13304
executed: d->is_sequential = d->nativeIsSequential() ? 1 : 2;
Execution Count:13337
33-13337
674 return d->is_sequential == 1;
executed: return d->is_sequential == 1;
Execution Count:23598
23598
675} -
676 -
677 -
678 -
679 -
680 -
681bool QFSFileEnginePrivate::isSequentialFdFh() const -
682{ -
683 if (doStat(QFileSystemMetaData::SequentialType))
evaluated: doStat(QFileSystemMetaData::SequentialType)
TRUEFALSE
yes
Evaluation Count:13341
yes
Evaluation Count:1
1-13341
684 return metaData.isSequential();
executed: return metaData.isSequential();
Execution Count:13341
13341
685 return true;
executed: return true;
Execution Count:1
1
686} -
687 -
688 -
689 -
690 -
691 -
692bool 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
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:66604
never evaluated: d->fh
never evaluated: isSequential()
0-66604
696 return feof(d->fh);
never executed: return feof(d->fh);
0
697 -
698 if (extension == MapExtension) {
evaluated: extension == MapExtension
TRUEFALSE
yes
Evaluation Count:33306
yes
Evaluation Count:33298
33298-33306
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:33306
33306
703 } -
704 if (extension == UnMapExtension) {
partially evaluated: extension == UnMapExtension
TRUEFALSE
yes
Evaluation Count:33298
no
Evaluation Count:0
0-33298
705 UnMapExtensionOption *options = (UnMapExtensionOption*)option; -
706 return d->unmap(options->address);
executed: return d->unmap(options->address);
Execution Count:33298
33298
707 } -
708 -
709 return false;
never executed: return false;
0
710} -
711 -
712 -
713 -
714 -
715bool QFSFileEngine::supportsExtension(Extension extension) const -
716{ -
717 const QFSFileEnginePrivate * const d = d_func(); -
718 if (extension == AtEndExtension && d->fh && isSequential())
evaluated: extension == AtEndExtension
TRUEFALSE
yes
Evaluation Count:4251
yes
Evaluation Count:66458
evaluated: d->fh
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:4247
partially evaluated: isSequential()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4
0-66458
719 return true;
never executed: return true;
0
720 if (extension == FastReadLineExtension && d->fh)
evaluated: extension == FastReadLineExtension
TRUEFALSE
yes
Evaluation Count:349
yes
Evaluation Count:70360
partially evaluated: d->fh
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:349
0-70360
721 return true;
never executed: return true;
0
722 if (extension == FastReadLineExtension && d->fd != -1 && isSequential())
evaluated: extension == FastReadLineExtension
TRUEFALSE
yes
Evaluation Count:349
yes
Evaluation Count:70360
partially evaluated: d->fd != -1
TRUEFALSE
yes
Evaluation Count:349
no
Evaluation Count:0
evaluated: isSequential()
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:341
0-70360
723 return true;
executed: return true;
Execution Count:8
8
724 if (extension == UnMapExtension || extension == MapExtension)
evaluated: extension == UnMapExtension
TRUEFALSE
yes
Evaluation Count:32803
yes
Evaluation Count:37898
evaluated: extension == MapExtension
TRUEFALSE
yes
Evaluation Count:33306
yes
Evaluation Count:4592
4592-37898
725 return true;
executed: return true;
Execution Count:66109
66109
726 return false;
executed: return false;
Execution Count:4592
4592
727} -
728 -
729 -
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial