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 "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:171176 | 171176 |
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:97523 | 97523 |
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:11799 | 11799 |
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:90742 | 90742 |
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:336226 | 336226 |
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:136123 | 136123 |
141 | } | - |
142 | | - |
143 | void QFileSystemEntry::resolveFilePath() const | - |
144 | { | - |
145 | if (m_filePath.isEmpty() && !m_nativeFilePath.isEmpty()) { evaluated: m_filePath.isEmpty() yes Evaluation Count:177645 | yes Evaluation Count:468964 |
evaluated: !m_nativeFilePath.isEmpty() yes Evaluation Count:176989 | yes Evaluation Count:655 |
| 655-468964 |
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:176974 | 176974 |
158 | } executed: } Execution Count:646437 | 646437 |
159 | | - |
160 | void QFileSystemEntry::resolveNativeFilePath() const | - |
161 | { | - |
162 | if (!m_filePath.isEmpty() && m_nativeFilePath.isEmpty()) { evaluated: !m_filePath.isEmpty() yes Evaluation Count:135420 | yes Evaluation Count:701 |
evaluated: m_nativeFilePath.isEmpty() yes Evaluation Count:47036 | yes Evaluation Count:88385 |
| 701-135420 |
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:47037 | 47037 |
174 | } executed: } Execution Count:136123 | 136123 |
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:265141 | 265141 |
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:10333 |
| 206-10333 |
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:944 | yes Evaluation Count:9389 |
| 944-9389 |
197 | return QString(QLatin1Char('/')); executed: return QString(QLatin1Char('/')); Execution Count:944 | 944 |
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:9389 | 9389 |
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:1754 | yes Evaluation Count:233 |
| 233-1754 |
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:1595 | yes Evaluation Count:159 |
| 159-1595 |
212 | length--; executed: length--; Execution Count:1595 | 1595 |
213 | } executed: } Execution Count:1754 | 1754 |
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:1987 | 1987 |
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:13021 | yes Evaluation Count:29859 |
| 13021-29859 |
242 | return QString(); executed: return QString(); Execution Count:13021 | 13021 |
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:29859 | 29859 |
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:1742 |
| 18-1742 |
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:1742 | 1742 |
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:14093 | 14093 |
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:24154 | 24154 |
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:152 | yes Evaluation Count:62674 |
| 152-62674 |
299 | #if defined(Q_OS_WIN) | - |
300 | || isDriveRoot() | - |
301 | || isUncRoot(m_filePath) | - |
302 | #endif | - |
303 | ) | - |
304 | return true; executed: return true; Execution Count:152 | 152 |
305 | | - |
306 | return false; executed: return false; Execution Count:62674 | 62674 |
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:40834 | 40834 |
312 | } | - |
313 | | - |
314 | // private methods | - |
315 | | - |
316 | void QFileSystemEntry::findLastSeparator() const | - |
317 | { | - |
318 | if (m_lastSeparator == -2) { evaluated: m_lastSeparator == -2 yes Evaluation Count:176558 | yes Evaluation Count:99242 |
| 99242-176558 |
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:2706043 | yes Evaluation Count:336 |
| 336-2706043 |
322 | if (m_filePath[i].unicode() == '/') { evaluated: m_filePath[i].unicode() == '/' yes Evaluation Count:176109 | yes Evaluation Count:2530127 |
| 176109-2530127 |
323 | m_lastSeparator = i; executed (the execution status of this line is deduced): m_lastSeparator = i; | - |
324 | break; executed: break; Execution Count:176112 | 176112 |
325 | } | - |
326 | } executed: } Execution Count:2530169 | 2530169 |
327 | } executed: } Execution Count:176454 | 176454 |
328 | } executed: } Execution Count:275666 | 275666 |
329 | | - |
330 | void QFileSystemEntry::findFileNameSeparators() const | - |
331 | { | - |
332 | if (m_firstDotInFileName == -2) { evaluated: m_firstDotInFileName == -2 yes Evaluation Count:32110 | yes Evaluation Count:14548 |
| 14548-32110 |
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:6718 | yes Evaluation Count:25392 |
| 6718-25392 |
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:6718 | 6718 |
343 | stop = lastSeparator; executed (the execution status of this line is deduced): stop = lastSeparator; | - |
344 | } executed: } Execution Count:25392 | 25392 |
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:195269 | yes Evaluation Count:314 |
| 314-195269 |
348 | if (m_filePath[i].unicode() == '.') { evaluated: m_filePath[i].unicode() == '.' yes Evaluation Count:20025 | yes Evaluation Count:175244 |
| 20025-175244 |
349 | firstDotInFileName = lastDotInFileName = i; executed (the execution status of this line is deduced): firstDotInFileName = lastDotInFileName = i; | - |
350 | break; executed: break; Execution Count:20025 | 20025 |
351 | } else if (m_filePath[i].unicode() == '/') { evaluated: m_filePath[i].unicode() == '/' yes Evaluation Count:11771 | yes Evaluation Count:163473 |
| 11771-163473 |
352 | lastSeparator = i; executed (the execution status of this line is deduced): lastSeparator = i; | - |
353 | break; executed: break; Execution Count:11771 | 11771 |
354 | } | - |
355 | } | - |
356 | | - |
357 | if (lastSeparator != i) { evaluated: lastSeparator != i yes Evaluation Count:20025 | yes Evaluation Count:12085 |
| 12085-20025 |
358 | for (--i; i >= stop; --i) { evaluated: i >= stop yes Evaluation Count:371720 | yes Evaluation Count:260 |
| 260-371720 |
359 | if (m_filePath[i].unicode() == '.') evaluated: m_filePath[i].unicode() == '.' yes Evaluation Count:7789 | yes Evaluation Count:363931 |
| 7789-363931 |
360 | firstDotInFileName = i; executed: firstDotInFileName = i; Execution Count:7789 | 7789 |
361 | else if (m_filePath[i].unicode() == '/') { evaluated: m_filePath[i].unicode() == '/' yes Evaluation Count:19765 | yes Evaluation Count:344166 |
| 19765-344166 |
362 | lastSeparator = i; executed (the execution status of this line is deduced): lastSeparator = i; | - |
363 | break; executed: break; Execution Count:19765 | 19765 |
364 | } | - |
365 | } | - |
366 | } executed: } Execution Count:20025 | 20025 |
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:12085 | yes Evaluation Count:20025 |
| 12085-20025 |
369 | if (lastDotInFileName == -1) evaluated: lastDotInFileName == -1 yes Evaluation Count:12085 | yes Evaluation Count:20025 |
| 12085-20025 |
370 | m_lastDotInFileName = -1; executed: m_lastDotInFileName = -1; Execution Count:12085 | 12085 |
371 | else if (firstDotInFileName == lastDotInFileName) evaluated: firstDotInFileName == lastDotInFileName yes Evaluation Count:16047 | yes Evaluation Count:3978 |
| 3978-16047 |
372 | m_lastDotInFileName = 0; executed: m_lastDotInFileName = 0; Execution Count:16047 | 16047 |
373 | else | - |
374 | m_lastDotInFileName = lastDotInFileName - firstDotInFileName; executed: m_lastDotInFileName = lastDotInFileName - firstDotInFileName; Execution Count:3978 | 3978 |
375 | } | - |
376 | } executed: } Execution Count:46658 | 46658 |
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:604929 | yes Evaluation Count:14600 |
| 14600-604929 |
385 | if (*iter == QLatin1Char('/')) { evaluated: *iter == QLatin1Char('/') yes Evaluation Count:70859 | yes Evaluation Count:534072 |
| 70859-534072 |
386 | if (dots == 1 || dots == 2) evaluated: dots == 1 yes Evaluation Count:2 | yes Evaluation Count:70857 |
evaluated: dots == 2 yes Evaluation Count:153 | yes Evaluation Count:70704 |
| 2-70857 |
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:70687 |
| 17-70687 |
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:70687 evaluated: dotok yes Evaluation Count:71588 | yes Evaluation Count:462484 |
| 70687-462484 |
394 | slashok = true; executed (the execution status of this line is deduced): slashok = true; | - |
395 | if (*iter == QLatin1Char('.')) { evaluated: *iter == QLatin1Char('.') yes Evaluation Count:1654 | yes Evaluation Count:69934 |
| 1654-69934 |
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:1653 |
| 1-1653 |
398 | dotok = false; executed: dotok = false; Execution Count:1 | 1 |
399 | } else { executed: } Execution Count:1654 | 1654 |
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:69934 | 69934 |
404 | } | - |
405 | } | - |
406 | return (dots != 1 && dots != 2); // clean if path doesn't end in . or .. executed: return (dots != 1 && dots != 2); Execution Count:14600 | 14600 |
407 | } | - |
408 | | - |
409 | QT_END_NAMESPACE | - |
410 | | - |
| | |