io/qfilesystementry.cpp

Switch to Source codePreprocessed file
LineSource CodeCoverage
1 -
2 -
3 -
4 -
5 -
6 -
7QFileSystemEntry::QFileSystemEntry() -
8 : m_lastSeparator(-1), -
9 m_firstDotInFileName(-1), -
10 m_lastDotInFileName(-1) -
11{ -
12}
executed: }
Execution Count:117399
117399
13 -
14 -
15 -
16 -
17 -
18 -
19QFileSystemEntry::QFileSystemEntry(const QString &filePath) -
20 : m_filePath(QDir::fromNativeSeparators(filePath)), -
21 m_lastSeparator(-2), -
22 m_firstDotInFileName(-2), -
23 m_lastDotInFileName(0) -
24{ -
25}
executed: }
Execution Count:94521
94521
26 -
27 -
28 -
29 -
30 -
31 -
32QFileSystemEntry::QFileSystemEntry(const QString &filePath, FromInternalPath ) -
33 : m_filePath(filePath), -
34 m_lastSeparator(-2), -
35 m_firstDotInFileName(-2), -
36 m_lastDotInFileName(0) -
37{ -
38}
executed: }
Execution Count:11197
11197
39 -
40 -
41 -
42 -
43 -
44QFileSystemEntry::QFileSystemEntry(const NativePath &nativeFilePath, FromNativePath ) -
45 : m_nativeFilePath(nativeFilePath), -
46 m_lastSeparator(-2), -
47 m_firstDotInFileName(-2), -
48 m_lastDotInFileName(0) -
49{ -
50}
executed: }
Execution Count:44307
44307
51 -
52QFileSystemEntry::QFileSystemEntry(const QString &filePath, const NativePath &nativeFilePath) -
53 : m_filePath(QDir::fromNativeSeparators(filePath)), -
54 m_nativeFilePath(nativeFilePath), -
55 m_lastSeparator(-2), -
56 m_firstDotInFileName(-2), -
57 m_lastDotInFileName(0) -
58{ -
59}
never executed: }
0
60 -
61QString QFileSystemEntry::filePath() const -
62{ -
63 resolveFilePath(); -
64 return m_filePath;
executed: return m_filePath;
Execution Count:228785
228785
65} -
66 -
67QFileSystemEntry::NativePath QFileSystemEntry::nativeFilePath() const -
68{ -
69 resolveNativeFilePath(); -
70 return m_nativeFilePath;
executed: return m_nativeFilePath;
Execution Count:82740
82740
71} -
72 -
73void QFileSystemEntry::resolveFilePath() const -
74{ -
75 if (m_filePath.isEmpty() && !m_nativeFilePath.isEmpty()) {
evaluated: m_filePath.isEmpty()
TRUEFALSE
yes
Evaluation Count:84953
yes
Evaluation Count:286329
evaluated: !m_nativeFilePath.isEmpty()
TRUEFALSE
yes
Evaluation Count:84341
yes
Evaluation Count:612
612-286329
76 m_filePath = QDir::fromNativeSeparators(QFile::decodeName(m_nativeFilePath)); -
77 -
78 }
executed: }
Execution Count:84341
84341
79}
executed: }
Execution Count:371261
371261
80 -
81void QFileSystemEntry::resolveNativeFilePath() const -
82{ -
83 if (!m_filePath.isEmpty() && m_nativeFilePath.isEmpty()) {
evaluated: !m_filePath.isEmpty()
TRUEFALSE
yes
Evaluation Count:82106
yes
Evaluation Count:635
evaluated: m_nativeFilePath.isEmpty()
TRUEFALSE
yes
Evaluation Count:45468
yes
Evaluation Count:36640
635-82106
84 m_nativeFilePath = QFile::encodeName(QDir::toNativeSeparators(m_filePath)); -
85 -
86 }
executed: }
Execution Count:45468
45468
87}
executed: }
Execution Count:82741
82741
88 -
89QString QFileSystemEntry::fileName() const -
90{ -
91 findLastSeparator(); -
92 -
93 -
94 -
95 -
96 return m_filePath.mid(m_lastSeparator + 1);
executed: return m_filePath.mid(m_lastSeparator + 1);
Execution Count:108331
108331
97} -
98 -
99QString QFileSystemEntry::path() const -
100{ -
101 findLastSeparator(); -
102 if (m_lastSeparator == -1) {
evaluated: m_lastSeparator == -1
TRUEFALSE
yes
Evaluation Count:206
yes
Evaluation Count:9249
206-9249
103 -
104 -
105 -
106 -
107 return QString(QLatin1Char('.'));
executed: return QString(QLatin1Char('.'));
Execution Count:206
206
108 } -
109 if (m_lastSeparator == 0)
evaluated: m_lastSeparator == 0
TRUEFALSE
yes
Evaluation Count:902
yes
Evaluation Count:8347
902-8347
110 return QString(QLatin1Char('/'));
executed: return QString(QLatin1Char('/'));
Execution Count:902
902
111 -
112 -
113 -
114 -
115 return m_filePath.left(m_lastSeparator);
executed: return m_filePath.left(m_lastSeparator);
Execution Count:8347
8347
116} -
117 -
118QString QFileSystemEntry::baseName() const -
119{ -
120 findFileNameSeparators(); -
121 int length = -1; -
122 if (m_firstDotInFileName >= 0) {
evaluated: m_firstDotInFileName >= 0
TRUEFALSE
yes
Evaluation Count:1737
yes
Evaluation Count:233
233-1737
123 length = m_firstDotInFileName; -
124 if (m_lastSeparator != -1)
evaluated: m_lastSeparator != -1
TRUEFALSE
yes
Evaluation Count:1578
yes
Evaluation Count:159
159-1578
125 length--;
executed: length--;
Execution Count:1578
1578
126 }
executed: }
Execution Count:1737
1737
127 -
128 -
129 -
130 -
131 return m_filePath.mid(m_lastSeparator + 1, length);
executed: return m_filePath.mid(m_lastSeparator + 1, length);
Execution Count:1970
1970
132} -
133 -
134QString QFileSystemEntry::completeBaseName() const -
135{ -
136 findFileNameSeparators(); -
137 int length = -1; -
138 if (m_firstDotInFileName >= 0) {
evaluated: m_firstDotInFileName >= 0
TRUEFALSE
yes
Evaluation Count:20
yes
Evaluation Count:11
11-20
139 length = m_firstDotInFileName + m_lastDotInFileName; -
140 if (m_lastSeparator != -1)
evaluated: m_lastSeparator != -1
TRUEFALSE
yes
Evaluation Count:16
yes
Evaluation Count:4
4-16
141 length--;
executed: length--;
Execution Count:16
16
142 }
executed: }
Execution Count:20
20
143 -
144 -
145 -
146 -
147 return m_filePath.mid(m_lastSeparator + 1, length);
executed: return m_filePath.mid(m_lastSeparator + 1, length);
Execution Count:31
31
148} -
149 -
150QString QFileSystemEntry::suffix() const -
151{ -
152 findFileNameSeparators(); -
153 -
154 if (m_lastDotInFileName == -1)
evaluated: m_lastDotInFileName == -1
TRUEFALSE
yes
Evaluation Count:2353
yes
Evaluation Count:4831
2353-4831
155 return QString();
executed: return QString();
Execution Count:2353
2353
156 -
157 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
158} -
159 -
160QString QFileSystemEntry::completeSuffix() const -
161{ -
162 findFileNameSeparators(); -
163 if (m_firstDotInFileName == -1)
evaluated: m_firstDotInFileName == -1
TRUEFALSE
yes
Evaluation Count:18
yes
Evaluation Count:1511
18-1511
164 return QString();
executed: return QString();
Execution Count:18
18
165 -
166 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
167} -
168bool QFileSystemEntry::isRelative() const -
169{ -
170 return !isAbsolute();
executed: return !isAbsolute();
Execution Count:13472
13472
171} -
172 -
173bool QFileSystemEntry::isAbsolute() const -
174{ -
175 resolveFilePath(); -
176 return (!m_filePath.isEmpty() && (m_filePath[0].unicode() == '/'));
executed: return (!m_filePath.isEmpty() && (m_filePath[0].unicode() == '/'));
Execution Count:22543
22543
177} -
178bool QFileSystemEntry::isRoot() const -
179{ -
180 resolveFilePath(); -
181 if (m_filePath == QLatin1String("/")
evaluated: m_filePath == QLatin1String("/")
TRUEFALSE
yes
Evaluation Count:134
yes
Evaluation Count:14583
134-14583
182 -
183 -
184 -
185 -
186 ) -
187 return true;
executed: return true;
Execution Count:134
134
188 -
189 return false;
executed: return false;
Execution Count:14583
14583
190} -
191 -
192bool QFileSystemEntry::isEmpty() const -
193{ -
194 return m_filePath.isEmpty() && m_nativeFilePath.isEmpty();
executed: return m_filePath.isEmpty() && m_nativeFilePath.isEmpty();
Execution Count:38717
38717
195} -
196 -
197 -
198 -
199void QFileSystemEntry::findLastSeparator() const -
200{ -
201 if (m_lastSeparator == -2) {
evaluated: m_lastSeparator == -2
TRUEFALSE
yes
Evaluation Count:83221
yes
Evaluation Count:34566
34566-83221
202 resolveFilePath(); -
203 m_lastSeparator = -1; -
204 for (int i = m_filePath.size() - 1; i >= 0; --i) {
evaluated: i >= 0
TRUEFALSE
yes
Evaluation Count:956927
yes
Evaluation Count:352
352-956927
205 if (m_filePath[i].unicode() == '/') {
evaluated: m_filePath[i].unicode() == '/'
TRUEFALSE
yes
Evaluation Count:82866
yes
Evaluation Count:874060
82866-874060
206 m_lastSeparator = i; -
207 break;
executed: break;
Execution Count:82866
82866
208 } -
209 }
executed: }
Execution Count:874061
874061
210 }
executed: }
Execution Count:83218
83218
211}
executed: }
Execution Count:117783
117783
212 -
213void QFileSystemEntry::findFileNameSeparators() const -
214{ -
215 if (m_firstDotInFileName == -2) {
evaluated: m_firstDotInFileName == -2
TRUEFALSE
yes
Evaluation Count:8554
yes
Evaluation Count:2160
2160-8554
216 resolveFilePath(); -
217 int firstDotInFileName = -1; -
218 int lastDotInFileName = -1; -
219 int lastSeparator = m_lastSeparator; -
220 -
221 int stop; -
222 if (lastSeparator < 0) {
evaluated: lastSeparator < 0
TRUEFALSE
yes
Evaluation Count:6239
yes
Evaluation Count:2315
2315-6239
223 lastSeparator = -1; -
224 stop = 0; -
225 } else {
executed: }
Execution Count:6239
6239
226 stop = lastSeparator; -
227 }
executed: }
Execution Count:2315
2315
228 -
229 int i = m_filePath.size() - 1; -
230 for (; i >= stop; --i) {
evaluated: i >= stop
TRUEFALSE
yes
Evaluation Count:36531
yes
Evaluation Count:308
308-36531
231 if (m_filePath[i].unicode() == '.') {
evaluated: m_filePath[i].unicode() == '.'
TRUEFALSE
yes
Evaluation Count:7152
yes
Evaluation Count:29379
7152-29379
232 firstDotInFileName = lastDotInFileName = i; -
233 break;
executed: break;
Execution Count:7152
7152
234 } else if (m_filePath[i].unicode() == '/') {
evaluated: m_filePath[i].unicode() == '/'
TRUEFALSE
yes
Evaluation Count:1094
yes
Evaluation Count:28285
1094-28285
235 lastSeparator = i; -
236 break;
executed: break;
Execution Count:1094
1094
237 } -
238 } -
239 -
240 if (lastSeparator != i) {
evaluated: lastSeparator != i
TRUEFALSE
yes
Evaluation Count:7152
yes
Evaluation Count:1402
1402-7152
241 for (--i; i >= stop; --i) {
evaluated: i >= stop
TRUEFALSE
yes
Evaluation Count:78919
yes
Evaluation Count:255
255-78919
242 if (m_filePath[i].unicode() == '.')
evaluated: m_filePath[i].unicode() == '.'
TRUEFALSE
yes
Evaluation Count:429
yes
Evaluation Count:78490
429-78490
243 firstDotInFileName = i;
executed: firstDotInFileName = i;
Execution Count:429
429
244 else if (m_filePath[i].unicode() == '/') {
evaluated: m_filePath[i].unicode() == '/'
TRUEFALSE
yes
Evaluation Count:6897
yes
Evaluation Count:71593
6897-71593
245 lastSeparator = i; -
246 break;
executed: break;
Execution Count:6897
6897
247 } -
248 } -
249 }
executed: }
Execution Count:7152
7152
250 m_lastSeparator = lastSeparator; -
251 m_firstDotInFileName = firstDotInFileName == -1 ? -1 : firstDotInFileName - qMax(0, lastSeparator);
evaluated: firstDotInFileName == -1
TRUEFALSE
yes
Evaluation Count:1402
yes
Evaluation Count:7152
1402-7152
252 if (lastDotInFileName == -1)
evaluated: lastDotInFileName == -1
TRUEFALSE
yes
Evaluation Count:1402
yes
Evaluation Count:7152
1402-7152
253 m_lastDotInFileName = -1;
executed: m_lastDotInFileName = -1;
Execution Count:1402
1402
254 else if (firstDotInFileName == lastDotInFileName)
evaluated: firstDotInFileName == lastDotInFileName
TRUEFALSE
yes
Evaluation Count:6855
yes
Evaluation Count:297
297-6855
255 m_lastDotInFileName = 0;
executed: m_lastDotInFileName = 0;
Execution Count:6855
6855
256 else -
257 m_lastDotInFileName = lastDotInFileName - firstDotInFileName;
executed: m_lastDotInFileName = lastDotInFileName - firstDotInFileName;
Execution Count:297
297
258 } -
259}
executed: }
Execution Count:10714
10714
260 -
261bool QFileSystemEntry::isClean() const -
262{ -
263 resolveFilePath(); -
264 int dots = 0; -
265 bool dotok = true; -
266 bool slashok = true; -
267 for (QString::const_iterator iter = m_filePath.constBegin(); iter != m_filePath.constEnd(); iter++) {
evaluated: iter != m_filePath.constEnd()
TRUEFALSE
yes
Evaluation Count:553027
yes
Evaluation Count:13289
13289-553027
268 if (*iter == QLatin1Char('/')) {
evaluated: *iter == QLatin1Char('/')
TRUEFALSE
yes
Evaluation Count:64501
yes
Evaluation Count:488534
64501-488534
269 if (dots == 1 || dots == 2)
evaluated: dots == 1
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:64499
evaluated: dots == 2
TRUEFALSE
yes
Evaluation Count:153
yes
Evaluation Count:64346
2-64499
270 return false;
executed: return false;
Execution Count:155
155
271 if (!slashok)
evaluated: !slashok
TRUEFALSE
yes
Evaluation Count:17
yes
Evaluation Count:64329
17-64329
272 return false;
executed: return false;
Execution Count:17
17
273 dots = 0; -
274 dotok = true; -
275 slashok = false; -
276 } else if (dotok) {
executed: }
Execution Count:64329
evaluated: dotok
TRUEFALSE
yes
Evaluation Count:65088
yes
Evaluation Count:423452
64329-423452
277 slashok = true; -
278 if (*iter == QLatin1Char('.')) {
evaluated: *iter == QLatin1Char('.')
TRUEFALSE
yes
Evaluation Count:1451
yes
Evaluation Count:63637
1451-63637
279 dots++; -
280 if (dots > 2)
evaluated: dots > 2
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1450
1-1450
281 dotok = false;
executed: dotok = false;
Execution Count:1
1
282 } else {
executed: }
Execution Count:1451
1451
283 -
284 dots = 0; -
285 dotok = false; -
286 }
executed: }
Execution Count:63637
63637
287 } -
288 } -
289 return (dots != 1 && dots != 2);
executed: return (dots != 1 && dots != 2);
Execution Count:13289
13289
290} -
291 -
292 -
293 -
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial