io/qfsfileengine_unix.cpp

Switch to Source codePreprocessed file
LineSource CodeCoverage
1 -
2 -
3 -
4 -
5 -
6 -
7 -
8 -
9 -
10 -
11 -
12 -
13 -
14 -
15 -
16 -
17 -
18static inline QByteArray openModeToFopenMode(QIODevice::OpenMode flags, const QFileSystemEntry &fileEntry, -
19 QFileSystemMetaData &metaData) -
20{ -
21 QByteArray mode; -
22 if ((flags & QIODevice::ReadOnly) && !(flags & QIODevice::Truncate)) {
never evaluated: (flags & QIODevice::ReadOnly)
never evaluated: !(flags & QIODevice::Truncate)
0
23 mode = "rb"; -
24 if (flags & QIODevice::WriteOnly) {
never evaluated: flags & QIODevice::WriteOnly
0
25 metaData.clearFlags(QFileSystemMetaData::FileType); -
26 if (!fileEntry.isEmpty()
never evaluated: !fileEntry.isEmpty()
0
27 && QFileSystemEngine::fillMetaData(fileEntry, metaData, QFileSystemMetaData::FileType)
never evaluated: QFileSystemEngine::fillMetaData(fileEntry, metaData, QFileSystemMetaData::FileType)
0
28 && metaData.isFile()) {
never evaluated: metaData.isFile()
0
29 mode += '+'; -
30 } else {
never executed: }
0
31 mode = "wb+"; -
32 }
never executed: }
0
33 } -
34 } else if (flags & QIODevice::WriteOnly) {
never evaluated: flags & QIODevice::WriteOnly
never executed: }
0
35 mode = "wb"; -
36 if (flags & QIODevice::ReadOnly)
never evaluated: flags & QIODevice::ReadOnly
0
37 mode += '+';
never executed: mode += '+';
0
38 }
never executed: }
0
39 if (flags & QIODevice::Append) {
never evaluated: flags & QIODevice::Append
0
40 mode = "ab"; -
41 if (flags & QIODevice::ReadOnly)
never evaluated: flags & QIODevice::ReadOnly
0
42 mode += '+';
never executed: mode += '+';
0
43 }
never executed: }
0
44 -
45 -
46 -
47 mode += 'e'; -
48 -
49 -
50 return mode;
never executed: return mode;
0
51} -
52 -
53 -
54 -
55 -
56 -
57 -
58static inline int openModeToOpenFlags(QIODevice::OpenMode mode) -
59{ -
60 int oflags = 00; -
61 -
62 oflags |= 0; -
63 -
64 -
65 if ((mode & QFile::ReadWrite) == QFile::ReadWrite) {
evaluated: (mode & QFile::ReadWrite) == QFile::ReadWrite
TRUEFALSE
yes
Evaluation Count:1050
yes
Evaluation Count:17070
1050-17070
66 oflags = 02 | 0100; -
67 } else if (mode & QFile::WriteOnly) {
evaluated: mode & QFile::WriteOnly
TRUEFALSE
yes
Evaluation Count:1521
yes
Evaluation Count:15549
executed: }
Execution Count:1050
1050-15549
68 oflags = 01 | 0100; -
69 }
executed: }
Execution Count:1521
1521
70 -
71 if (mode & QFile::Append) {
evaluated: mode & QFile::Append
TRUEFALSE
yes
Evaluation Count:248
yes
Evaluation Count:17872
248-17872
72 oflags |= 02000; -
73 } else if (mode & QFile::WriteOnly) {
executed: }
Execution Count:248
evaluated: mode & QFile::WriteOnly
TRUEFALSE
yes
Evaluation Count:2323
yes
Evaluation Count:15549
248-15549
74 if ((mode & QFile::Truncate) || !(mode & QFile::ReadOnly))
evaluated: (mode & QFile::Truncate)
TRUEFALSE
yes
Evaluation Count:1278
yes
Evaluation Count:1045
partially evaluated: !(mode & QFile::ReadOnly)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1045
0-1278
75 oflags |= 01000;
executed: oflags |= 01000;
Execution Count:1278
1278
76 }
executed: }
Execution Count:2323
2323
77 -
78 return oflags;
executed: return oflags;
Execution Count:18120
18120
79} -
80 -
81 -
82 -
83 -
84 -
85 -
86 -
87static inline bool setCloseOnExec(int fd) -
88{ -
89 return fd != -1 && fcntl(fd, 2, 1) != -1;
never executed: return fd != -1 && fcntl(fd, 2, 1) != -1;
0
90} -
91 -
92 -
93 -
94 -
95bool QFSFileEnginePrivate::nativeOpen(QIODevice::OpenMode openMode) -
96{ -
97 QFSFileEngine * const q = q_func(); -
98 -
99 if (openMode & QIODevice::Unbuffered) {
partially evaluated: openMode & QIODevice::Unbuffered
TRUEFALSE
yes
Evaluation Count:18120
no
Evaluation Count:0
0-18120
100 int flags = openModeToOpenFlags(openMode); -
101 -
102 -
103 do { -
104 fd = qt_safe_open(fileEntry.nativeFilePath().constData(), flags, 0666); -
105 } while (fd == -1 && (*__errno_location ()) == 4);
executed: }
Execution Count:18121
evaluated: fd == -1
TRUEFALSE
yes
Evaluation Count:3074
yes
Evaluation Count:15046
partially evaluated: (*__errno_location ()) == 4
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3074
0-18121
106 -
107 -
108 if (fd == -1) {
evaluated: fd == -1
TRUEFALSE
yes
Evaluation Count:3074
yes
Evaluation Count:15046
3074-15046
109 q->setError((*__errno_location ()) == 24 ? QFile::ResourceError : QFile::OpenError, -
110 qt_error_string((*__errno_location ()))); -
111 return false;
executed: return false;
Execution Count:3074
3074
112 } -
113 -
114 if (!(openMode & QIODevice::WriteOnly)) {
evaluated: !(openMode & QIODevice::WriteOnly)
TRUEFALSE
yes
Evaluation Count:12510
yes
Evaluation Count:2536
2536-12510
115 -
116 -
117 if (QFileSystemEngine::fillMetaData(fd, metaData)
partially evaluated: QFileSystemEngine::fillMetaData(fd, metaData)
TRUEFALSE
yes
Evaluation Count:12511
no
Evaluation Count:0
0-12511
118 && metaData.isDirectory()) {
evaluated: metaData.isDirectory()
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:12504
7-12504
119 q->setError(QFile::OpenError, QLatin1String("file to open is a directory")); -
120 qt_safe_close(fd); -
121 return false;
executed: return false;
Execution Count:7
7
122 } -
123 }
executed: }
Execution Count:12503
12503
124 -
125 -
126 if (flags & QFile::Append) {
partially evaluated: flags & QFile::Append
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:15039
0-15039
127 int ret; -
128 do { -
129 ret = ::lseek64(fd, 0, 2); -
130 } while (ret == -1 && (*__errno_location ()) == 4);
never executed: }
never evaluated: ret == -1
never evaluated: (*__errno_location ()) == 4
0
131 -
132 if (ret == -1) {
never evaluated: ret == -1
0
133 q->setError((*__errno_location ()) == 24 ? QFile::ResourceError : QFile::OpenError, -
134 qt_error_string(int((*__errno_location ())))); -
135 return false;
never executed: return false;
0
136 } -
137 }
never executed: }
0
138 -
139 fh = 0; -
140 } else {
executed: }
Execution Count:15040
15040
141 QByteArray fopenMode = openModeToFopenMode(openMode, fileEntry, metaData); -
142 -
143 -
144 do { -
145 fh = ::fopen64(fileEntry.nativeFilePath().constData(), fopenMode.constData()); -
146 } while (!fh && (*__errno_location ()) == 4);
never evaluated: !fh
never evaluated: (*__errno_location ()) == 4
never executed: }
0
147 -
148 -
149 if (!fh) {
never evaluated: !fh
0
150 q->setError((*__errno_location ()) == 24 ? QFile::ResourceError : QFile::OpenError, -
151 qt_error_string(int((*__errno_location ())))); -
152 return false;
never executed: return false;
0
153 } -
154 -
155 if (!(openMode & QIODevice::WriteOnly)) {
never evaluated: !(openMode & QIODevice::WriteOnly)
0
156 -
157 -
158 if (QFileSystemEngine::fillMetaData(fileno(fh), metaData)
never evaluated: QFileSystemEngine::fillMetaData(fileno(fh), metaData)
0
159 && metaData.isDirectory()) {
never evaluated: metaData.isDirectory()
0
160 q->setError(QFile::OpenError, QLatin1String("file to open is a directory")); -
161 fclose(fh); -
162 return false;
never executed: return false;
0
163 } -
164 }
never executed: }
0
165 -
166 setCloseOnExec(fileno(fh)); -
167 -
168 -
169 if (openMode & QIODevice::Append) {
never evaluated: openMode & QIODevice::Append
0
170 int ret; -
171 do { -
172 ret = ::fseeko64(fh, 0, 2); -
173 } while (ret == -1 && (*__errno_location ()) == 4);
never evaluated: ret == -1
never evaluated: (*__errno_location ()) == 4
never executed: }
0
174 -
175 if (ret == -1) {
never evaluated: ret == -1
0
176 q->setError((*__errno_location ()) == 24 ? QFile::ResourceError : QFile::OpenError, -
177 qt_error_string(int((*__errno_location ())))); -
178 return false;
never executed: return false;
0
179 } -
180 }
never executed: }
0
181 -
182 fd = -1; -
183 }
never executed: }
0
184 -
185 closeFileHandle = true; -
186 return true;
executed: return true;
Execution Count:15040
15040
187} -
188 -
189 -
190 -
191 -
192bool QFSFileEnginePrivate::nativeClose() -
193{ -
194 return closeFdFh();
executed: return closeFdFh();
Execution Count:17226
17226
195} -
196 -
197 -
198 -
199 -
200 -
201bool QFSFileEnginePrivate::nativeFlush() -
202{ -
203 return fh ? flushFh() : fd != -1;
executed: return fh ? flushFh() : fd != -1;
Execution Count:23302
23302
204} -
205 -
206 -
207 -
208 -
209qint64 QFSFileEnginePrivate::nativeRead(char *data, qint64 len) -
210{ -
211 QFSFileEngine * const q = q_func(); -
212 -
213 if (fh && nativeIsSequential()) {
evaluated: fh
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:115648
partially evaluated: nativeIsSequential()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:5
0-115648
214 size_t readBytes = 0; -
215 int oldFlags = fcntl(fileno(fh), 3); -
216 for (int i = 0; i < 2; ++i) {
never evaluated: i < 2
0
217 -
218 if ((oldFlags & 04000) == 0)
never evaluated: (oldFlags & 04000) == 0
0
219 fcntl(fileno(fh), 4, oldFlags | 04000);
never executed: fcntl(fileno(fh), 4, oldFlags | 04000);
0
220 -
221 -
222 size_t read = 0; -
223 do { -
224 read = fread(data + readBytes, 1, size_t(len - readBytes), fh); -
225 } while (read == 0 && !feof(fh) && (*__errno_location ()) == 4);
never evaluated: read == 0
never evaluated: !feof(fh)
never evaluated: (*__errno_location ()) == 4
never executed: }
0
226 if (read > 0) {
never evaluated: read > 0
0
227 readBytes += read; -
228 break;
never executed: break;
0
229 } else { -
230 if (readBytes)
never evaluated: readBytes
0
231 break;
never executed: break;
0
232 readBytes = read; -
233 }
never executed: }
0
234 -
235 -
236 if ((oldFlags & 04000) == 0) {
never evaluated: (oldFlags & 04000) == 0
0
237 fcntl(fileno(fh), 4, oldFlags); -
238 if (readBytes == 0) {
never evaluated: readBytes == 0
0
239 int readByte = 0; -
240 do { -
241 readByte = fgetc(fh); -
242 } while (readByte == -1 && (*__errno_location ()) == 4);
never evaluated: readByte == -1
never evaluated: (*__errno_location ()) == 4
never executed: }
0
243 if (readByte != -1) {
never evaluated: readByte != -1
0
244 *data = uchar(readByte); -
245 readBytes += 1; -
246 } else {
never executed: }
0
247 break;
never executed: break;
0
248 } -
249 } -
250 }
never executed: }
0
251 }
never executed: }
0
252 -
253 if ((oldFlags & 04000) == 0) {
never evaluated: (oldFlags & 04000) == 0
0
254 fcntl(fileno(fh), 4, oldFlags); -
255 }
never executed: }
0
256 if (readBytes == 0 && !feof(fh)) {
never evaluated: readBytes == 0
never evaluated: !feof(fh)
0
257 -
258 q->setError(QFile::ReadError, qt_error_string(int((*__errno_location ())))); -
259 return -1;
never executed: return -1;
0
260 } -
261 return readBytes;
never executed: return readBytes;
0
262 } -
263 -
264 return readFdFh(data, len);
executed: return readFdFh(data, len);
Execution Count:115653
115653
265} -
266 -
267 -
268 -
269 -
270qint64 QFSFileEnginePrivate::nativeReadLine(char *data, qint64 maxlen) -
271{ -
272 return readLineFdFh(data, maxlen);
executed: return readLineFdFh(data, maxlen);
Execution Count:8
8
273} -
274 -
275 -
276 -
277 -
278qint64 QFSFileEnginePrivate::nativeWrite(const char *data, qint64 len) -
279{ -
280 return writeFdFh(data, len);
executed: return writeFdFh(data, len);
Execution Count:16701
16701
281} -
282 -
283 -
284 -
285 -
286qint64 QFSFileEnginePrivate::nativePos() const -
287{ -
288 return posFdFh();
executed: return posFdFh();
Execution Count:768
768
289} -
290 -
291 -
292 -
293 -
294bool QFSFileEnginePrivate::nativeSeek(qint64 pos) -
295{ -
296 return seekFdFh(pos);
executed: return seekFdFh(pos);
Execution Count:221320
221320
297} -
298 -
299 -
300 -
301 -
302int QFSFileEnginePrivate::nativeHandle() const -
303{ -
304 return fh ? fileno(fh) : fd;
executed: return fh ? fileno(fh) : fd;
Execution Count:34293
34293
305} -
306 -
307 -
308 -
309 -
310bool QFSFileEnginePrivate::nativeIsSequential() const -
311{ -
312 return isSequentialFdFh();
executed: return isSequentialFdFh();
Execution Count:13531
13531
313} -
314 -
315bool QFSFileEngine::remove() -
316{ -
317 QFSFileEnginePrivate * const d = d_func(); -
318 QSystemError error; -
319 bool ret = QFileSystemEngine::removeFile(d->fileEntry, error); -
320 d->metaData.clear(); -
321 if (!ret) {
evaluated: !ret
TRUEFALSE
yes
Evaluation Count:615
yes
Evaluation Count:4879
615-4879
322 setError(QFile::RemoveError, error.toString()); -
323 }
executed: }
Execution Count:615
615
324 return ret;
executed: return ret;
Execution Count:5494
5494
325} -
326 -
327bool QFSFileEngine::copy(const QString &newName) -
328{ -
329 QFSFileEnginePrivate * const d = d_func(); -
330 QSystemError error; -
331 bool ret = QFileSystemEngine::copyFile(d->fileEntry, QFileSystemEntry(newName), error); -
332 if (!ret) {
partially evaluated: !ret
TRUEFALSE
yes
Evaluation Count:96
no
Evaluation Count:0
0-96
333 setError(QFile::CopyError, error.toString()); -
334 }
executed: }
Execution Count:96
96
335 return ret;
executed: return ret;
Execution Count:96
96
336} -
337 -
338bool QFSFileEngine::rename(const QString &newName) -
339{ -
340 QFSFileEnginePrivate * const d = d_func(); -
341 QSystemError error; -
342 bool ret = QFileSystemEngine::renameFile(d->fileEntry, QFileSystemEntry(newName), error); -
343 -
344 if (!ret) {
evaluated: !ret
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:200
3-200
345 setError(QFile::RenameError, error.toString()); -
346 }
executed: }
Execution Count:3
3
347 -
348 return ret;
executed: return ret;
Execution Count:203
203
349} -
350 -
351bool QFSFileEngine::link(const QString &newName) -
352{ -
353 QFSFileEnginePrivate * const d = d_func(); -
354 QSystemError error; -
355 bool ret = QFileSystemEngine::createLink(d->fileEntry, QFileSystemEntry(newName), error); -
356 if (!ret) {
partially evaluated: !ret
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:145
0-145
357 setError(QFile::RenameError, error.toString()); -
358 }
never executed: }
0
359 return ret;
executed: return ret;
Execution Count:145
145
360} -
361 -
362qint64 QFSFileEnginePrivate::nativeSize() const -
363{ -
364 return sizeFdFh();
executed: return sizeFdFh();
Execution Count:122314
122314
365} -
366 -
367bool QFSFileEngine::mkdir(const QString &name, bool createParentDirectories) const -
368{ -
369 return QFileSystemEngine::createDirectory(QFileSystemEntry(name), createParentDirectories);
never executed: return QFileSystemEngine::createDirectory(QFileSystemEntry(name), createParentDirectories);
0
370} -
371 -
372bool QFSFileEngine::rmdir(const QString &name, bool recurseParentDirectories) const -
373{ -
374 return QFileSystemEngine::removeDirectory(QFileSystemEntry(name), recurseParentDirectories);
never executed: return QFileSystemEngine::removeDirectory(QFileSystemEntry(name), recurseParentDirectories);
0
375} -
376 -
377bool QFSFileEngine::caseSensitive() const -
378{ -
379 return true;
never executed: return true;
0
380} -
381 -
382bool QFSFileEngine::setCurrentPath(const QString &path) -
383{ -
384 return QFileSystemEngine::setCurrentPath(QFileSystemEntry(path));
never executed: return QFileSystemEngine::setCurrentPath(QFileSystemEntry(path));
0
385} -
386 -
387QString QFSFileEngine::currentPath(const QString &) -
388{ -
389 return QFileSystemEngine::currentPath().filePath();
never executed: return QFileSystemEngine::currentPath().filePath();
0
390} -
391 -
392QString QFSFileEngine::homePath() -
393{ -
394 return QFileSystemEngine::homePath();
never executed: return QFileSystemEngine::homePath();
0
395} -
396 -
397QString QFSFileEngine::rootPath() -
398{ -
399 return QFileSystemEngine::rootPath();
executed: return QFileSystemEngine::rootPath();
Execution Count:147
147
400} -
401 -
402QString QFSFileEngine::tempPath() -
403{ -
404 return QFileSystemEngine::tempPath();
never executed: return QFileSystemEngine::tempPath();
0
405} -
406 -
407QFileInfoList QFSFileEngine::drives() -
408{ -
409 QFileInfoList ret; -
410 ret.append(QFileInfo(rootPath())); -
411 return ret;
executed: return ret;
Execution Count:147
147
412} -
413 -
414bool QFSFileEnginePrivate::doStat(QFileSystemMetaData::MetaDataFlags flags) const -
415{ -
416 if (!tried_stat || !metaData.hasFlags(flags)) {
evaluated: !tried_stat
TRUEFALSE
yes
Evaluation Count:140279
yes
Evaluation Count:34009
evaluated: !metaData.hasFlags(flags)
TRUEFALSE
yes
Evaluation Count:286
yes
Evaluation Count:33723
286-140279
417 tried_stat = 1; -
418 -
419 int localFd = fd; -
420 if (fh && fileEntry.isEmpty())
evaluated: fh
TRUEFALSE
yes
Evaluation Count:41
yes
Evaluation Count:140525
partially evaluated: fileEntry.isEmpty()
TRUEFALSE
yes
Evaluation Count:41
no
Evaluation Count:0
0-140525
421 localFd = fileno(fh);
executed: localFd = fileno(fh);
Execution Count:41
41
422 if (localFd != -1)
evaluated: localFd != -1
TRUEFALSE
yes
Evaluation Count:135652
yes
Evaluation Count:4914
4914-135652
423 QFileSystemEngine::fillMetaData(localFd, metaData);
executed: QFileSystemEngine::fillMetaData(localFd, metaData);
Execution Count:135651
135651
424 -
425 if (metaData.missingFlags(flags) && !fileEntry.isEmpty())
evaluated: metaData.missingFlags(flags)
TRUEFALSE
yes
Evaluation Count:5332
yes
Evaluation Count:135234
evaluated: !fileEntry.isEmpty()
TRUEFALSE
yes
Evaluation Count:5331
yes
Evaluation Count:1
1-135234
426 QFileSystemEngine::fillMetaData(fileEntry, metaData, metaData.missingFlags(flags));
executed: QFileSystemEngine::fillMetaData(fileEntry, metaData, metaData.missingFlags(flags));
Execution Count:5331
5331
427 }
executed: }
Execution Count:140565
140565
428 -
429 return metaData.exists();
executed: return metaData.exists();
Execution Count:174288
174288
430} -
431 -
432bool QFSFileEnginePrivate::isSymlink() const -
433{ -
434 if (!metaData.hasFlags(QFileSystemMetaData::LinkType))
partially evaluated: !metaData.hasFlags(QFileSystemMetaData::LinkType)
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
435 QFileSystemEngine::fillMetaData(fileEntry, metaData, QFileSystemMetaData::LinkType);
executed: QFileSystemEngine::fillMetaData(fileEntry, metaData, QFileSystemMetaData::LinkType);
Execution Count:2
2
436 -
437 return metaData.isLink();
executed: return metaData.isLink();
Execution Count:2
2
438} -
439 -
440 -
441 -
442 -
443QAbstractFileEngine::FileFlags QFSFileEngine::fileFlags(FileFlags type) const -
444{ -
445 const QFSFileEnginePrivate * const d = d_func(); -
446 -
447 if (type & Refresh)
evaluated: type & Refresh
TRUEFALSE
yes
Evaluation Count:4901
yes
Evaluation Count:218
218-4901
448 d->metaData.clear();
executed: d->metaData.clear();
Execution Count:4901
4901
449 -
450 QAbstractFileEngine::FileFlags ret = 0; -
451 -
452 if (type & FlagsMask)
evaluated: type & FlagsMask
TRUEFALSE
yes
Evaluation Count:4901
yes
Evaluation Count:218
218-4901
453 ret |= LocalDiskFlag;
executed: ret |= LocalDiskFlag;
Execution Count:4901
4901
454 -
455 bool exists; -
456 { -
457 QFileSystemMetaData::MetaDataFlags queryFlags = 0; -
458 -
459 queryFlags |= QFileSystemMetaData::MetaDataFlags(uint(type)) -
460 & QFileSystemMetaData::Permissions; -
461 -
462 if (type & TypesMask)
partially evaluated: type & TypesMask
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:5119
0-5119
463 queryFlags |= QFileSystemMetaData::AliasType 0
464 | QFileSystemMetaData::LinkType 0
465 | QFileSystemMetaData::FileType 0
466 | QFileSystemMetaData::DirectoryType 0
467 | QFileSystemMetaData::BundleType;
never executed: queryFlags |= QFileSystemMetaData::AliasType | QFileSystemMetaData::LinkType | QFileSystemMetaData::FileType | QFileSystemMetaData::DirectoryType | QFileSystemMetaData::BundleType;
0
468 -
469 if (type & FlagsMask)
evaluated: type & FlagsMask
TRUEFALSE
yes
Evaluation Count:4901
yes
Evaluation Count:218
218-4901
470 queryFlags |= QFileSystemMetaData::HiddenAttribute 4901
471 | QFileSystemMetaData::ExistsAttribute;
executed: queryFlags |= QFileSystemMetaData::HiddenAttribute | QFileSystemMetaData::ExistsAttribute;
Execution Count:4901
4901
472 -
473 queryFlags |= QFileSystemMetaData::LinkType; -
474 -
475 exists = d->doStat(queryFlags); -
476 } -
477 -
478 if (!exists && !d->metaData.isLink())
evaluated: !exists
TRUEFALSE
yes
Evaluation Count:3146
yes
Evaluation Count:1973
partially evaluated: !d->metaData.isLink()
TRUEFALSE
yes
Evaluation Count:3146
no
Evaluation Count:0
0-3146
479 return ret;
executed: return ret;
Execution Count:3146
3146
480 -
481 if (exists && (type & PermsMask))
partially evaluated: exists
TRUEFALSE
yes
Evaluation Count:1973
no
Evaluation Count:0
evaluated: (type & PermsMask)
TRUEFALSE
yes
Evaluation Count:218
yes
Evaluation Count:1755
0-1973
482 ret |= FileFlags(uint(d->metaData.permissions()));
executed: ret |= FileFlags(uint(d->metaData.permissions()));
Execution Count:218
218
483 -
484 if (type & TypesMask) {
partially evaluated: type & TypesMask
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1973
0-1973
485 if (d->metaData.isAlias()) {
never evaluated: d->metaData.isAlias()
0
486 ret |= LinkType; -
487 } else {
never executed: }
0
488 if ((type & LinkType) && d->metaData.isLink())
never evaluated: (type & LinkType)
never evaluated: d->metaData.isLink()
0
489 ret |= LinkType;
never executed: ret |= LinkType;
0
490 if (exists) {
never evaluated: exists
0
491 if (d->metaData.isFile()) {
never evaluated: d->metaData.isFile()
0
492 ret |= FileType; -
493 } else if (d->metaData.isDirectory()) {
never evaluated: d->metaData.isDirectory()
never executed: }
0
494 ret |= DirectoryType; -
495 if ((type & BundleType) && d->metaData.isBundle())
never evaluated: (type & BundleType)
never evaluated: d->metaData.isBundle()
0
496 ret |= BundleType;
never executed: ret |= BundleType;
0
497 }
never executed: }
0
498 } -
499 }
never executed: }
0
500 } -
501 -
502 if (type & FlagsMask) {
evaluated: type & FlagsMask
TRUEFALSE
yes
Evaluation Count:1755
yes
Evaluation Count:218
218-1755
503 if (exists)
partially evaluated: exists
TRUEFALSE
yes
Evaluation Count:1755
no
Evaluation Count:0
0-1755
504 ret |= ExistsFlag;
executed: ret |= ExistsFlag;
Execution Count:1755
1755
505 if (d->fileEntry.isRoot())
partially evaluated: d->fileEntry.isRoot()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1755
0-1755
506 ret |= RootFlag;
never executed: ret |= RootFlag;
0
507 else if (d->metaData.isHidden())
evaluated: d->metaData.isHidden()
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:1743
12-1743
508 ret |= HiddenFlag;
executed: ret |= HiddenFlag;
Execution Count:12
12
509 } -
510 -
511 return ret;
executed: return ret;
Execution Count:1973
1973
512} -
513 -
514QString QFSFileEngine::fileName(FileName file) const -
515{ -
516 const QFSFileEnginePrivate * const d = d_func(); -
517 if (file == BundleName) {
partially evaluated: file == BundleName
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:6037
0-6037
518 return QFileSystemEngine::bundleName(d->fileEntry);
never executed: return QFileSystemEngine::bundleName(d->fileEntry);
0
519 } else if (file == BaseName) {
partially evaluated: file == BaseName
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:6037
0-6037
520 return d->fileEntry.fileName();
never executed: return d->fileEntry.fileName();
0
521 } else if (file == PathName) {
partially evaluated: file == PathName
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:6037
0-6037
522 return d->fileEntry.path();
never executed: return d->fileEntry.path();
0
523 } else if (file == AbsoluteName || file == AbsolutePathName) {
partially evaluated: file == AbsoluteName
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:6037
partially evaluated: file == AbsolutePathName
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:6037
0-6037
524 QFileSystemEntry entry(QFileSystemEngine::absoluteName(d->fileEntry)); -
525 if (file == AbsolutePathName) {
never evaluated: file == AbsolutePathName
0
526 return entry.path();
never executed: return entry.path();
0
527 } -
528 return entry.filePath();
never executed: return entry.filePath();
0
529 } else if (file == CanonicalName || file == CanonicalPathName) {
partially evaluated: file == CanonicalName
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:6037
partially evaluated: file == CanonicalPathName
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:6037
0-6037
530 QFileSystemEntry entry(QFileSystemEngine::canonicalName(d->fileEntry, d->metaData)); -
531 if (file == CanonicalPathName)
never evaluated: file == CanonicalPathName
0
532 return entry.path();
never executed: return entry.path();
0
533 return entry.filePath();
never executed: return entry.filePath();
0
534 } else if (file == LinkName) {
evaluated: file == LinkName
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:6035
2-6035
535 if (d->isSymlink()) {
partially evaluated: d->isSymlink()
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
536 QFileSystemEntry entry = QFileSystemEngine::getLinkTarget(d->fileEntry, d->metaData); -
537 return entry.filePath();
executed: return entry.filePath();
Execution Count:2
2
538 } -
539 return QString();
never executed: return QString();
0
540 } -
541 return d->fileEntry.filePath();
executed: return d->fileEntry.filePath();
Execution Count:6035
6035
542} -
543 -
544bool QFSFileEngine::isRelativePath() const -
545{ -
546 const QFSFileEnginePrivate * const d = d_func(); -
547 return d->fileEntry.filePath().length() ? d->fileEntry.filePath()[0] != QLatin1Char('/') : true;
never executed: return d->fileEntry.filePath().length() ? d->fileEntry.filePath()[0] != QLatin1Char('/') : true;
0
548} -
549 -
550uint QFSFileEngine::ownerId(FileOwner own) const -
551{ -
552 const QFSFileEnginePrivate * const d = d_func(); -
553 static const uint nobodyID = (uint) -2; -
554 -
555 if (d->doStat(QFileSystemMetaData::OwnerIds))
never evaluated: d->doStat(QFileSystemMetaData::OwnerIds)
0
556 return d->metaData.ownerId(own);
never executed: return d->metaData.ownerId(own);
0
557 -
558 return nobodyID;
never executed: return nobodyID;
0
559} -
560 -
561QString QFSFileEngine::owner(FileOwner own) const -
562{ -
563 if (own == OwnerUser)
never evaluated: own == OwnerUser
0
564 return QFileSystemEngine::resolveUserName(ownerId(own));
never executed: return QFileSystemEngine::resolveUserName(ownerId(own));
0
565 return QFileSystemEngine::resolveGroupName(ownerId(own));
never executed: return QFileSystemEngine::resolveGroupName(ownerId(own));
0
566} -
567 -
568bool QFSFileEngine::setPermissions(uint perms) -
569{ -
570 QFSFileEnginePrivate * const d = d_func(); -
571 QSystemError error; -
572 if (!QFileSystemEngine::setPermissions(d->fileEntry, QFile::Permissions(perms), error, 0)) {
evaluated: !QFileSystemEngine::setPermissions(d->fileEntry, QFile::Permissions(perms), error, 0)
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:510
5-510
573 setError(QFile::PermissionsError, error.toString()); -
574 return false;
executed: return false;
Execution Count:5
5
575 } -
576 return true;
executed: return true;
Execution Count:510
510
577} -
578 -
579bool QFSFileEngine::setSize(qint64 size) -
580{ -
581 QFSFileEnginePrivate * const d = d_func(); -
582 bool ret = false; -
583 if (d->fd != -1)
evaluated: d->fd != -1
TRUEFALSE
yes
Evaluation Count:767
yes
Evaluation Count:6
6-767
584 ret = ::ftruncate64(d->fd, size) == 0;
executed: ret = ::ftruncate64(d->fd, size) == 0;
Execution Count:767
767
585 else if (d->fh)
evaluated: d->fh
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:5
1-5
586 ret = ::ftruncate64(fileno(d->fh), size) == 0;
executed: ret = ::ftruncate64(fileno(d->fh), size) == 0;
Execution Count:1
1
587 else -
588 ret = ::truncate64(d->fileEntry.nativeFilePath().constData(), size) == 0;
executed: ret = ::truncate64(d->fileEntry.nativeFilePath().constData(), size) == 0;
Execution Count:5
5
589 if (!ret)
partially evaluated: !ret
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:773
0-773
590 setError(QFile::ResizeError, qt_error_string((*__errno_location ())));
never executed: setError(QFile::ResizeError, qt_error_string((*__errno_location ())));
0
591 return ret;
executed: return ret;
Execution Count:773
773
592} -
593 -
594QDateTime QFSFileEngine::fileTime(FileTime time) const -
595{ -
596 const QFSFileEnginePrivate * const d = d_func(); -
597 -
598 if (d->doStat(QFileSystemMetaData::Times))
never evaluated: d->doStat(QFileSystemMetaData::Times)
0
599 return d->metaData.fileTime(time);
never executed: return d->metaData.fileTime(time);
0
600 -
601 return QDateTime();
never executed: return QDateTime();
0
602} -
603 -
604uchar *QFSFileEnginePrivate::map(qint64 offset, qint64 size, QFile::MemoryMapFlags flags) -
605{ -
606 QFSFileEngine * const q = q_func(); -
607 (void)flags;; -
608 if (openMode == QIODevice::NotOpen) {
evaluated: openMode == QIODevice::NotOpen
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:33326
8-33326
609 q->setError(QFile::PermissionsError, qt_error_string(int(13))); -
610 return 0;
executed: return 0;
Execution Count:8
8
611 } -
612 -
613 if (offset < 0 || offset != qint64(off64_t(offset))
evaluated: offset < 0
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:33325
partially evaluated: offset != qint64(off64_t(offset))
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:33325
0-33325
614 || size < 0 || quint64(size) > quint64(size_t(-1))) {
evaluated: size < 0
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:33324
partially evaluated: quint64(size) > quint64(size_t(-1))
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:33324
0-33324
615 q->setError(QFile::UnspecifiedError, qt_error_string(int(22))); -
616 return 0;
executed: return 0;
Execution Count:2
2
617 } -
618 -
619 -
620 -
621 if (doStat(QFileSystemMetaData::SizeAttribute)
partially evaluated: doStat(QFileSystemMetaData::SizeAttribute)
TRUEFALSE
yes
Evaluation Count:33324
no
Evaluation Count:0
0-33324
622 && (off64_t(size) > metaData.size() - off64_t(offset)))
evaluated: (off64_t(size) > metaData.size() - off64_t(offset))
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:33323
1-33323
623 QMessageLogger("io/qfsfileengine_unix.cpp", 676, __PRETTY_FUNCTION__).warning("QFSFileEngine::map: Mapping a file beyond its size is not portable");
executed: QMessageLogger("io/qfsfileengine_unix.cpp", 676, __PRETTY_FUNCTION__).warning("QFSFileEngine::map: Mapping a file beyond its size is not portable");
Execution Count:1
1
624 -
625 int access = 0; -
626 if (openMode & QIODevice::ReadOnly) access |= 0x1;
executed: access |= 0x1;
Execution Count:33324
partially evaluated: openMode & QIODevice::ReadOnly
TRUEFALSE
yes
Evaluation Count:33324
no
Evaluation Count:0
0-33324
627 if (openMode & QIODevice::WriteOnly) access |= 0x2;
executed: access |= 0x2;
Execution Count:33
evaluated: openMode & QIODevice::WriteOnly
TRUEFALSE
yes
Evaluation Count:33
yes
Evaluation Count:33291
33-33291
628 -
629 -
630 -
631 -
632 int pageSize = getpagesize(); -
633 -
634 int extra = offset % pageSize; -
635 -
636 if (quint64(size + extra) > quint64((size_t)-1)) {
partially evaluated: quint64(size + extra) > quint64((size_t)-1)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:33324
0-33324
637 q->setError(QFile::UnspecifiedError, qt_error_string(int(22))); -
638 return 0;
never executed: return 0;
0
639 } -
640 -
641 size_t realSize = (size_t)size + extra; -
642 off64_t realOffset = off64_t(offset); -
643 realOffset &= ~(off64_t(pageSize - 1)); -
644 -
645 void *mapAddress = ::mmap64((void*)0, realSize, -
646 access, 0x01, nativeHandle(), realOffset); -
647 if (((void *) -1) != mapAddress) {
evaluated: ((void *) -1) != mapAddress
TRUEFALSE
yes
Evaluation Count:33318
yes
Evaluation Count:6
6-33318
648 uchar *address = extra + static_cast<uchar*>(mapAddress); -
649 maps[address] = QPair<int,size_t>(extra, realSize); -
650 return address;
executed: return address;
Execution Count:33318
33318
651 } -
652 -
653 switch((*__errno_location ())) { -
654 case 9: -
655 q->setError(QFile::PermissionsError, qt_error_string(int(13))); -
656 break;
executed: break;
Execution Count:5
5
657 case 23: -
658 case 12: -
659 q->setError(QFile::ResourceError, qt_error_string(int((*__errno_location ())))); -
660 break;
never executed: break;
0
661 case 22: -
662 -
663 default: -
664 q->setError(QFile::UnspecifiedError, qt_error_string(int((*__errno_location ())))); -
665 break;
executed: break;
Execution Count:1
1
666 } -
667 return 0;
executed: return 0;
Execution Count:6
6
668} -
669 -
670bool QFSFileEnginePrivate::unmap(uchar *ptr) -
671{ -
672 -
673 QFSFileEngine * const q = q_func(); -
674 if (!maps.contains(ptr)) {
evaluated: !maps.contains(ptr)
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:33318
8-33318
675 q->setError(QFile::PermissionsError, qt_error_string(13)); -
676 return false;
executed: return false;
Execution Count:8
8
677 } -
678 -
679 uchar *start = ptr - maps[ptr].first; -
680 size_t len = maps[ptr].second; -
681 if (-1 == munmap(start, len)) {
partially evaluated: -1 == munmap(start, len)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:33318
0-33318
682 q->setError(QFile::UnspecifiedError, qt_error_string((*__errno_location ()))); -
683 return false;
never executed: return false;
0
684 } -
685 maps.remove(ptr); -
686 return true;
executed: return true;
Execution Count:33318
33318
687 -
688 -
689 -
690} -
691 -
692 -
693 -
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial