Line | Source Code | Coverage |
---|
1 | | - |
2 | | - |
3 | | - |
4 | | - |
5 | | - |
6 | | - |
7 | | - |
8 | | - |
9 | | - |
10 | | - |
11 | | - |
12 | QString QFileSystemEngine::slowCanonicalized(const QString &path) | - |
13 | { | - |
14 | if (path.isEmpty()) never evaluated: path.isEmpty() | 0 |
15 | return path; never executed: return path; | 0 |
16 | | - |
17 | QFileInfo fi; | - |
18 | const QChar slash(QLatin1Char('/')); | - |
19 | QString tmpPath = path; | - |
20 | int separatorPos = 0; | - |
21 | QSet<QString> nonSymlinks; | - |
22 | QSet<QString> known; | - |
23 | | - |
24 | known.insert(path); | - |
25 | do { | - |
26 | separatorPos = tmpPath.indexOf(slash, separatorPos + 1); | - |
27 | QString prefix = separatorPos == -1 ? tmpPath : tmpPath.left(separatorPos); never evaluated: separatorPos == -1 | 0 |
28 | if (!nonSymlinks.contains(prefix)) { never evaluated: !nonSymlinks.contains(prefix) | 0 |
29 | fi.setFile(prefix); | - |
30 | if (fi.isSymLink()) { never evaluated: fi.isSymLink() | 0 |
31 | QString target = fi.symLinkTarget(); | - |
32 | if(QFileInfo(target).isRelative()) never evaluated: QFileInfo(target).isRelative() | 0 |
33 | target = fi.absolutePath() + slash + target; never executed: target = fi.absolutePath() + slash + target; | 0 |
34 | if (separatorPos != -1) { never evaluated: separatorPos != -1 | 0 |
35 | if (fi.isDir() && !target.endsWith(slash)) never evaluated: fi.isDir() never evaluated: !target.endsWith(slash) | 0 |
36 | target.append(slash); never executed: target.append(slash); | 0 |
37 | target.append(tmpPath.mid(separatorPos)); | - |
38 | } | 0 |
39 | tmpPath = QDir::cleanPath(target); | - |
40 | separatorPos = 0; | - |
41 | | - |
42 | if (known.contains(tmpPath)) never evaluated: known.contains(tmpPath) | 0 |
43 | return QString(); never executed: return QString(); | 0 |
44 | known.insert(tmpPath); | - |
45 | } else { | 0 |
46 | nonSymlinks.insert(prefix); | - |
47 | } | 0 |
48 | } | - |
49 | } while (separatorPos != -1); never evaluated: separatorPos != -1 | 0 |
50 | | - |
51 | return QDir::cleanPath(tmpPath); never executed: return QDir::cleanPath(tmpPath); | 0 |
52 | } | - |
53 | | - |
54 | static inline bool _q_checkEntry(QFileSystemEntry &entry, QFileSystemMetaData &data, bool resolvingEntry) | - |
55 | { | - |
56 | if (resolvingEntry) { evaluated: resolvingEntry yes Evaluation Count:46 | yes Evaluation Count:106362 |
| 46-106362 |
57 | if (!QFileSystemEngine::fillMetaData(entry, data, QFileSystemMetaData::ExistsAttribute) partially evaluated: !QFileSystemEngine::fillMetaData(entry, data, QFileSystemMetaData::ExistsAttribute) no Evaluation Count:0 | yes Evaluation Count:46 |
| 0-46 |
58 | || !data.exists()) { partially evaluated: !data.exists() no Evaluation Count:0 | yes Evaluation Count:46 |
| 0-46 |
59 | data.clear(); | - |
60 | return false; never executed: return false; | 0 |
61 | } | - |
62 | } executed: } Execution Count:46 | 46 |
63 | | - |
64 | return true; executed: return true; Execution Count:106407 | 106407 |
65 | } | - |
66 | | - |
67 | static inline bool _q_checkEntry(QAbstractFileEngine *&engine, bool resolvingEntry) | - |
68 | { | - |
69 | if (resolvingEntry) { evaluated: resolvingEntry yes Evaluation Count:1 | yes Evaluation Count:7755 |
| 1-7755 |
70 | if (!(engine->fileFlags(QAbstractFileEngine::FlagsMask) & QAbstractFileEngine::ExistsFlag)) { partially evaluated: !(engine->fileFlags(QAbstractFileEngine::FlagsMask) & QAbstractFileEngine::ExistsFlag) no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
71 | delete engine; | - |
72 | engine = 0; | - |
73 | return false; never executed: return false; | 0 |
74 | } | - |
75 | } executed: } Execution Count:1 | 1 |
76 | | - |
77 | return true; executed: return true; Execution Count:7756 | 7756 |
78 | } | - |
79 | | - |
80 | static bool _q_resolveEntryAndCreateLegacyEngine_recursive(QFileSystemEntry &entry, QFileSystemMetaData &data, | - |
81 | QAbstractFileEngine *&engine, bool resolvingEntry = false) | - |
82 | { | - |
83 | QString const &filePath = entry.filePath(); | - |
84 | if ((engine = qt_custom_file_engine_handler_create(filePath))) partially evaluated: (engine = qt_custom_file_engine_handler_create(filePath)) no Evaluation Count:0 | yes Evaluation Count:114234 |
| 0-114234 |
85 | return _q_checkEntry(engine, resolvingEntry); never executed: return _q_checkEntry(engine, resolvingEntry); | 0 |
86 | | - |
87 | | - |
88 | for (int prefixSeparator = 0; prefixSeparator < filePath.size(); ++prefixSeparator) { evaluated: prefixSeparator < filePath.size() yes Evaluation Count:399851 | yes Evaluation Count:8449 |
| 8449-399851 |
89 | QChar const ch = filePath[prefixSeparator]; | - |
90 | if (ch == QLatin1Char('/')) evaluated: ch == QLatin1Char('/') yes Evaluation Count:97956 | yes Evaluation Count:301895 |
| 97956-301895 |
91 | break; executed: break; Execution Count:97956 | 97956 |
92 | | - |
93 | if (ch == QLatin1Char(':')) { evaluated: ch == QLatin1Char(':') yes Evaluation Count:7829 | yes Evaluation Count:294066 |
| 7829-294066 |
94 | if (prefixSeparator == 0) { evaluated: prefixSeparator == 0 yes Evaluation Count:7756 | yes Evaluation Count:73 |
| 73-7756 |
95 | engine = new QResourceFileEngine(filePath); | - |
96 | return _q_checkEntry(engine, resolvingEntry); executed: return _q_checkEntry(engine, resolvingEntry); Execution Count:7756 | 7756 |
97 | } | - |
98 | | - |
99 | if (prefixSeparator == 1) evaluated: prefixSeparator == 1 yes Evaluation Count:2 | yes Evaluation Count:71 |
| 2-71 |
100 | break; executed: break; Execution Count:2 | 2 |
101 | | - |
102 | const QStringList &paths = QDir::searchPaths(filePath.left(prefixSeparator)); | - |
103 | for (int i = 0; i < paths.count(); i++) { evaluated: i < paths.count() yes Evaluation Count:47 | yes Evaluation Count:24 |
| 24-47 |
104 | entry = QFileSystemEntry(QDir::cleanPath(paths.at(i) % QLatin1Char('/') % filePath.mid(prefixSeparator + 1))); | - |
105 | | - |
106 | if (_q_resolveEntryAndCreateLegacyEngine_recursive(entry, data, engine, true)) partially evaluated: _q_resolveEntryAndCreateLegacyEngine_recursive(entry, data, engine, true) yes Evaluation Count:47 | no Evaluation Count:0 |
| 0-47 |
107 | return true; executed: return true; Execution Count:47 | 47 |
108 | } | 0 |
109 | | - |
110 | | - |
111 | return false; executed: return false; Execution Count:24 | 24 |
112 | } | - |
113 | | - |
114 | | - |
115 | | - |
116 | | - |
117 | | - |
118 | | - |
119 | | - |
120 | } executed: } Execution Count:294066 | 294066 |
121 | | - |
122 | | - |
123 | return _q_checkEntry(entry, data, resolvingEntry); executed: return _q_checkEntry(entry, data, resolvingEntry); Execution Count:106407 | 106407 |
124 | } | - |
125 | QAbstractFileEngine *QFileSystemEngine::resolveEntryAndCreateLegacyEngine( | - |
126 | QFileSystemEntry &entry, QFileSystemMetaData &data) { | - |
127 | QFileSystemEntry copy = entry; | - |
128 | QAbstractFileEngine *engine = 0; | - |
129 | | - |
130 | if (_q_resolveEntryAndCreateLegacyEngine_recursive(copy, data, engine)) evaluated: _q_resolveEntryAndCreateLegacyEngine_recursive(copy, data, engine) yes Evaluation Count:114164 | yes Evaluation Count:24 |
| 24-114164 |
131 | | - |
132 | entry = copy; executed: entry = copy; Execution Count:114164 | 114164 |
133 | else | - |
134 | data.clear(); executed: data.clear(); Execution Count:24 | 24 |
135 | | - |
136 | return engine; executed: return engine; Execution Count:114187 | 114187 |
137 | } | - |
138 | | - |
139 | | - |
140 | | - |
141 | | - |
142 | | - |
143 | bool QFileSystemEngine::fillMetaData(int fd, QFileSystemMetaData &data) | - |
144 | { | - |
145 | data.entryFlags &= ~QFileSystemMetaData::PosixStatFlags; | - |
146 | data.knownFlagsMask |= QFileSystemMetaData::PosixStatFlags; | - |
147 | | - |
148 | struct stat64 statBuffer; | - |
149 | if (::fstat64(fd, &statBuffer) == 0) { partially evaluated: ::fstat64(fd, &statBuffer) == 0 yes Evaluation Count:145936 | no Evaluation Count:0 |
| 0-145936 |
150 | data.fillFromStatBuf(statBuffer); | - |
151 | return true; executed: return true; Execution Count:145936 | 145936 |
152 | } | - |
153 | | - |
154 | return false; never executed: return false; | 0 |
155 | } | - |
156 | void QFileSystemMetaData::fillFromStatBuf(const struct stat64 &statBuffer) | - |
157 | { | - |
158 | | - |
159 | if (statBuffer.st_mode & 0400) evaluated: statBuffer.st_mode & 0400 yes Evaluation Count:166297 | yes Evaluation Count:22 |
| 22-166297 |
160 | entryFlags |= QFileSystemMetaData::OwnerReadPermission; executed: entryFlags |= QFileSystemMetaData::OwnerReadPermission; Execution Count:166297 | 166297 |
161 | if (statBuffer.st_mode & 0200) evaluated: statBuffer.st_mode & 0200 yes Evaluation Count:166212 | yes Evaluation Count:107 |
| 107-166212 |
162 | entryFlags |= QFileSystemMetaData::OwnerWritePermission; executed: entryFlags |= QFileSystemMetaData::OwnerWritePermission; Execution Count:166212 | 166212 |
163 | if (statBuffer.st_mode & 0100) evaluated: statBuffer.st_mode & 0100 yes Evaluation Count:12948 | yes Evaluation Count:153371 |
| 12948-153371 |
164 | entryFlags |= QFileSystemMetaData::OwnerExecutePermission; executed: entryFlags |= QFileSystemMetaData::OwnerExecutePermission; Execution Count:12948 | 12948 |
165 | | - |
166 | if (statBuffer.st_mode & (0400 >> 3)) evaluated: statBuffer.st_mode & (0400 >> 3) yes Evaluation Count:162837 | yes Evaluation Count:3482 |
| 3482-162837 |
167 | entryFlags |= QFileSystemMetaData::GroupReadPermission; executed: entryFlags |= QFileSystemMetaData::GroupReadPermission; Execution Count:162837 | 162837 |
168 | if (statBuffer.st_mode & (0200 >> 3)) evaluated: statBuffer.st_mode & (0200 >> 3) yes Evaluation Count:656 | yes Evaluation Count:165663 |
| 656-165663 |
169 | entryFlags |= QFileSystemMetaData::GroupWritePermission; executed: entryFlags |= QFileSystemMetaData::GroupWritePermission; Execution Count:656 | 656 |
170 | if (statBuffer.st_mode & (0100 >> 3)) evaluated: statBuffer.st_mode & (0100 >> 3) yes Evaluation Count:11032 | yes Evaluation Count:155287 |
| 11032-155287 |
171 | entryFlags |= QFileSystemMetaData::GroupExecutePermission; executed: entryFlags |= QFileSystemMetaData::GroupExecutePermission; Execution Count:11032 | 11032 |
172 | | - |
173 | if (statBuffer.st_mode & ((0400 >> 3) >> 3)) evaluated: statBuffer.st_mode & ((0400 >> 3) >> 3) yes Evaluation Count:162789 | yes Evaluation Count:3530 |
| 3530-162789 |
174 | entryFlags |= QFileSystemMetaData::OtherReadPermission; executed: entryFlags |= QFileSystemMetaData::OtherReadPermission; Execution Count:162789 | 162789 |
175 | if (statBuffer.st_mode & ((0200 >> 3) >> 3)) evaluated: statBuffer.st_mode & ((0200 >> 3) >> 3) yes Evaluation Count:613 | yes Evaluation Count:165706 |
| 613-165706 |
176 | entryFlags |= QFileSystemMetaData::OtherWritePermission; executed: entryFlags |= QFileSystemMetaData::OtherWritePermission; Execution Count:613 | 613 |
177 | if (statBuffer.st_mode & ((0100 >> 3) >> 3)) evaluated: statBuffer.st_mode & ((0100 >> 3) >> 3) yes Evaluation Count:11032 | yes Evaluation Count:155287 |
| 11032-155287 |
178 | entryFlags |= QFileSystemMetaData::OtherExecutePermission; executed: entryFlags |= QFileSystemMetaData::OtherExecutePermission; Execution Count:11032 | 11032 |
179 | | - |
180 | | - |
181 | if ((statBuffer.st_mode & 0170000) == 0100000) evaluated: (statBuffer.st_mode & 0170000) == 0100000 yes Evaluation Count:154906 | yes Evaluation Count:11413 |
| 11413-154906 |
182 | entryFlags |= QFileSystemMetaData::FileType; executed: entryFlags |= QFileSystemMetaData::FileType; Execution Count:154906 | 154906 |
183 | else if ((statBuffer.st_mode & 0170000) == 0040000) evaluated: (statBuffer.st_mode & 0170000) == 0040000 yes Evaluation Count:11173 | yes Evaluation Count:240 |
| 240-11173 |
184 | entryFlags |= QFileSystemMetaData::DirectoryType; executed: entryFlags |= QFileSystemMetaData::DirectoryType; Execution Count:11173 | 11173 |
185 | else | - |
186 | entryFlags |= QFileSystemMetaData::SequentialType; executed: entryFlags |= QFileSystemMetaData::SequentialType; Execution Count:240 | 240 |
187 | | - |
188 | | - |
189 | entryFlags |= QFileSystemMetaData::ExistsAttribute; | - |
190 | size_ = statBuffer.st_size; | - |
191 | creationTime_ = statBuffer.st_ctim.tv_sec ? statBuffer.st_ctim.tv_sec : statBuffer.st_mtim.tv_sec; evaluated: statBuffer.st_ctim.tv_sec yes Evaluation Count:166317 | yes Evaluation Count:2 |
| 2-166317 |
192 | modificationTime_ = statBuffer.st_mtim.tv_sec; | - |
193 | accessTime_ = statBuffer.st_atim.tv_sec; | - |
194 | userId_ = statBuffer.st_uid; | - |
195 | groupId_ = statBuffer.st_gid; | - |
196 | } executed: } Execution Count:166319 | 166319 |
197 | | - |
198 | void QFileSystemMetaData::fillFromDirEnt(const struct dirent64 &entry) | - |
199 | { | - |
200 | switch (entry.d_type) | - |
201 | { | - |
202 | case DT_DIR: | - |
203 | knownFlagsMask = QFileSystemMetaData::LinkType | - |
204 | | QFileSystemMetaData::FileType | - |
205 | | QFileSystemMetaData::DirectoryType | - |
206 | | QFileSystemMetaData::SequentialType | - |
207 | | QFileSystemMetaData::ExistsAttribute; | - |
208 | | - |
209 | entryFlags = QFileSystemMetaData::DirectoryType | - |
210 | | QFileSystemMetaData::ExistsAttribute; | - |
211 | | - |
212 | break; executed: break; Execution Count:22593 | 22593 |
213 | | - |
214 | case DT_BLK: | - |
215 | case DT_CHR: | - |
216 | case DT_FIFO: | - |
217 | case DT_SOCK: | - |
218 | | - |
219 | knownFlagsMask = QFileSystemMetaData::LinkType | - |
220 | | QFileSystemMetaData::FileType | - |
221 | | QFileSystemMetaData::DirectoryType | - |
222 | | QFileSystemMetaData::BundleType | - |
223 | | QFileSystemMetaData::AliasType | - |
224 | | QFileSystemMetaData::SequentialType | - |
225 | | QFileSystemMetaData::ExistsAttribute; | - |
226 | | - |
227 | entryFlags = QFileSystemMetaData::SequentialType | - |
228 | | QFileSystemMetaData::ExistsAttribute; | - |
229 | | - |
230 | break; executed: break; Execution Count:158 | 158 |
231 | | - |
232 | case DT_LNK: | - |
233 | knownFlagsMask = QFileSystemMetaData::LinkType; | - |
234 | entryFlags = QFileSystemMetaData::LinkType; | - |
235 | break; executed: break; Execution Count:1995 | 1995 |
236 | | - |
237 | case DT_REG: | - |
238 | knownFlagsMask = QFileSystemMetaData::LinkType | - |
239 | | QFileSystemMetaData::FileType | - |
240 | | QFileSystemMetaData::DirectoryType | - |
241 | | QFileSystemMetaData::BundleType | - |
242 | | QFileSystemMetaData::SequentialType | - |
243 | | QFileSystemMetaData::ExistsAttribute; | - |
244 | | - |
245 | entryFlags = QFileSystemMetaData::FileType | - |
246 | | QFileSystemMetaData::ExistsAttribute; | - |
247 | | - |
248 | break; executed: break; Execution Count:15831 | 15831 |
249 | | - |
250 | case DT_UNKNOWN: | - |
251 | default: | - |
252 | clear(); | - |
253 | } | 0 |
254 | | - |
255 | | - |
256 | | - |
257 | } executed: } Execution Count:40577 | 40577 |
258 | | - |
259 | | - |
260 | | - |
261 | | - |
262 | QString QFileSystemEngine::resolveUserName(const QFileSystemEntry &entry, QFileSystemMetaData &metaData) | - |
263 | { | - |
264 | | - |
265 | | - |
266 | | - |
267 | | - |
268 | if (!metaData.hasFlags(QFileSystemMetaData::UserId)) never evaluated: !metaData.hasFlags(QFileSystemMetaData::UserId) | 0 |
269 | QFileSystemEngine::fillMetaData(entry, metaData, QFileSystemMetaData::UserId); never executed: QFileSystemEngine::fillMetaData(entry, metaData, QFileSystemMetaData::UserId); | 0 |
270 | return resolveUserName(metaData.userId()); never executed: return resolveUserName(metaData.userId()); | 0 |
271 | | - |
272 | } | - |
273 | | - |
274 | | - |
275 | QString QFileSystemEngine::resolveGroupName(const QFileSystemEntry &entry, QFileSystemMetaData &metaData) | - |
276 | { | - |
277 | | - |
278 | | - |
279 | | - |
280 | | - |
281 | if (!metaData.hasFlags(QFileSystemMetaData::GroupId)) never evaluated: !metaData.hasFlags(QFileSystemMetaData::GroupId) | 0 |
282 | QFileSystemEngine::fillMetaData(entry, metaData, QFileSystemMetaData::GroupId); never executed: QFileSystemEngine::fillMetaData(entry, metaData, QFileSystemMetaData::GroupId); | 0 |
283 | return resolveGroupName(metaData.groupId()); never executed: return resolveGroupName(metaData.groupId()); | 0 |
284 | | - |
285 | } | - |
286 | | - |
287 | | - |
288 | | - |
| | |