Line | Source Code | Coverage |
---|
1 | /**************************************************************************** | - |
2 | ** | - |
3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). | - |
4 | ** Contact: http://www.qt-project.org/legal | - |
5 | ** | - |
6 | ** This file is part of the QtCore module of the Qt Toolkit. | - |
7 | ** | - |
8 | ** $QT_BEGIN_LICENSE:LGPL$ | - |
9 | ** Commercial License Usage | - |
10 | ** Licensees holding valid commercial Qt licenses may use this file in | - |
11 | ** accordance with the commercial license agreement provided with the | - |
12 | ** Software or, alternatively, in accordance with the terms contained in | - |
13 | ** a written agreement between you and Digia. For licensing terms and | - |
14 | ** conditions see http://qt.digia.com/licensing. For further information | - |
15 | ** use the contact form at http://qt.digia.com/contact-us. | - |
16 | ** | - |
17 | ** GNU Lesser General Public License Usage | - |
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - |
19 | ** General Public License version 2.1 as published by the Free Software | - |
20 | ** Foundation and appearing in the file LICENSE.LGPL included in the | - |
21 | ** packaging of this file. Please review the following information to | - |
22 | ** ensure the GNU Lesser General Public License version 2.1 requirements | - |
23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - |
24 | ** | - |
25 | ** In addition, as a special exception, Digia gives you certain additional | - |
26 | ** rights. These rights are described in the Digia Qt LGPL Exception | - |
27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - |
28 | ** | - |
29 | ** GNU General Public License Usage | - |
30 | ** Alternatively, this file may be used under the terms of the GNU | - |
31 | ** General Public License version 3.0 as published by the Free Software | - |
32 | ** Foundation and appearing in the file LICENSE.GPL included in the | - |
33 | ** packaging of this file. Please review the following information to | - |
34 | ** ensure the GNU General Public License version 3.0 requirements will be | - |
35 | ** met: http://www.gnu.org/copyleft/gpl.html. | - |
36 | ** | - |
37 | ** | - |
38 | ** $QT_END_LICENSE$ | - |
39 | ** | - |
40 | ****************************************************************************/ | - |
41 | | - |
42 | #include "qplatformdefs.h" | - |
43 | #include "private/qabstractfileengine_p.h" | - |
44 | #include "private/qfsfileengine_p.h" | - |
45 | #include "private/qcore_unix_p.h" | - |
46 | #include "qfilesystementry_p.h" | - |
47 | #include "qfilesystemengine_p.h" | - |
48 | | - |
49 | #ifndef QT_NO_FSFILEENGINE | - |
50 | | - |
51 | #include "qfile.h" | - |
52 | #include "qdir.h" | - |
53 | #include "qdatetime.h" | - |
54 | #include "qvarlengtharray.h" | - |
55 | | - |
56 | #include <sys/mman.h> | - |
57 | #include <stdlib.h> | - |
58 | #include <limits.h> | - |
59 | #include <errno.h> | - |
60 | #if !defined(QWS) && defined(Q_OS_MAC) | - |
61 | # include <private/qcore_mac_p.h> | - |
62 | #endif | - |
63 | | - |
64 | QT_BEGIN_NAMESPACE | - |
65 | | - |
66 | /*! | - |
67 | \internal | - |
68 | | - |
69 | Returns the stdlib open string corresponding to a QIODevice::OpenMode. | - |
70 | */ | - |
71 | static inline QByteArray openModeToFopenMode(QIODevice::OpenMode flags, const QFileSystemEntry &fileEntry, | - |
72 | QFileSystemMetaData &metaData) | - |
73 | { | - |
74 | QByteArray mode; never executed (the execution status of this line is deduced): QByteArray mode; | - |
75 | if ((flags & QIODevice::ReadOnly) && !(flags & QIODevice::Truncate)) { never evaluated: (flags & QIODevice::ReadOnly) never evaluated: !(flags & QIODevice::Truncate) | 0 |
76 | mode = "rb"; never executed (the execution status of this line is deduced): mode = "rb"; | - |
77 | if (flags & QIODevice::WriteOnly) { never evaluated: flags & QIODevice::WriteOnly | 0 |
78 | metaData.clearFlags(QFileSystemMetaData::FileType); never executed (the execution status of this line is deduced): metaData.clearFlags(QFileSystemMetaData::FileType); | - |
79 | if (!fileEntry.isEmpty() never evaluated: !fileEntry.isEmpty() | 0 |
80 | && QFileSystemEngine::fillMetaData(fileEntry, metaData, QFileSystemMetaData::FileType) never evaluated: QFileSystemEngine::fillMetaData(fileEntry, metaData, QFileSystemMetaData::FileType) | 0 |
81 | && metaData.isFile()) { never evaluated: metaData.isFile() | 0 |
82 | mode += '+'; never executed (the execution status of this line is deduced): mode += '+'; | - |
83 | } else { | 0 |
84 | mode = "wb+"; never executed (the execution status of this line is deduced): mode = "wb+"; | - |
85 | } | 0 |
86 | } | - |
87 | } else if (flags & QIODevice::WriteOnly) { never executed: } never evaluated: flags & QIODevice::WriteOnly | 0 |
88 | mode = "wb"; never executed (the execution status of this line is deduced): mode = "wb"; | - |
89 | if (flags & QIODevice::ReadOnly) never evaluated: flags & QIODevice::ReadOnly | 0 |
90 | mode += '+'; never executed: mode += '+'; | 0 |
91 | } | 0 |
92 | if (flags & QIODevice::Append) { never evaluated: flags & QIODevice::Append | 0 |
93 | mode = "ab"; never executed (the execution status of this line is deduced): mode = "ab"; | - |
94 | if (flags & QIODevice::ReadOnly) never evaluated: flags & QIODevice::ReadOnly | 0 |
95 | mode += '+'; never executed: mode += '+'; | 0 |
96 | } | 0 |
97 | | - |
98 | #if defined(__GLIBC__) && (__GLIBC__ * 0x100 + __GLIBC_MINOR__) >= 0x0207 | - |
99 | // must be glibc >= 2.7 | - |
100 | mode += 'e'; never executed (the execution status of this line is deduced): mode += 'e'; | - |
101 | #endif | - |
102 | | - |
103 | return mode; never executed: return mode; | 0 |
104 | } | - |
105 | | - |
106 | /*! | - |
107 | \internal | - |
108 | | - |
109 | Returns the stdio open flags corresponding to a QIODevice::OpenMode. | - |
110 | */ | - |
111 | static inline int openModeToOpenFlags(QIODevice::OpenMode mode) | - |
112 | { | - |
113 | int oflags = QT_OPEN_RDONLY; executed (the execution status of this line is deduced): int oflags = 00; | - |
114 | #ifdef QT_LARGEFILE_SUPPORT | - |
115 | oflags |= QT_OPEN_LARGEFILE; executed (the execution status of this line is deduced): oflags |= 0; | - |
116 | #endif | - |
117 | | - |
118 | if ((mode & QFile::ReadWrite) == QFile::ReadWrite) { evaluated: (mode & QFile::ReadWrite) == QFile::ReadWrite yes Evaluation Count:1050 | yes Evaluation Count:17070 |
| 1050-17070 |
119 | oflags = QT_OPEN_RDWR | QT_OPEN_CREAT; executed (the execution status of this line is deduced): oflags = 02 | 0100; | - |
120 | } else if (mode & QFile::WriteOnly) { executed: } Execution Count:1050 evaluated: mode & QFile::WriteOnly yes Evaluation Count:1521 | yes Evaluation Count:15549 |
| 1050-15549 |
121 | oflags = QT_OPEN_WRONLY | QT_OPEN_CREAT; executed (the execution status of this line is deduced): oflags = 01 | 0100; | - |
122 | } executed: } Execution Count:1521 | 1521 |
123 | | - |
124 | if (mode & QFile::Append) { evaluated: mode & QFile::Append yes Evaluation Count:248 | yes Evaluation Count:17872 |
| 248-17872 |
125 | oflags |= QT_OPEN_APPEND; executed (the execution status of this line is deduced): oflags |= 02000; | - |
126 | } else if (mode & QFile::WriteOnly) { executed: } Execution Count:248 evaluated: mode & QFile::WriteOnly yes Evaluation Count:2323 | yes Evaluation Count:15549 |
| 248-15549 |
127 | if ((mode & QFile::Truncate) || !(mode & QFile::ReadOnly)) evaluated: (mode & QFile::Truncate) yes Evaluation Count:1278 | yes Evaluation Count:1045 |
partially evaluated: !(mode & QFile::ReadOnly) no Evaluation Count:0 | yes Evaluation Count:1045 |
| 0-1278 |
128 | oflags |= QT_OPEN_TRUNC; executed: oflags |= 01000; Execution Count:1278 | 1278 |
129 | } executed: } Execution Count:2323 | 2323 |
130 | | - |
131 | return oflags; executed: return oflags; Execution Count:18120 | 18120 |
132 | } | - |
133 | | - |
134 | /*! | - |
135 | \internal | - |
136 | | - |
137 | Sets the file descriptor to close on exec. That is, the file | - |
138 | descriptor is not inherited by child processes. | - |
139 | */ | - |
140 | static inline bool setCloseOnExec(int fd) | - |
141 | { | - |
142 | return fd != -1 && fcntl(fd, F_SETFD, FD_CLOEXEC) != -1; never executed: return fd != -1 && fcntl(fd, 2, 1) != -1; | 0 |
143 | } | - |
144 | | - |
145 | /*! | - |
146 | \internal | - |
147 | */ | - |
148 | bool QFSFileEnginePrivate::nativeOpen(QIODevice::OpenMode openMode) | - |
149 | { | - |
150 | Q_Q(QFSFileEngine); executed (the execution status of this line is deduced): QFSFileEngine * const q = q_func(); | - |
151 | | - |
152 | if (openMode & QIODevice::Unbuffered) { partially evaluated: openMode & QIODevice::Unbuffered yes Evaluation Count:18120 | no Evaluation Count:0 |
| 0-18120 |
153 | int flags = openModeToOpenFlags(openMode); executed (the execution status of this line is deduced): int flags = openModeToOpenFlags(openMode); | - |
154 | | - |
155 | // Try to open the file in unbuffered mode. | - |
156 | do { | - |
157 | fd = QT_OPEN(fileEntry.nativeFilePath().constData(), flags, 0666); executed (the execution status of this line is deduced): fd = qt_safe_open(fileEntry.nativeFilePath().constData(), flags, 0666); | - |
158 | } while (fd == -1 && errno == EINTR); executed: } Execution Count:18121 evaluated: fd == -1 yes Evaluation Count:3074 | yes Evaluation Count:15046 |
partially evaluated: (*__errno_location ()) == 4 no Evaluation Count:0 | yes Evaluation Count:3074 |
| 0-18121 |
159 | | - |
160 | // On failure, return and report the error. | - |
161 | if (fd == -1) { evaluated: fd == -1 yes Evaluation Count:3074 | yes Evaluation Count:15046 |
| 3074-15046 |
162 | q->setError(errno == EMFILE ? QFile::ResourceError : QFile::OpenError, executed (the execution status of this line is deduced): q->setError((*__errno_location ()) == 24 ? QFile::ResourceError : QFile::OpenError, | - |
163 | qt_error_string(errno)); executed (the execution status of this line is deduced): qt_error_string((*__errno_location ()))); | - |
164 | return false; executed: return false; Execution Count:3074 | 3074 |
165 | } | - |
166 | | - |
167 | if (!(openMode & QIODevice::WriteOnly)) { evaluated: !(openMode & QIODevice::WriteOnly) yes Evaluation Count:12510 | yes Evaluation Count:2536 |
| 2536-12510 |
168 | // we don't need this check if we tried to open for writing because then | - |
169 | // we had received EISDIR anyway. | - |
170 | if (QFileSystemEngine::fillMetaData(fd, metaData) partially evaluated: QFileSystemEngine::fillMetaData(fd, metaData) yes Evaluation Count:12511 | no Evaluation Count:0 |
| 0-12511 |
171 | && metaData.isDirectory()) { evaluated: metaData.isDirectory() yes Evaluation Count:7 | yes Evaluation Count:12504 |
| 7-12504 |
172 | q->setError(QFile::OpenError, QLatin1String("file to open is a directory")); executed (the execution status of this line is deduced): q->setError(QFile::OpenError, QLatin1String("file to open is a directory")); | - |
173 | QT_CLOSE(fd); executed (the execution status of this line is deduced): qt_safe_close(fd); | - |
174 | return false; executed: return false; Execution Count:7 | 7 |
175 | } | - |
176 | } executed: } Execution Count:12503 | 12503 |
177 | | - |
178 | // Seek to the end when in Append mode. | - |
179 | if (flags & QFile::Append) { partially evaluated: flags & QFile::Append no Evaluation Count:0 | yes Evaluation Count:15039 |
| 0-15039 |
180 | int ret; never executed (the execution status of this line is deduced): int ret; | - |
181 | do { | - |
182 | ret = QT_LSEEK(fd, 0, SEEK_END); never executed (the execution status of this line is deduced): ret = ::lseek64(fd, 0, 2); | - |
183 | } while (ret == -1 && errno == EINTR); never executed: } never evaluated: ret == -1 never evaluated: (*__errno_location ()) == 4 | 0 |
184 | | - |
185 | if (ret == -1) { never evaluated: ret == -1 | 0 |
186 | q->setError(errno == EMFILE ? QFile::ResourceError : QFile::OpenError, never executed (the execution status of this line is deduced): q->setError((*__errno_location ()) == 24 ? QFile::ResourceError : QFile::OpenError, | - |
187 | qt_error_string(int(errno))); never executed (the execution status of this line is deduced): qt_error_string(int((*__errno_location ())))); | - |
188 | return false; never executed: return false; | 0 |
189 | } | - |
190 | } | 0 |
191 | | - |
192 | fh = 0; executed (the execution status of this line is deduced): fh = 0; | - |
193 | } else { executed: } Execution Count:15040 | 15040 |
194 | QByteArray fopenMode = openModeToFopenMode(openMode, fileEntry, metaData); never executed (the execution status of this line is deduced): QByteArray fopenMode = openModeToFopenMode(openMode, fileEntry, metaData); | - |
195 | | - |
196 | // Try to open the file in buffered mode. | - |
197 | do { | - |
198 | fh = QT_FOPEN(fileEntry.nativeFilePath().constData(), fopenMode.constData()); never executed (the execution status of this line is deduced): fh = ::fopen64(fileEntry.nativeFilePath().constData(), fopenMode.constData()); | - |
199 | } while (!fh && errno == EINTR); never executed: } never evaluated: !fh never evaluated: (*__errno_location ()) == 4 | 0 |
200 | | - |
201 | // On failure, return and report the error. | - |
202 | if (!fh) { | 0 |
203 | q->setError(errno == EMFILE ? QFile::ResourceError : QFile::OpenError, never executed (the execution status of this line is deduced): q->setError((*__errno_location ()) == 24 ? QFile::ResourceError : QFile::OpenError, | - |
204 | qt_error_string(int(errno))); never executed (the execution status of this line is deduced): qt_error_string(int((*__errno_location ())))); | - |
205 | return false; never executed: return false; | 0 |
206 | } | - |
207 | | - |
208 | if (!(openMode & QIODevice::WriteOnly)) { never evaluated: !(openMode & QIODevice::WriteOnly) | 0 |
209 | // we don't need this check if we tried to open for writing because then | - |
210 | // we had received EISDIR anyway. | - |
211 | if (QFileSystemEngine::fillMetaData(QT_FILENO(fh), metaData) never evaluated: QFileSystemEngine::fillMetaData(fileno(fh), metaData) | 0 |
212 | && metaData.isDirectory()) { never evaluated: metaData.isDirectory() | 0 |
213 | q->setError(QFile::OpenError, QLatin1String("file to open is a directory")); never executed (the execution status of this line is deduced): q->setError(QFile::OpenError, QLatin1String("file to open is a directory")); | - |
214 | fclose(fh); never executed (the execution status of this line is deduced): fclose(fh); | - |
215 | return false; never executed: return false; | 0 |
216 | } | - |
217 | } | 0 |
218 | | - |
219 | setCloseOnExec(fileno(fh)); // ignore failure never executed (the execution status of this line is deduced): setCloseOnExec(fileno(fh)); | - |
220 | | - |
221 | // Seek to the end when in Append mode. | - |
222 | if (openMode & QIODevice::Append) { never evaluated: openMode & QIODevice::Append | 0 |
223 | int ret; never executed (the execution status of this line is deduced): int ret; | - |
224 | do { | - |
225 | ret = QT_FSEEK(fh, 0, SEEK_END); never executed (the execution status of this line is deduced): ret = ::fseeko64(fh, 0, 2); | - |
226 | } while (ret == -1 && errno == EINTR); never executed: } never evaluated: ret == -1 never evaluated: (*__errno_location ()) == 4 | 0 |
227 | | - |
228 | if (ret == -1) { never evaluated: ret == -1 | 0 |
229 | q->setError(errno == EMFILE ? QFile::ResourceError : QFile::OpenError, never executed (the execution status of this line is deduced): q->setError((*__errno_location ()) == 24 ? QFile::ResourceError : QFile::OpenError, | - |
230 | qt_error_string(int(errno))); never executed (the execution status of this line is deduced): qt_error_string(int((*__errno_location ())))); | - |
231 | return false; never executed: return false; | 0 |
232 | } | - |
233 | } | 0 |
234 | | - |
235 | fd = -1; never executed (the execution status of this line is deduced): fd = -1; | - |
236 | } | 0 |
237 | | - |
238 | closeFileHandle = true; executed (the execution status of this line is deduced): closeFileHandle = true; | - |
239 | return true; executed: return true; Execution Count:15040 | 15040 |
240 | } | - |
241 | | - |
242 | /*! | - |
243 | \internal | - |
244 | */ | - |
245 | bool QFSFileEnginePrivate::nativeClose() | - |
246 | { | - |
247 | return closeFdFh(); executed: return closeFdFh(); Execution Count:17226 | 17226 |
248 | } | - |
249 | | - |
250 | /*! | - |
251 | \internal | - |
252 | | - |
253 | */ | - |
254 | bool QFSFileEnginePrivate::nativeFlush() | - |
255 | { | - |
256 | return fh ? flushFh() : fd != -1; executed: return fh ? flushFh() : fd != -1; Execution Count:23302 | 23302 |
257 | } | - |
258 | | - |
259 | /*! | - |
260 | \internal | - |
261 | */ | - |
262 | qint64 QFSFileEnginePrivate::nativeRead(char *data, qint64 len) | - |
263 | { | - |
264 | Q_Q(QFSFileEngine); executed (the execution status of this line is deduced): QFSFileEngine * const q = q_func(); | - |
265 | | - |
266 | if (fh && nativeIsSequential()) { evaluated: fh yes Evaluation Count:5 | yes Evaluation Count:115648 |
partially evaluated: nativeIsSequential() no Evaluation Count:0 | yes Evaluation Count:5 |
| 0-115648 |
267 | size_t readBytes = 0; never executed (the execution status of this line is deduced): size_t readBytes = 0; | - |
268 | int oldFlags = fcntl(QT_FILENO(fh), F_GETFL); never executed (the execution status of this line is deduced): int oldFlags = fcntl(fileno(fh), 3); | - |
269 | for (int i = 0; i < 2; ++i) { | 0 |
270 | // Unix: Make the underlying file descriptor non-blocking | - |
271 | if ((oldFlags & O_NONBLOCK) == 0) never evaluated: (oldFlags & 04000) == 0 | 0 |
272 | fcntl(QT_FILENO(fh), F_SETFL, oldFlags | O_NONBLOCK); never executed: fcntl(fileno(fh), 4, oldFlags | 04000); | 0 |
273 | | - |
274 | // Cross platform stdlib read | - |
275 | size_t read = 0; never executed (the execution status of this line is deduced): size_t read = 0; | - |
276 | do { | - |
277 | read = fread(data + readBytes, 1, size_t(len - readBytes), fh); never executed (the execution status of this line is deduced): read = fread(data + readBytes, 1, size_t(len - readBytes), fh); | - |
278 | } while (read == 0 && !feof(fh) && errno == EINTR); never executed: } never evaluated: read == 0 never evaluated: !feof(fh) never evaluated: (*__errno_location ()) == 4 | 0 |
279 | if (read > 0) { never evaluated: read > 0 | 0 |
280 | readBytes += read; never executed (the execution status of this line is deduced): readBytes += read; | - |
281 | break; | 0 |
282 | } else { | - |
283 | if (readBytes) never evaluated: readBytes | 0 |
284 | break; | 0 |
285 | readBytes = read; never executed (the execution status of this line is deduced): readBytes = read; | - |
286 | } | 0 |
287 | | - |
288 | // Unix: Restore the blocking state of the underlying socket | - |
289 | if ((oldFlags & O_NONBLOCK) == 0) { never evaluated: (oldFlags & 04000) == 0 | 0 |
290 | fcntl(QT_FILENO(fh), F_SETFL, oldFlags); never executed (the execution status of this line is deduced): fcntl(fileno(fh), 4, oldFlags); | - |
291 | if (readBytes == 0) { never evaluated: readBytes == 0 | 0 |
292 | int readByte = 0; never executed (the execution status of this line is deduced): int readByte = 0; | - |
293 | do { | - |
294 | readByte = fgetc(fh); never executed (the execution status of this line is deduced): readByte = fgetc(fh); | - |
295 | } while (readByte == -1 && errno == EINTR); never executed: } never evaluated: readByte == -1 never evaluated: (*__errno_location ()) == 4 | 0 |
296 | if (readByte != -1) { never evaluated: readByte != -1 | 0 |
297 | *data = uchar(readByte); never executed (the execution status of this line is deduced): *data = uchar(readByte); | - |
298 | readBytes += 1; never executed (the execution status of this line is deduced): readBytes += 1; | - |
299 | } else { | 0 |
300 | break; | 0 |
301 | } | - |
302 | } | - |
303 | } | 0 |
304 | } | 0 |
305 | // Unix: Restore the blocking state of the underlying socket | - |
306 | if ((oldFlags & O_NONBLOCK) == 0) { never evaluated: (oldFlags & 04000) == 0 | 0 |
307 | fcntl(QT_FILENO(fh), F_SETFL, oldFlags); never executed (the execution status of this line is deduced): fcntl(fileno(fh), 4, oldFlags); | - |
308 | } | 0 |
309 | if (readBytes == 0 && !feof(fh)) { never evaluated: readBytes == 0 never evaluated: !feof(fh) | 0 |
310 | // if we didn't read anything and we're not at EOF, it must be an error | - |
311 | q->setError(QFile::ReadError, qt_error_string(int(errno))); never executed (the execution status of this line is deduced): q->setError(QFile::ReadError, qt_error_string(int((*__errno_location ())))); | - |
312 | return -1; never executed: return -1; | 0 |
313 | } | - |
314 | return readBytes; never executed: return readBytes; | 0 |
315 | } | - |
316 | | - |
317 | return readFdFh(data, len); executed: return readFdFh(data, len); Execution Count:115653 | 115653 |
318 | } | - |
319 | | - |
320 | /*! | - |
321 | \internal | - |
322 | */ | - |
323 | qint64 QFSFileEnginePrivate::nativeReadLine(char *data, qint64 maxlen) | - |
324 | { | - |
325 | return readLineFdFh(data, maxlen); executed: return readLineFdFh(data, maxlen); Execution Count:8 | 8 |
326 | } | - |
327 | | - |
328 | /*! | - |
329 | \internal | - |
330 | */ | - |
331 | qint64 QFSFileEnginePrivate::nativeWrite(const char *data, qint64 len) | - |
332 | { | - |
333 | return writeFdFh(data, len); executed: return writeFdFh(data, len); Execution Count:16701 | 16701 |
334 | } | - |
335 | | - |
336 | /*! | - |
337 | \internal | - |
338 | */ | - |
339 | qint64 QFSFileEnginePrivate::nativePos() const | - |
340 | { | - |
341 | return posFdFh(); executed: return posFdFh(); Execution Count:768 | 768 |
342 | } | - |
343 | | - |
344 | /*! | - |
345 | \internal | - |
346 | */ | - |
347 | bool QFSFileEnginePrivate::nativeSeek(qint64 pos) | - |
348 | { | - |
349 | return seekFdFh(pos); executed: return seekFdFh(pos); Execution Count:221320 | 221320 |
350 | } | - |
351 | | - |
352 | /*! | - |
353 | \internal | - |
354 | */ | - |
355 | int QFSFileEnginePrivate::nativeHandle() const | - |
356 | { | - |
357 | return fh ? fileno(fh) : fd; executed: return fh ? fileno(fh) : fd; Execution Count:34293 | 34293 |
358 | } | - |
359 | | - |
360 | /*! | - |
361 | \internal | - |
362 | */ | - |
363 | bool QFSFileEnginePrivate::nativeIsSequential() const | - |
364 | { | - |
365 | return isSequentialFdFh(); executed: return isSequentialFdFh(); Execution Count:13531 | 13531 |
366 | } | - |
367 | | - |
368 | bool QFSFileEngine::remove() | - |
369 | { | - |
370 | Q_D(QFSFileEngine); executed (the execution status of this line is deduced): QFSFileEnginePrivate * const d = d_func(); | - |
371 | QSystemError error; executed (the execution status of this line is deduced): QSystemError error; | - |
372 | bool ret = QFileSystemEngine::removeFile(d->fileEntry, error); executed (the execution status of this line is deduced): bool ret = QFileSystemEngine::removeFile(d->fileEntry, error); | - |
373 | d->metaData.clear(); executed (the execution status of this line is deduced): d->metaData.clear(); | - |
374 | if (!ret) { evaluated: !ret yes Evaluation Count:615 | yes Evaluation Count:4879 |
| 615-4879 |
375 | setError(QFile::RemoveError, error.toString()); executed (the execution status of this line is deduced): setError(QFile::RemoveError, error.toString()); | - |
376 | } executed: } Execution Count:615 | 615 |
377 | return ret; executed: return ret; Execution Count:5494 | 5494 |
378 | } | - |
379 | | - |
380 | bool QFSFileEngine::copy(const QString &newName) | - |
381 | { | - |
382 | Q_D(QFSFileEngine); executed (the execution status of this line is deduced): QFSFileEnginePrivate * const d = d_func(); | - |
383 | QSystemError error; executed (the execution status of this line is deduced): QSystemError error; | - |
384 | bool ret = QFileSystemEngine::copyFile(d->fileEntry, QFileSystemEntry(newName), error); executed (the execution status of this line is deduced): bool ret = QFileSystemEngine::copyFile(d->fileEntry, QFileSystemEntry(newName), error); | - |
385 | if (!ret) { partially evaluated: !ret yes Evaluation Count:96 | no Evaluation Count:0 |
| 0-96 |
386 | setError(QFile::CopyError, error.toString()); executed (the execution status of this line is deduced): setError(QFile::CopyError, error.toString()); | - |
387 | } executed: } Execution Count:96 | 96 |
388 | return ret; executed: return ret; Execution Count:96 | 96 |
389 | } | - |
390 | | - |
391 | bool QFSFileEngine::rename(const QString &newName) | - |
392 | { | - |
393 | Q_D(QFSFileEngine); executed (the execution status of this line is deduced): QFSFileEnginePrivate * const d = d_func(); | - |
394 | QSystemError error; executed (the execution status of this line is deduced): QSystemError error; | - |
395 | bool ret = QFileSystemEngine::renameFile(d->fileEntry, QFileSystemEntry(newName), error); executed (the execution status of this line is deduced): bool ret = QFileSystemEngine::renameFile(d->fileEntry, QFileSystemEntry(newName), error); | - |
396 | | - |
397 | if (!ret) { evaluated: !ret yes Evaluation Count:3 | yes Evaluation Count:200 |
| 3-200 |
398 | setError(QFile::RenameError, error.toString()); executed (the execution status of this line is deduced): setError(QFile::RenameError, error.toString()); | - |
399 | } executed: } Execution Count:3 | 3 |
400 | | - |
401 | return ret; executed: return ret; Execution Count:203 | 203 |
402 | } | - |
403 | | - |
404 | bool QFSFileEngine::link(const QString &newName) | - |
405 | { | - |
406 | Q_D(QFSFileEngine); executed (the execution status of this line is deduced): QFSFileEnginePrivate * const d = d_func(); | - |
407 | QSystemError error; executed (the execution status of this line is deduced): QSystemError error; | - |
408 | bool ret = QFileSystemEngine::createLink(d->fileEntry, QFileSystemEntry(newName), error); executed (the execution status of this line is deduced): bool ret = QFileSystemEngine::createLink(d->fileEntry, QFileSystemEntry(newName), error); | - |
409 | if (!ret) { partially evaluated: !ret no Evaluation Count:0 | yes Evaluation Count:145 |
| 0-145 |
410 | setError(QFile::RenameError, error.toString()); never executed (the execution status of this line is deduced): setError(QFile::RenameError, error.toString()); | - |
411 | } | 0 |
412 | return ret; executed: return ret; Execution Count:145 | 145 |
413 | } | - |
414 | | - |
415 | qint64 QFSFileEnginePrivate::nativeSize() const | - |
416 | { | - |
417 | return sizeFdFh(); executed: return sizeFdFh(); Execution Count:122314 | 122314 |
418 | } | - |
419 | | - |
420 | bool QFSFileEngine::mkdir(const QString &name, bool createParentDirectories) const | - |
421 | { | - |
422 | return QFileSystemEngine::createDirectory(QFileSystemEntry(name), createParentDirectories); never executed: return QFileSystemEngine::createDirectory(QFileSystemEntry(name), createParentDirectories); | 0 |
423 | } | - |
424 | | - |
425 | bool QFSFileEngine::rmdir(const QString &name, bool recurseParentDirectories) const | - |
426 | { | - |
427 | return QFileSystemEngine::removeDirectory(QFileSystemEntry(name), recurseParentDirectories); never executed: return QFileSystemEngine::removeDirectory(QFileSystemEntry(name), recurseParentDirectories); | 0 |
428 | } | - |
429 | | - |
430 | bool QFSFileEngine::caseSensitive() const | - |
431 | { | - |
432 | return true; never executed: return true; | 0 |
433 | } | - |
434 | | - |
435 | bool QFSFileEngine::setCurrentPath(const QString &path) | - |
436 | { | - |
437 | return QFileSystemEngine::setCurrentPath(QFileSystemEntry(path)); never executed: return QFileSystemEngine::setCurrentPath(QFileSystemEntry(path)); | 0 |
438 | } | - |
439 | | - |
440 | QString QFSFileEngine::currentPath(const QString &) | - |
441 | { | - |
442 | return QFileSystemEngine::currentPath().filePath(); never executed: return QFileSystemEngine::currentPath().filePath(); | 0 |
443 | } | - |
444 | | - |
445 | QString QFSFileEngine::homePath() | - |
446 | { | - |
447 | return QFileSystemEngine::homePath(); never executed: return QFileSystemEngine::homePath(); | 0 |
448 | } | - |
449 | | - |
450 | QString QFSFileEngine::rootPath() | - |
451 | { | - |
452 | return QFileSystemEngine::rootPath(); executed: return QFileSystemEngine::rootPath(); Execution Count:147 | 147 |
453 | } | - |
454 | | - |
455 | QString QFSFileEngine::tempPath() | - |
456 | { | - |
457 | return QFileSystemEngine::tempPath(); never executed: return QFileSystemEngine::tempPath(); | 0 |
458 | } | - |
459 | | - |
460 | QFileInfoList QFSFileEngine::drives() | - |
461 | { | - |
462 | QFileInfoList ret; executed (the execution status of this line is deduced): QFileInfoList ret; | - |
463 | ret.append(QFileInfo(rootPath())); executed (the execution status of this line is deduced): ret.append(QFileInfo(rootPath())); | - |
464 | return ret; executed: return ret; Execution Count:147 | 147 |
465 | } | - |
466 | | - |
467 | bool QFSFileEnginePrivate::doStat(QFileSystemMetaData::MetaDataFlags flags) const | - |
468 | { | - |
469 | if (!tried_stat || !metaData.hasFlags(flags)) { evaluated: !tried_stat yes Evaluation Count:140279 | yes Evaluation Count:34009 |
evaluated: !metaData.hasFlags(flags) yes Evaluation Count:286 | yes Evaluation Count:33723 |
| 286-140279 |
470 | tried_stat = 1; executed (the execution status of this line is deduced): tried_stat = 1; | - |
471 | | - |
472 | int localFd = fd; executed (the execution status of this line is deduced): int localFd = fd; | - |
473 | if (fh && fileEntry.isEmpty()) evaluated: fh yes Evaluation Count:41 | yes Evaluation Count:140525 |
partially evaluated: fileEntry.isEmpty() yes Evaluation Count:41 | no Evaluation Count:0 |
| 0-140525 |
474 | localFd = QT_FILENO(fh); executed: localFd = fileno(fh); Execution Count:41 | 41 |
475 | if (localFd != -1) evaluated: localFd != -1 yes Evaluation Count:135652 | yes Evaluation Count:4914 |
| 4914-135652 |
476 | QFileSystemEngine::fillMetaData(localFd, metaData); executed: QFileSystemEngine::fillMetaData(localFd, metaData); Execution Count:135651 | 135651 |
477 | | - |
478 | if (metaData.missingFlags(flags) && !fileEntry.isEmpty()) evaluated: metaData.missingFlags(flags) yes Evaluation Count:5332 | yes Evaluation Count:135234 |
evaluated: !fileEntry.isEmpty() yes Evaluation Count:5331 | yes Evaluation Count:1 |
| 1-135234 |
479 | QFileSystemEngine::fillMetaData(fileEntry, metaData, metaData.missingFlags(flags)); executed: QFileSystemEngine::fillMetaData(fileEntry, metaData, metaData.missingFlags(flags)); Execution Count:5331 | 5331 |
480 | } executed: } Execution Count:140565 | 140565 |
481 | | - |
482 | return metaData.exists(); executed: return metaData.exists(); Execution Count:174288 | 174288 |
483 | } | - |
484 | | - |
485 | bool QFSFileEnginePrivate::isSymlink() const | - |
486 | { | - |
487 | if (!metaData.hasFlags(QFileSystemMetaData::LinkType)) partially evaluated: !metaData.hasFlags(QFileSystemMetaData::LinkType) yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
488 | QFileSystemEngine::fillMetaData(fileEntry, metaData, QFileSystemMetaData::LinkType); executed: QFileSystemEngine::fillMetaData(fileEntry, metaData, QFileSystemMetaData::LinkType); Execution Count:2 | 2 |
489 | | - |
490 | return metaData.isLink(); executed: return metaData.isLink(); Execution Count:2 | 2 |
491 | } | - |
492 | | - |
493 | /*! | - |
494 | \reimp | - |
495 | */ | - |
496 | QAbstractFileEngine::FileFlags QFSFileEngine::fileFlags(FileFlags type) const | - |
497 | { | - |
498 | Q_D(const QFSFileEngine); executed (the execution status of this line is deduced): const QFSFileEnginePrivate * const d = d_func(); | - |
499 | | - |
500 | if (type & Refresh) evaluated: type & Refresh yes Evaluation Count:4901 | yes Evaluation Count:218 |
| 218-4901 |
501 | d->metaData.clear(); executed: d->metaData.clear(); Execution Count:4901 | 4901 |
502 | | - |
503 | QAbstractFileEngine::FileFlags ret = 0; executed (the execution status of this line is deduced): QAbstractFileEngine::FileFlags ret = 0; | - |
504 | | - |
505 | if (type & FlagsMask) evaluated: type & FlagsMask yes Evaluation Count:4901 | yes Evaluation Count:218 |
| 218-4901 |
506 | ret |= LocalDiskFlag; executed: ret |= LocalDiskFlag; Execution Count:4901 | 4901 |
507 | | - |
508 | bool exists; executed (the execution status of this line is deduced): bool exists; | - |
509 | { | - |
510 | QFileSystemMetaData::MetaDataFlags queryFlags = 0; executed (the execution status of this line is deduced): QFileSystemMetaData::MetaDataFlags queryFlags = 0; | - |
511 | | - |
512 | queryFlags |= QFileSystemMetaData::MetaDataFlags(uint(type)) executed (the execution status of this line is deduced): queryFlags |= QFileSystemMetaData::MetaDataFlags(uint(type)) | - |
513 | & QFileSystemMetaData::Permissions; executed (the execution status of this line is deduced): & QFileSystemMetaData::Permissions; | - |
514 | | - |
515 | if (type & TypesMask) partially evaluated: type & TypesMask no Evaluation Count:0 | yes Evaluation Count:5119 |
| 0-5119 |
516 | queryFlags |= QFileSystemMetaData::AliasType never executed: queryFlags |= QFileSystemMetaData::AliasType | QFileSystemMetaData::LinkType | QFileSystemMetaData::FileType | QFileSystemMetaData::DirectoryType | QFileSystemMetaData::BundleType; | 0 |
517 | | QFileSystemMetaData::LinkType never executed: queryFlags |= QFileSystemMetaData::AliasType | QFileSystemMetaData::LinkType | QFileSystemMetaData::FileType | QFileSystemMetaData::DirectoryType | QFileSystemMetaData::BundleType; | 0 |
518 | | QFileSystemMetaData::FileType never executed: queryFlags |= QFileSystemMetaData::AliasType | QFileSystemMetaData::LinkType | QFileSystemMetaData::FileType | QFileSystemMetaData::DirectoryType | QFileSystemMetaData::BundleType; | 0 |
519 | | QFileSystemMetaData::DirectoryType never executed: queryFlags |= QFileSystemMetaData::AliasType | QFileSystemMetaData::LinkType | QFileSystemMetaData::FileType | QFileSystemMetaData::DirectoryType | QFileSystemMetaData::BundleType; | 0 |
520 | | QFileSystemMetaData::BundleType; never executed: queryFlags |= QFileSystemMetaData::AliasType | QFileSystemMetaData::LinkType | QFileSystemMetaData::FileType | QFileSystemMetaData::DirectoryType | QFileSystemMetaData::BundleType; | 0 |
521 | | - |
522 | if (type & FlagsMask) evaluated: type & FlagsMask yes Evaluation Count:4901 | yes Evaluation Count:218 |
| 218-4901 |
523 | queryFlags |= QFileSystemMetaData::HiddenAttribute executed: queryFlags |= QFileSystemMetaData::HiddenAttribute | QFileSystemMetaData::ExistsAttribute; Execution Count:4901 | 4901 |
524 | | QFileSystemMetaData::ExistsAttribute; executed: queryFlags |= QFileSystemMetaData::HiddenAttribute | QFileSystemMetaData::ExistsAttribute; Execution Count:4901 | 4901 |
525 | | - |
526 | queryFlags |= QFileSystemMetaData::LinkType; executed (the execution status of this line is deduced): queryFlags |= QFileSystemMetaData::LinkType; | - |
527 | | - |
528 | exists = d->doStat(queryFlags); executed (the execution status of this line is deduced): exists = d->doStat(queryFlags); | - |
529 | } | - |
530 | | - |
531 | if (!exists && !d->metaData.isLink()) evaluated: !exists yes Evaluation Count:3146 | yes Evaluation Count:1973 |
partially evaluated: !d->metaData.isLink() yes Evaluation Count:3146 | no Evaluation Count:0 |
| 0-3146 |
532 | return ret; executed: return ret; Execution Count:3146 | 3146 |
533 | | - |
534 | if (exists && (type & PermsMask)) partially evaluated: exists yes Evaluation Count:1973 | no Evaluation Count:0 |
evaluated: (type & PermsMask) yes Evaluation Count:218 | yes Evaluation Count:1755 |
| 0-1973 |
535 | ret |= FileFlags(uint(d->metaData.permissions())); executed: ret |= FileFlags(uint(d->metaData.permissions())); Execution Count:218 | 218 |
536 | | - |
537 | if (type & TypesMask) { partially evaluated: type & TypesMask no Evaluation Count:0 | yes Evaluation Count:1973 |
| 0-1973 |
538 | if (d->metaData.isAlias()) { never evaluated: d->metaData.isAlias() | 0 |
539 | ret |= LinkType; never executed (the execution status of this line is deduced): ret |= LinkType; | - |
540 | } else { | 0 |
541 | if ((type & LinkType) && d->metaData.isLink()) never evaluated: (type & LinkType) never evaluated: d->metaData.isLink() | 0 |
542 | ret |= LinkType; never executed: ret |= LinkType; | 0 |
543 | if (exists) { | 0 |
544 | if (d->metaData.isFile()) { never evaluated: d->metaData.isFile() | 0 |
545 | ret |= FileType; never executed (the execution status of this line is deduced): ret |= FileType; | - |
546 | } else if (d->metaData.isDirectory()) { never executed: } never evaluated: d->metaData.isDirectory() | 0 |
547 | ret |= DirectoryType; never executed (the execution status of this line is deduced): ret |= DirectoryType; | - |
548 | if ((type & BundleType) && d->metaData.isBundle()) never evaluated: (type & BundleType) never evaluated: d->metaData.isBundle() | 0 |
549 | ret |= BundleType; never executed: ret |= BundleType; | 0 |
550 | } | 0 |
551 | } | - |
552 | } | 0 |
553 | } | - |
554 | | - |
555 | if (type & FlagsMask) { evaluated: type & FlagsMask yes Evaluation Count:1755 | yes Evaluation Count:218 |
| 218-1755 |
556 | if (exists) partially evaluated: exists yes Evaluation Count:1755 | no Evaluation Count:0 |
| 0-1755 |
557 | ret |= ExistsFlag; executed: ret |= ExistsFlag; Execution Count:1755 | 1755 |
558 | if (d->fileEntry.isRoot()) partially evaluated: d->fileEntry.isRoot() no Evaluation Count:0 | yes Evaluation Count:1755 |
| 0-1755 |
559 | ret |= RootFlag; never executed: ret |= RootFlag; | 0 |
560 | else if (d->metaData.isHidden()) evaluated: d->metaData.isHidden() yes Evaluation Count:12 | yes Evaluation Count:1743 |
| 12-1743 |
561 | ret |= HiddenFlag; executed: ret |= HiddenFlag; Execution Count:12 | 12 |
562 | } | - |
563 | | - |
564 | return ret; executed: return ret; Execution Count:1973 | 1973 |
565 | } | - |
566 | | - |
567 | QString QFSFileEngine::fileName(FileName file) const | - |
568 | { | - |
569 | Q_D(const QFSFileEngine); executed (the execution status of this line is deduced): const QFSFileEnginePrivate * const d = d_func(); | - |
570 | if (file == BundleName) { partially evaluated: file == BundleName no Evaluation Count:0 | yes Evaluation Count:6037 |
| 0-6037 |
571 | return QFileSystemEngine::bundleName(d->fileEntry); never executed: return QFileSystemEngine::bundleName(d->fileEntry); | 0 |
572 | } else if (file == BaseName) { partially evaluated: file == BaseName no Evaluation Count:0 | yes Evaluation Count:6037 |
| 0-6037 |
573 | return d->fileEntry.fileName(); never executed: return d->fileEntry.fileName(); | 0 |
574 | } else if (file == PathName) { partially evaluated: file == PathName no Evaluation Count:0 | yes Evaluation Count:6037 |
| 0-6037 |
575 | return d->fileEntry.path(); never executed: return d->fileEntry.path(); | 0 |
576 | } else if (file == AbsoluteName || file == AbsolutePathName) { partially evaluated: file == AbsoluteName no Evaluation Count:0 | yes Evaluation Count:6037 |
partially evaluated: file == AbsolutePathName no Evaluation Count:0 | yes Evaluation Count:6037 |
| 0-6037 |
577 | QFileSystemEntry entry(QFileSystemEngine::absoluteName(d->fileEntry)); never executed (the execution status of this line is deduced): QFileSystemEntry entry(QFileSystemEngine::absoluteName(d->fileEntry)); | - |
578 | if (file == AbsolutePathName) { never evaluated: file == AbsolutePathName | 0 |
579 | return entry.path(); never executed: return entry.path(); | 0 |
580 | } | - |
581 | return entry.filePath(); never executed: return entry.filePath(); | 0 |
582 | } else if (file == CanonicalName || file == CanonicalPathName) { partially evaluated: file == CanonicalName no Evaluation Count:0 | yes Evaluation Count:6037 |
partially evaluated: file == CanonicalPathName no Evaluation Count:0 | yes Evaluation Count:6037 |
| 0-6037 |
583 | QFileSystemEntry entry(QFileSystemEngine::canonicalName(d->fileEntry, d->metaData)); never executed (the execution status of this line is deduced): QFileSystemEntry entry(QFileSystemEngine::canonicalName(d->fileEntry, d->metaData)); | - |
584 | if (file == CanonicalPathName) never evaluated: file == CanonicalPathName | 0 |
585 | return entry.path(); never executed: return entry.path(); | 0 |
586 | return entry.filePath(); never executed: return entry.filePath(); | 0 |
587 | } else if (file == LinkName) { evaluated: file == LinkName yes Evaluation Count:2 | yes Evaluation Count:6035 |
| 2-6035 |
588 | if (d->isSymlink()) { partially evaluated: d->isSymlink() yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
589 | QFileSystemEntry entry = QFileSystemEngine::getLinkTarget(d->fileEntry, d->metaData); executed (the execution status of this line is deduced): QFileSystemEntry entry = QFileSystemEngine::getLinkTarget(d->fileEntry, d->metaData); | - |
590 | return entry.filePath(); executed: return entry.filePath(); Execution Count:2 | 2 |
591 | } | - |
592 | return QString(); never executed: return QString(); | 0 |
593 | } | - |
594 | return d->fileEntry.filePath(); executed: return d->fileEntry.filePath(); Execution Count:6035 | 6035 |
595 | } | - |
596 | | - |
597 | bool QFSFileEngine::isRelativePath() const | - |
598 | { | - |
599 | Q_D(const QFSFileEngine); never executed (the execution status of this line is deduced): const QFSFileEnginePrivate * const d = d_func(); | - |
600 | 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 |
601 | } | - |
602 | | - |
603 | uint QFSFileEngine::ownerId(FileOwner own) const | - |
604 | { | - |
605 | Q_D(const QFSFileEngine); never executed (the execution status of this line is deduced): const QFSFileEnginePrivate * const d = d_func(); | - |
606 | static const uint nobodyID = (uint) -2; | - |
607 | | - |
608 | if (d->doStat(QFileSystemMetaData::OwnerIds)) never evaluated: d->doStat(QFileSystemMetaData::OwnerIds) | 0 |
609 | return d->metaData.ownerId(own); never executed: return d->metaData.ownerId(own); | 0 |
610 | | - |
611 | return nobodyID; never executed: return nobodyID; | 0 |
612 | } | - |
613 | | - |
614 | QString QFSFileEngine::owner(FileOwner own) const | - |
615 | { | - |
616 | if (own == OwnerUser) never evaluated: own == OwnerUser | 0 |
617 | return QFileSystemEngine::resolveUserName(ownerId(own)); never executed: return QFileSystemEngine::resolveUserName(ownerId(own)); | 0 |
618 | return QFileSystemEngine::resolveGroupName(ownerId(own)); never executed: return QFileSystemEngine::resolveGroupName(ownerId(own)); | 0 |
619 | } | - |
620 | | - |
621 | bool QFSFileEngine::setPermissions(uint perms) | - |
622 | { | - |
623 | Q_D(QFSFileEngine); executed (the execution status of this line is deduced): QFSFileEnginePrivate * const d = d_func(); | - |
624 | QSystemError error; executed (the execution status of this line is deduced): QSystemError error; | - |
625 | if (!QFileSystemEngine::setPermissions(d->fileEntry, QFile::Permissions(perms), error, 0)) { evaluated: !QFileSystemEngine::setPermissions(d->fileEntry, QFile::Permissions(perms), error, 0) yes Evaluation Count:5 | yes Evaluation Count:510 |
| 5-510 |
626 | setError(QFile::PermissionsError, error.toString()); executed (the execution status of this line is deduced): setError(QFile::PermissionsError, error.toString()); | - |
627 | return false; executed: return false; Execution Count:5 | 5 |
628 | } | - |
629 | return true; executed: return true; Execution Count:510 | 510 |
630 | } | - |
631 | | - |
632 | bool QFSFileEngine::setSize(qint64 size) | - |
633 | { | - |
634 | Q_D(QFSFileEngine); executed (the execution status of this line is deduced): QFSFileEnginePrivate * const d = d_func(); | - |
635 | bool ret = false; executed (the execution status of this line is deduced): bool ret = false; | - |
636 | if (d->fd != -1) evaluated: d->fd != -1 yes Evaluation Count:767 | yes Evaluation Count:6 |
| 6-767 |
637 | ret = QT_FTRUNCATE(d->fd, size) == 0; executed: ret = ::ftruncate64(d->fd, size) == 0; Execution Count:767 | 767 |
638 | else if (d->fh) evaluated: d->fh yes Evaluation Count:1 | yes Evaluation Count:5 |
| 1-5 |
639 | ret = QT_FTRUNCATE(QT_FILENO(d->fh), size) == 0; executed: ret = ::ftruncate64(fileno(d->fh), size) == 0; Execution Count:1 | 1 |
640 | else | - |
641 | ret = QT_TRUNCATE(d->fileEntry.nativeFilePath().constData(), size) == 0; executed: ret = ::truncate64(d->fileEntry.nativeFilePath().constData(), size) == 0; Execution Count:5 | 5 |
642 | if (!ret) partially evaluated: !ret no Evaluation Count:0 | yes Evaluation Count:773 |
| 0-773 |
643 | setError(QFile::ResizeError, qt_error_string(errno)); never executed: setError(QFile::ResizeError, qt_error_string((*__errno_location ()))); | 0 |
644 | return ret; executed: return ret; Execution Count:773 | 773 |
645 | } | - |
646 | | - |
647 | QDateTime QFSFileEngine::fileTime(FileTime time) const | - |
648 | { | - |
649 | Q_D(const QFSFileEngine); never executed (the execution status of this line is deduced): const QFSFileEnginePrivate * const d = d_func(); | - |
650 | | - |
651 | if (d->doStat(QFileSystemMetaData::Times)) never evaluated: d->doStat(QFileSystemMetaData::Times) | 0 |
652 | return d->metaData.fileTime(time); never executed: return d->metaData.fileTime(time); | 0 |
653 | | - |
654 | return QDateTime(); never executed: return QDateTime(); | 0 |
655 | } | - |
656 | | - |
657 | uchar *QFSFileEnginePrivate::map(qint64 offset, qint64 size, QFile::MemoryMapFlags flags) | - |
658 | { | - |
659 | Q_Q(QFSFileEngine); executed (the execution status of this line is deduced): QFSFileEngine * const q = q_func(); | - |
660 | Q_UNUSED(flags); executed (the execution status of this line is deduced): (void)flags;; | - |
661 | if (openMode == QIODevice::NotOpen) { evaluated: openMode == QIODevice::NotOpen yes Evaluation Count:8 | yes Evaluation Count:33326 |
| 8-33326 |
662 | q->setError(QFile::PermissionsError, qt_error_string(int(EACCES))); executed (the execution status of this line is deduced): q->setError(QFile::PermissionsError, qt_error_string(int(13))); | - |
663 | return 0; executed: return 0; Execution Count:8 | 8 |
664 | } | - |
665 | | - |
666 | if (offset < 0 || offset != qint64(QT_OFF_T(offset)) evaluated: offset < 0 yes Evaluation Count:1 | yes Evaluation Count:33325 |
partially evaluated: offset != qint64(off64_t(offset)) no Evaluation Count:0 | yes Evaluation Count:33325 |
| 0-33325 |
667 | || size < 0 || quint64(size) > quint64(size_t(-1))) { evaluated: size < 0 yes Evaluation Count:1 | yes Evaluation Count:33324 |
partially evaluated: quint64(size) > quint64(size_t(-1)) no Evaluation Count:0 | yes Evaluation Count:33324 |
| 0-33324 |
668 | q->setError(QFile::UnspecifiedError, qt_error_string(int(EINVAL))); executed (the execution status of this line is deduced): q->setError(QFile::UnspecifiedError, qt_error_string(int(22))); | - |
669 | return 0; executed: return 0; Execution Count:2 | 2 |
670 | } | - |
671 | | - |
672 | // If we know the mapping will extend beyond EOF, fail early to avoid | - |
673 | // undefined behavior. Otherwise, let mmap have its say. | - |
674 | if (doStat(QFileSystemMetaData::SizeAttribute) partially evaluated: doStat(QFileSystemMetaData::SizeAttribute) yes Evaluation Count:33324 | no Evaluation Count:0 |
| 0-33324 |
675 | && (QT_OFF_T(size) > metaData.size() - QT_OFF_T(offset))) evaluated: (off64_t(size) > metaData.size() - off64_t(offset)) yes Evaluation Count:1 | yes Evaluation Count:33323 |
| 1-33323 |
676 | qWarning("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 |
677 | | - |
678 | int access = 0; executed (the execution status of this line is deduced): int access = 0; | - |
679 | if (openMode & QIODevice::ReadOnly) access |= PROT_READ; executed: access |= 0x1; Execution Count:33324 partially evaluated: openMode & QIODevice::ReadOnly yes Evaluation Count:33324 | no Evaluation Count:0 |
| 0-33324 |
680 | if (openMode & QIODevice::WriteOnly) access |= PROT_WRITE; executed: access |= 0x2; Execution Count:33 evaluated: openMode & QIODevice::WriteOnly yes Evaluation Count:33 | yes Evaluation Count:33291 |
| 33-33291 |
681 | | - |
682 | #if defined(Q_OS_INTEGRITY) | - |
683 | int pageSize = sysconf(_SC_PAGESIZE); | - |
684 | #else | - |
685 | int pageSize = getpagesize(); executed (the execution status of this line is deduced): int pageSize = getpagesize(); | - |
686 | #endif | - |
687 | int extra = offset % pageSize; executed (the execution status of this line is deduced): int extra = offset % pageSize; | - |
688 | | - |
689 | if (quint64(size + extra) > quint64((size_t)-1)) { partially evaluated: quint64(size + extra) > quint64((size_t)-1) no Evaluation Count:0 | yes Evaluation Count:33324 |
| 0-33324 |
690 | q->setError(QFile::UnspecifiedError, qt_error_string(int(EINVAL))); never executed (the execution status of this line is deduced): q->setError(QFile::UnspecifiedError, qt_error_string(int(22))); | - |
691 | return 0; never executed: return 0; | 0 |
692 | } | - |
693 | | - |
694 | size_t realSize = (size_t)size + extra; executed (the execution status of this line is deduced): size_t realSize = (size_t)size + extra; | - |
695 | QT_OFF_T realOffset = QT_OFF_T(offset); executed (the execution status of this line is deduced): off64_t realOffset = off64_t(offset); | - |
696 | realOffset &= ~(QT_OFF_T(pageSize - 1)); executed (the execution status of this line is deduced): realOffset &= ~(off64_t(pageSize - 1)); | - |
697 | | - |
698 | void *mapAddress = QT_MMAP((void*)0, realSize, executed (the execution status of this line is deduced): void *mapAddress = ::mmap64((void*)0, realSize, | - |
699 | access, MAP_SHARED, nativeHandle(), realOffset); executed (the execution status of this line is deduced): access, 0x01, nativeHandle(), realOffset); | - |
700 | if (MAP_FAILED != mapAddress) { evaluated: ((void *) -1) != mapAddress yes Evaluation Count:33318 | yes Evaluation Count:6 |
| 6-33318 |
701 | uchar *address = extra + static_cast<uchar*>(mapAddress); executed (the execution status of this line is deduced): uchar *address = extra + static_cast<uchar*>(mapAddress); | - |
702 | maps[address] = QPair<int,size_t>(extra, realSize); executed (the execution status of this line is deduced): maps[address] = QPair<int,size_t>(extra, realSize); | - |
703 | return address; executed: return address; Execution Count:33318 | 33318 |
704 | } | - |
705 | | - |
706 | switch(errno) { | - |
707 | case EBADF: | - |
708 | q->setError(QFile::PermissionsError, qt_error_string(int(EACCES))); executed (the execution status of this line is deduced): q->setError(QFile::PermissionsError, qt_error_string(int(13))); | - |
709 | break; executed: break; Execution Count:5 | 5 |
710 | case ENFILE: | - |
711 | case ENOMEM: | - |
712 | q->setError(QFile::ResourceError, qt_error_string(int(errno))); never executed (the execution status of this line is deduced): q->setError(QFile::ResourceError, qt_error_string(int((*__errno_location ())))); | - |
713 | break; | 0 |
714 | case EINVAL: | - |
715 | // size are out of bounds | - |
716 | default: | - |
717 | q->setError(QFile::UnspecifiedError, qt_error_string(int(errno))); executed (the execution status of this line is deduced): q->setError(QFile::UnspecifiedError, qt_error_string(int((*__errno_location ())))); | - |
718 | break; executed: break; Execution Count:1 | 1 |
719 | } | - |
720 | return 0; executed: return 0; Execution Count:6 | 6 |
721 | } | - |
722 | | - |
723 | bool QFSFileEnginePrivate::unmap(uchar *ptr) | - |
724 | { | - |
725 | #if !defined(Q_OS_INTEGRITY) | - |
726 | Q_Q(QFSFileEngine); executed (the execution status of this line is deduced): QFSFileEngine * const q = q_func(); | - |
727 | if (!maps.contains(ptr)) { evaluated: !maps.contains(ptr) yes Evaluation Count:8 | yes Evaluation Count:33318 |
| 8-33318 |
728 | q->setError(QFile::PermissionsError, qt_error_string(EACCES)); executed (the execution status of this line is deduced): q->setError(QFile::PermissionsError, qt_error_string(13)); | - |
729 | return false; executed: return false; Execution Count:8 | 8 |
730 | } | - |
731 | | - |
732 | uchar *start = ptr - maps[ptr].first; executed (the execution status of this line is deduced): uchar *start = ptr - maps[ptr].first; | - |
733 | size_t len = maps[ptr].second; executed (the execution status of this line is deduced): size_t len = maps[ptr].second; | - |
734 | if (-1 == munmap(start, len)) { partially evaluated: -1 == munmap(start, len) no Evaluation Count:0 | yes Evaluation Count:33318 |
| 0-33318 |
735 | q->setError(QFile::UnspecifiedError, qt_error_string(errno)); never executed (the execution status of this line is deduced): q->setError(QFile::UnspecifiedError, qt_error_string((*__errno_location ()))); | - |
736 | return false; never executed: return false; | 0 |
737 | } | - |
738 | maps.remove(ptr); executed (the execution status of this line is deduced): maps.remove(ptr); | - |
739 | return true; executed: return true; Execution Count:33318 | 33318 |
740 | #else | - |
741 | return false; | - |
742 | #endif | - |
743 | } | - |
744 | | - |
745 | QT_END_NAMESPACE | - |
746 | | - |
747 | #endif // QT_NO_FSFILEENGINE | - |
748 | | - |
| | |