Line | Source Code | Coverage |
---|
1 | /**************************************************************************** | - |
2 | ** | - |
3 | ** Copyright (C) 2012 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 "qfilesystementry_p.h" | - |
43 | | - |
44 | #include <QtCore/qdir.h> | - |
45 | #include <QtCore/qfile.h> | - |
46 | #include <QtCore/private/qfsfileengine_p.h> | - |
47 | #ifdef Q_OS_WIN | - |
48 | #include <QtCore/qstringbuilder.h> | - |
49 | #endif | - |
50 | | - |
51 | QT_BEGIN_NAMESPACE | - |
52 | | - |
53 | #ifdef Q_OS_WIN | - |
54 | static bool isUncRoot(const QString &server) | - |
55 | { | - |
56 | QString localPath = QDir::toNativeSeparators(server); | - |
57 | if (!localPath.startsWith(QLatin1String("\\\\"))) | - |
58 | return false; | - |
59 | | - |
60 | int idx = localPath.indexOf(QLatin1Char('\\'), 2); | - |
61 | if (idx == -1 || idx + 1 == localPath.length()) | - |
62 | return true; | - |
63 | | - |
64 | localPath = localPath.right(localPath.length() - idx - 1).trimmed(); | - |
65 | return localPath.isEmpty(); | - |
66 | } | - |
67 | | - |
68 | static inline QString fixIfRelativeUncPath(const QString &path) | - |
69 | { | - |
70 | QString currentPath = QDir::currentPath(); | - |
71 | if (currentPath.startsWith(QLatin1String("//"))) | - |
72 | return currentPath % QChar(QLatin1Char('/')) % path; | - |
73 | return path; | - |
74 | } | - |
75 | #endif | - |
76 | | - |
77 | QFileSystemEntry::QFileSystemEntry() | - |
78 | : m_lastSeparator(-1), | - |
79 | m_firstDotInFileName(-1), | - |
80 | m_lastDotInFileName(-1) | - |
81 | { | - |
82 | } executed: } Execution Count:117399 | 117399 |
83 | | - |
84 | /*! | - |
85 | \internal | - |
86 | Use this constructor when the path is supplied by user code, as it may contain a mix | - |
87 | of '/' and the native separator. | - |
88 | */ | - |
89 | QFileSystemEntry::QFileSystemEntry(const QString &filePath) | - |
90 | : m_filePath(QDir::fromNativeSeparators(filePath)), | - |
91 | m_lastSeparator(-2), | - |
92 | m_firstDotInFileName(-2), | - |
93 | m_lastDotInFileName(0) | - |
94 | { | - |
95 | } executed: } Execution Count:94521 | 94521 |
96 | | - |
97 | /*! | - |
98 | \internal | - |
99 | Use this constructor when the path is guaranteed to be in internal format, i.e. all | - |
100 | directory separators are '/' and not the native separator. | - |
101 | */ | - |
102 | QFileSystemEntry::QFileSystemEntry(const QString &filePath, FromInternalPath /* dummy */) | - |
103 | : m_filePath(filePath), | - |
104 | m_lastSeparator(-2), | - |
105 | m_firstDotInFileName(-2), | - |
106 | m_lastDotInFileName(0) | - |
107 | { | - |
108 | } executed: } Execution Count:11197 | 11197 |
109 | | - |
110 | /*! | - |
111 | \internal | - |
112 | Use this constructor when the path comes from a native API | - |
113 | */ | - |
114 | QFileSystemEntry::QFileSystemEntry(const NativePath &nativeFilePath, FromNativePath /* dummy */) | - |
115 | : m_nativeFilePath(nativeFilePath), | - |
116 | m_lastSeparator(-2), | - |
117 | m_firstDotInFileName(-2), | - |
118 | m_lastDotInFileName(0) | - |
119 | { | - |
120 | } executed: } Execution Count:44307 | 44307 |
121 | | - |
122 | QFileSystemEntry::QFileSystemEntry(const QString &filePath, const NativePath &nativeFilePath) | - |
123 | : m_filePath(QDir::fromNativeSeparators(filePath)), | - |
124 | m_nativeFilePath(nativeFilePath), | - |
125 | m_lastSeparator(-2), | - |
126 | m_firstDotInFileName(-2), | - |
127 | m_lastDotInFileName(0) | - |
128 | { | - |
129 | } | 0 |
130 | | - |
131 | QString QFileSystemEntry::filePath() const | - |
132 | { | - |
133 | resolveFilePath(); executed (the execution status of this line is deduced): resolveFilePath(); | - |
134 | return m_filePath; executed: return m_filePath; Execution Count:228785 | 228785 |
135 | } | - |
136 | | - |
137 | QFileSystemEntry::NativePath QFileSystemEntry::nativeFilePath() const | - |
138 | { | - |
139 | resolveNativeFilePath(); executed (the execution status of this line is deduced): resolveNativeFilePath(); | - |
140 | return m_nativeFilePath; executed: return m_nativeFilePath; Execution Count:82740 | 82740 |
141 | } | - |
142 | | - |
143 | void QFileSystemEntry::resolveFilePath() const | - |
144 | { | - |
145 | if (m_filePath.isEmpty() && !m_nativeFilePath.isEmpty()) { evaluated: m_filePath.isEmpty() yes Evaluation Count:84953 | yes Evaluation Count:286329 |
evaluated: !m_nativeFilePath.isEmpty() yes Evaluation Count:84341 | yes Evaluation Count:612 |
| 612-286329 |
146 | #if defined(QFILESYSTEMENTRY_NATIVE_PATH_IS_UTF16) | - |
147 | m_filePath = QDir::fromNativeSeparators(m_nativeFilePath); | - |
148 | #ifdef Q_OS_WIN | - |
149 | if (m_filePath.startsWith(QLatin1String("//?/UNC/"))) | - |
150 | m_filePath = m_filePath.remove(2,6); | - |
151 | if (m_filePath.startsWith(QLatin1String("//?/"))) | - |
152 | m_filePath = m_filePath.remove(0,4); | - |
153 | #endif | - |
154 | #else | - |
155 | m_filePath = QDir::fromNativeSeparators(QFile::decodeName(m_nativeFilePath)); executed (the execution status of this line is deduced): m_filePath = QDir::fromNativeSeparators(QFile::decodeName(m_nativeFilePath)); | - |
156 | #endif | - |
157 | } executed: } Execution Count:84341 | 84341 |
158 | } executed: } Execution Count:371261 | 371261 |
159 | | - |
160 | void QFileSystemEntry::resolveNativeFilePath() const | - |
161 | { | - |
162 | if (!m_filePath.isEmpty() && m_nativeFilePath.isEmpty()) { evaluated: !m_filePath.isEmpty() yes Evaluation Count:82106 | yes Evaluation Count:635 |
evaluated: m_nativeFilePath.isEmpty() yes Evaluation Count:45468 | yes Evaluation Count:36640 |
| 635-82106 |
163 | #ifdef Q_OS_WIN | - |
164 | QString filePath = m_filePath; | - |
165 | if (isRelative()) | - |
166 | filePath = fixIfRelativeUncPath(m_filePath); | - |
167 | m_nativeFilePath = QFSFileEnginePrivate::longFileName(QDir::toNativeSeparators(filePath)); | - |
168 | #elif defined(QFILESYSTEMENTRY_NATIVE_PATH_IS_UTF16) | - |
169 | m_nativeFilePath = QDir::toNativeSeparators(m_filePath); | - |
170 | #else | - |
171 | m_nativeFilePath = QFile::encodeName(QDir::toNativeSeparators(m_filePath)); executed (the execution status of this line is deduced): m_nativeFilePath = QFile::encodeName(QDir::toNativeSeparators(m_filePath)); | - |
172 | #endif | - |
173 | } executed: } Execution Count:45468 | 45468 |
174 | } executed: } Execution Count:82741 | 82741 |
175 | | - |
176 | QString QFileSystemEntry::fileName() const | - |
177 | { | - |
178 | findLastSeparator(); executed (the execution status of this line is deduced): findLastSeparator(); | - |
179 | #if defined(Q_OS_WIN) | - |
180 | if (m_lastSeparator == -1 && m_filePath.length() >= 2 && m_filePath.at(1) == QLatin1Char(':')) | - |
181 | return m_filePath.mid(2); | - |
182 | #endif | - |
183 | return m_filePath.mid(m_lastSeparator + 1); executed: return m_filePath.mid(m_lastSeparator + 1); Execution Count:108331 | 108331 |
184 | } | - |
185 | | - |
186 | QString QFileSystemEntry::path() const | - |
187 | { | - |
188 | findLastSeparator(); executed (the execution status of this line is deduced): findLastSeparator(); | - |
189 | if (m_lastSeparator == -1) { evaluated: m_lastSeparator == -1 yes Evaluation Count:206 | yes Evaluation Count:9249 |
| 206-9249 |
190 | #if defined(Q_OS_WIN) | - |
191 | if (m_filePath.length() >= 2 && m_filePath.at(1) == QLatin1Char(':')) | - |
192 | return QFSFileEngine::currentPath(m_filePath.left(2)); | - |
193 | #endif | - |
194 | return QString(QLatin1Char('.')); executed: return QString(QLatin1Char('.')); Execution Count:206 | 206 |
195 | } | - |
196 | if (m_lastSeparator == 0) evaluated: m_lastSeparator == 0 yes Evaluation Count:902 | yes Evaluation Count:8347 |
| 902-8347 |
197 | return QString(QLatin1Char('/')); executed: return QString(QLatin1Char('/')); Execution Count:902 | 902 |
198 | #if defined(Q_OS_WIN) | - |
199 | if (m_lastSeparator == 2 && m_filePath.at(1) == QLatin1Char(':')) | - |
200 | return m_filePath.left(m_lastSeparator + 1); | - |
201 | #endif | - |
202 | return m_filePath.left(m_lastSeparator); executed: return m_filePath.left(m_lastSeparator); Execution Count:8347 | 8347 |
203 | } | - |
204 | | - |
205 | QString QFileSystemEntry::baseName() const | - |
206 | { | - |
207 | findFileNameSeparators(); executed (the execution status of this line is deduced): findFileNameSeparators(); | - |
208 | int length = -1; executed (the execution status of this line is deduced): int length = -1; | - |
209 | if (m_firstDotInFileName >= 0) { evaluated: m_firstDotInFileName >= 0 yes Evaluation Count:1737 | yes Evaluation Count:233 |
| 233-1737 |
210 | length = m_firstDotInFileName; executed (the execution status of this line is deduced): length = m_firstDotInFileName; | - |
211 | if (m_lastSeparator != -1) // avoid off by one evaluated: m_lastSeparator != -1 yes Evaluation Count:1578 | yes Evaluation Count:159 |
| 159-1578 |
212 | length--; executed: length--; Execution Count:1578 | 1578 |
213 | } executed: } Execution Count:1737 | 1737 |
214 | #if defined(Q_OS_WIN) | - |
215 | if (m_lastSeparator == -1 && m_filePath.length() >= 2 && m_filePath.at(1) == QLatin1Char(':')) | - |
216 | return m_filePath.mid(2, length - 2); | - |
217 | #endif | - |
218 | return m_filePath.mid(m_lastSeparator + 1, length); executed: return m_filePath.mid(m_lastSeparator + 1, length); Execution Count:1970 | 1970 |
219 | } | - |
220 | | - |
221 | QString QFileSystemEntry::completeBaseName() const | - |
222 | { | - |
223 | findFileNameSeparators(); executed (the execution status of this line is deduced): findFileNameSeparators(); | - |
224 | int length = -1; executed (the execution status of this line is deduced): int length = -1; | - |
225 | if (m_firstDotInFileName >= 0) { evaluated: m_firstDotInFileName >= 0 yes Evaluation Count:20 | yes Evaluation Count:11 |
| 11-20 |
226 | length = m_firstDotInFileName + m_lastDotInFileName; executed (the execution status of this line is deduced): length = m_firstDotInFileName + m_lastDotInFileName; | - |
227 | if (m_lastSeparator != -1) // avoid off by one evaluated: m_lastSeparator != -1 yes Evaluation Count:16 | yes Evaluation Count:4 |
| 4-16 |
228 | length--; executed: length--; Execution Count:16 | 16 |
229 | } executed: } Execution Count:20 | 20 |
230 | #if defined(Q_OS_WIN) | - |
231 | if (m_lastSeparator == -1 && m_filePath.length() >= 2 && m_filePath.at(1) == QLatin1Char(':')) | - |
232 | return m_filePath.mid(2, length - 2); | - |
233 | #endif | - |
234 | return m_filePath.mid(m_lastSeparator + 1, length); executed: return m_filePath.mid(m_lastSeparator + 1, length); Execution Count:31 | 31 |
235 | } | - |
236 | | - |
237 | QString QFileSystemEntry::suffix() const | - |
238 | { | - |
239 | findFileNameSeparators(); executed (the execution status of this line is deduced): findFileNameSeparators(); | - |
240 | | - |
241 | if (m_lastDotInFileName == -1) evaluated: m_lastDotInFileName == -1 yes Evaluation Count:2353 | yes Evaluation Count:4831 |
| 2353-4831 |
242 | return QString(); executed: return QString(); Execution Count:2353 | 2353 |
243 | | - |
244 | return m_filePath.mid(qMax((qint16)0, m_lastSeparator) + m_firstDotInFileName + m_lastDotInFileName + 1); executed: return m_filePath.mid(qMax((qint16)0, m_lastSeparator) + m_firstDotInFileName + m_lastDotInFileName + 1); Execution Count:4831 | 4831 |
245 | } | - |
246 | | - |
247 | QString QFileSystemEntry::completeSuffix() const | - |
248 | { | - |
249 | findFileNameSeparators(); executed (the execution status of this line is deduced): findFileNameSeparators(); | - |
250 | if (m_firstDotInFileName == -1) evaluated: m_firstDotInFileName == -1 yes Evaluation Count:18 | yes Evaluation Count:1511 |
| 18-1511 |
251 | return QString(); executed: return QString(); Execution Count:18 | 18 |
252 | | - |
253 | return m_filePath.mid(qMax((qint16)0, m_lastSeparator) + m_firstDotInFileName + 1); executed: return m_filePath.mid(qMax((qint16)0, m_lastSeparator) + m_firstDotInFileName + 1); Execution Count:1511 | 1511 |
254 | } | - |
255 | | - |
256 | #if defined(Q_OS_WIN) | - |
257 | bool QFileSystemEntry::isRelative() const | - |
258 | { | - |
259 | resolveFilePath(); | - |
260 | return (m_filePath.isEmpty() || (!m_filePath.isEmpty() && (m_filePath[0].unicode() != '/') | - |
261 | && (!(m_filePath.length() >= 2 && m_filePath[1].unicode() == ':')))); | - |
262 | } | - |
263 | | - |
264 | bool QFileSystemEntry::isAbsolute() const | - |
265 | { | - |
266 | resolveFilePath(); | - |
267 | return (!m_filePath.isEmpty() && ((m_filePath.length() >= 3 | - |
268 | && (m_filePath[0].isLetter() && m_filePath[1].unicode() == ':' && m_filePath[2].unicode() == '/')) | - |
269 | || (m_filePath.length() >= 2 && (m_filePath.at(0) == QLatin1Char('/') && m_filePath.at(1) == QLatin1Char('/'))) | - |
270 | )); | - |
271 | } | - |
272 | #else | - |
273 | bool QFileSystemEntry::isRelative() const | - |
274 | { | - |
275 | return !isAbsolute(); executed: return !isAbsolute(); Execution Count:13472 | 13472 |
276 | } | - |
277 | | - |
278 | bool QFileSystemEntry::isAbsolute() const | - |
279 | { | - |
280 | resolveFilePath(); executed (the execution status of this line is deduced): resolveFilePath(); | - |
281 | return (!m_filePath.isEmpty() && (m_filePath[0].unicode() == '/')); executed: return (!m_filePath.isEmpty() && (m_filePath[0].unicode() == '/')); Execution Count:22543 | 22543 |
282 | } | - |
283 | #endif | - |
284 | | - |
285 | #if defined(Q_OS_WIN) | - |
286 | bool QFileSystemEntry::isDriveRoot() const | - |
287 | { | - |
288 | resolveFilePath(); | - |
289 | return (m_filePath.length() == 3 | - |
290 | && m_filePath.at(0).isLetter() && m_filePath.at(1) == QLatin1Char(':') | - |
291 | && m_filePath.at(2) == QLatin1Char('/')); | - |
292 | } | - |
293 | #endif | - |
294 | | - |
295 | bool QFileSystemEntry::isRoot() const | - |
296 | { | - |
297 | resolveFilePath(); executed (the execution status of this line is deduced): resolveFilePath(); | - |
298 | if (m_filePath == QLatin1String("/") evaluated: m_filePath == QLatin1String("/") yes Evaluation Count:134 | yes Evaluation Count:14583 |
| 134-14583 |
299 | #if defined(Q_OS_WIN) | - |
300 | || isDriveRoot() | - |
301 | || isUncRoot(m_filePath) | - |
302 | #endif | - |
303 | ) | - |
304 | return true; executed: return true; Execution Count:134 | 134 |
305 | | - |
306 | return false; executed: return false; Execution Count:14583 | 14583 |
307 | } | - |
308 | | - |
309 | bool QFileSystemEntry::isEmpty() const | - |
310 | { | - |
311 | return m_filePath.isEmpty() && m_nativeFilePath.isEmpty(); executed: return m_filePath.isEmpty() && m_nativeFilePath.isEmpty(); Execution Count:38717 | 38717 |
312 | } | - |
313 | | - |
314 | // private methods | - |
315 | | - |
316 | void QFileSystemEntry::findLastSeparator() const | - |
317 | { | - |
318 | if (m_lastSeparator == -2) { evaluated: m_lastSeparator == -2 yes Evaluation Count:83221 | yes Evaluation Count:34566 |
| 34566-83221 |
319 | resolveFilePath(); executed (the execution status of this line is deduced): resolveFilePath(); | - |
320 | m_lastSeparator = -1; executed (the execution status of this line is deduced): m_lastSeparator = -1; | - |
321 | for (int i = m_filePath.size() - 1; i >= 0; --i) { evaluated: i >= 0 yes Evaluation Count:956927 | yes Evaluation Count:352 |
| 352-956927 |
322 | if (m_filePath[i].unicode() == '/') { evaluated: m_filePath[i].unicode() == '/' yes Evaluation Count:82866 | yes Evaluation Count:874060 |
| 82866-874060 |
323 | m_lastSeparator = i; executed (the execution status of this line is deduced): m_lastSeparator = i; | - |
324 | break; executed: break; Execution Count:82866 | 82866 |
325 | } | - |
326 | } executed: } Execution Count:874061 | 874061 |
327 | } executed: } Execution Count:83218 | 83218 |
328 | } executed: } Execution Count:117783 | 117783 |
329 | | - |
330 | void QFileSystemEntry::findFileNameSeparators() const | - |
331 | { | - |
332 | if (m_firstDotInFileName == -2) { evaluated: m_firstDotInFileName == -2 yes Evaluation Count:8554 | yes Evaluation Count:2160 |
| 2160-8554 |
333 | resolveFilePath(); executed (the execution status of this line is deduced): resolveFilePath(); | - |
334 | int firstDotInFileName = -1; executed (the execution status of this line is deduced): int firstDotInFileName = -1; | - |
335 | int lastDotInFileName = -1; executed (the execution status of this line is deduced): int lastDotInFileName = -1; | - |
336 | int lastSeparator = m_lastSeparator; executed (the execution status of this line is deduced): int lastSeparator = m_lastSeparator; | - |
337 | | - |
338 | int stop; executed (the execution status of this line is deduced): int stop; | - |
339 | if (lastSeparator < 0) { evaluated: lastSeparator < 0 yes Evaluation Count:6239 | yes Evaluation Count:2315 |
| 2315-6239 |
340 | lastSeparator = -1; executed (the execution status of this line is deduced): lastSeparator = -1; | - |
341 | stop = 0; executed (the execution status of this line is deduced): stop = 0; | - |
342 | } else { executed: } Execution Count:6239 | 6239 |
343 | stop = lastSeparator; executed (the execution status of this line is deduced): stop = lastSeparator; | - |
344 | } executed: } Execution Count:2315 | 2315 |
345 | | - |
346 | int i = m_filePath.size() - 1; executed (the execution status of this line is deduced): int i = m_filePath.size() - 1; | - |
347 | for (; i >= stop; --i) { evaluated: i >= stop yes Evaluation Count:36531 | yes Evaluation Count:308 |
| 308-36531 |
348 | if (m_filePath[i].unicode() == '.') { evaluated: m_filePath[i].unicode() == '.' yes Evaluation Count:7152 | yes Evaluation Count:29379 |
| 7152-29379 |
349 | firstDotInFileName = lastDotInFileName = i; executed (the execution status of this line is deduced): firstDotInFileName = lastDotInFileName = i; | - |
350 | break; executed: break; Execution Count:7152 | 7152 |
351 | } else if (m_filePath[i].unicode() == '/') { evaluated: m_filePath[i].unicode() == '/' yes Evaluation Count:1094 | yes Evaluation Count:28285 |
| 1094-28285 |
352 | lastSeparator = i; executed (the execution status of this line is deduced): lastSeparator = i; | - |
353 | break; executed: break; Execution Count:1094 | 1094 |
354 | } | - |
355 | } | - |
356 | | - |
357 | if (lastSeparator != i) { evaluated: lastSeparator != i yes Evaluation Count:7152 | yes Evaluation Count:1402 |
| 1402-7152 |
358 | for (--i; i >= stop; --i) { evaluated: i >= stop yes Evaluation Count:78919 | yes Evaluation Count:255 |
| 255-78919 |
359 | if (m_filePath[i].unicode() == '.') evaluated: m_filePath[i].unicode() == '.' yes Evaluation Count:429 | yes Evaluation Count:78490 |
| 429-78490 |
360 | firstDotInFileName = i; executed: firstDotInFileName = i; Execution Count:429 | 429 |
361 | else if (m_filePath[i].unicode() == '/') { evaluated: m_filePath[i].unicode() == '/' yes Evaluation Count:6897 | yes Evaluation Count:71593 |
| 6897-71593 |
362 | lastSeparator = i; executed (the execution status of this line is deduced): lastSeparator = i; | - |
363 | break; executed: break; Execution Count:6897 | 6897 |
364 | } | - |
365 | } | - |
366 | } executed: } Execution Count:7152 | 7152 |
367 | m_lastSeparator = lastSeparator; executed (the execution status of this line is deduced): m_lastSeparator = lastSeparator; | - |
368 | m_firstDotInFileName = firstDotInFileName == -1 ? -1 : firstDotInFileName - qMax(0, lastSeparator); evaluated: firstDotInFileName == -1 yes Evaluation Count:1402 | yes Evaluation Count:7152 |
| 1402-7152 |
369 | if (lastDotInFileName == -1) evaluated: lastDotInFileName == -1 yes Evaluation Count:1402 | yes Evaluation Count:7152 |
| 1402-7152 |
370 | m_lastDotInFileName = -1; executed: m_lastDotInFileName = -1; Execution Count:1402 | 1402 |
371 | else if (firstDotInFileName == lastDotInFileName) evaluated: firstDotInFileName == lastDotInFileName yes Evaluation Count:6855 | yes Evaluation Count:297 |
| 297-6855 |
372 | m_lastDotInFileName = 0; executed: m_lastDotInFileName = 0; Execution Count:6855 | 6855 |
373 | else | - |
374 | m_lastDotInFileName = lastDotInFileName - firstDotInFileName; executed: m_lastDotInFileName = lastDotInFileName - firstDotInFileName; Execution Count:297 | 297 |
375 | } | - |
376 | } executed: } Execution Count:10714 | 10714 |
377 | | - |
378 | bool QFileSystemEntry::isClean() const | - |
379 | { | - |
380 | resolveFilePath(); executed (the execution status of this line is deduced): resolveFilePath(); | - |
381 | int dots = 0; executed (the execution status of this line is deduced): int dots = 0; | - |
382 | bool dotok = true; // checking for ".." or "." starts to relative paths executed (the execution status of this line is deduced): bool dotok = true; | - |
383 | bool slashok = true; executed (the execution status of this line is deduced): bool slashok = true; | - |
384 | for (QString::const_iterator iter = m_filePath.constBegin(); iter != m_filePath.constEnd(); iter++) { evaluated: iter != m_filePath.constEnd() yes Evaluation Count:553027 | yes Evaluation Count:13289 |
| 13289-553027 |
385 | if (*iter == QLatin1Char('/')) { evaluated: *iter == QLatin1Char('/') yes Evaluation Count:64501 | yes Evaluation Count:488534 |
| 64501-488534 |
386 | if (dots == 1 || dots == 2) evaluated: dots == 1 yes Evaluation Count:2 | yes Evaluation Count:64499 |
evaluated: dots == 2 yes Evaluation Count:153 | yes Evaluation Count:64346 |
| 2-64499 |
387 | return false; // path contains "./" or "../" executed: return false; Execution Count:155 | 155 |
388 | if (!slashok) evaluated: !slashok yes Evaluation Count:17 | yes Evaluation Count:64329 |
| 17-64329 |
389 | return false; // path contains "//" executed: return false; Execution Count:17 | 17 |
390 | dots = 0; executed (the execution status of this line is deduced): dots = 0; | - |
391 | dotok = true; executed (the execution status of this line is deduced): dotok = true; | - |
392 | slashok = false; executed (the execution status of this line is deduced): slashok = false; | - |
393 | } else if (dotok) { executed: } Execution Count:64329 evaluated: dotok yes Evaluation Count:65088 | yes Evaluation Count:423452 |
| 64329-423452 |
394 | slashok = true; executed (the execution status of this line is deduced): slashok = true; | - |
395 | if (*iter == QLatin1Char('.')) { evaluated: *iter == QLatin1Char('.') yes Evaluation Count:1451 | yes Evaluation Count:63637 |
| 1451-63637 |
396 | dots++; executed (the execution status of this line is deduced): dots++; | - |
397 | if (dots > 2) evaluated: dots > 2 yes Evaluation Count:1 | yes Evaluation Count:1450 |
| 1-1450 |
398 | dotok = false; executed: dotok = false; Execution Count:1 | 1 |
399 | } else { executed: } Execution Count:1451 | 1451 |
400 | //path element contains a character other than '.', it's clean | - |
401 | dots = 0; executed (the execution status of this line is deduced): dots = 0; | - |
402 | dotok = false; executed (the execution status of this line is deduced): dotok = false; | - |
403 | } executed: } Execution Count:63637 | 63637 |
404 | } | - |
405 | } | - |
406 | return (dots != 1 && dots != 2); // clean if path doesn't end in . or .. executed: return (dots != 1 && dots != 2); Execution Count:13289 | 13289 |
407 | } | - |
408 | | - |
409 | QT_END_NAMESPACE | - |
410 | | - |
| | |