io/qfilesystemengine.cpp

Switch to Source codePreprocessed file
LineSource CodeCoverage
1 -
2 -
3 -
4 -
5 -
6 -
7 -
8 -
9 -
10 -
11 -
12QString 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 }
never executed: }
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 {
never executed: }
0
46 nonSymlinks.insert(prefix); -
47 }
never executed: }
0
48 } -
49 } while (separatorPos != -1);
never executed: }
never evaluated: separatorPos != -1
0
50 -
51 return QDir::cleanPath(tmpPath);
never executed: return QDir::cleanPath(tmpPath);
0
52} -
53 -
54static inline bool _q_checkEntry(QFileSystemEntry &entry, QFileSystemMetaData &data, bool resolvingEntry) -
55{ -
56 if (resolvingEntry) {
evaluated: resolvingEntry
TRUEFALSE
yes
Evaluation Count:46
yes
Evaluation Count:155179
46-155179
57 if (!QFileSystemEngine::fillMetaData(entry, data, QFileSystemMetaData::ExistsAttribute)
partially evaluated: !QFileSystemEngine::fillMetaData(entry, data, QFileSystemMetaData::ExistsAttribute)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:46
0-46
58 || !data.exists()) {
partially evaluated: !data.exists()
TRUEFALSE
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:155224
155224
65} -
66 -
67static inline bool _q_checkEntry(QAbstractFileEngine *&engine, bool resolvingEntry) -
68{ -
69 if (resolvingEntry) {
evaluated: resolvingEntry
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:8254
1-8254
70 if (!(engine->fileFlags(QAbstractFileEngine::FlagsMask) & QAbstractFileEngine::ExistsFlag)) {
partially evaluated: !(engine->fileFlags(QAbstractFileEngine::FlagsMask) & QAbstractFileEngine::ExistsFlag)
TRUEFALSE
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:8255
8255
78} -
79 -
80static 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))
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:163556
0-163556
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()
TRUEFALSE
yes
Evaluation Count:451472
yes
Evaluation Count:8758
8758-451472
89 QChar const ch = filePath[prefixSeparator]; -
90 if (ch == QLatin1Char('/'))
evaluated: ch == QLatin1Char('/')
TRUEFALSE
yes
Evaluation Count:146464
yes
Evaluation Count:305006
146464-305006
91 break;
executed: break;
Execution Count:146465
146465
92 -
93 if (ch == QLatin1Char(':')) {
evaluated: ch == QLatin1Char(':')
TRUEFALSE
yes
Evaluation Count:8329
yes
Evaluation Count:296677
8329-296677
94 if (prefixSeparator == 0) {
evaluated: prefixSeparator == 0
TRUEFALSE
yes
Evaluation Count:8255
yes
Evaluation Count:74
74-8255
95 engine = new QResourceFileEngine(filePath); -
96 return _q_checkEntry(engine, resolvingEntry);
executed: return _q_checkEntry(engine, resolvingEntry);
Execution Count:8255
8255
97 } -
98 -
99 if (prefixSeparator == 1)
evaluated: prefixSeparator == 1
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:72
2-72
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()
TRUEFALSE
yes
Evaluation Count:47
yes
Evaluation Count:25
25-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)
TRUEFALSE
yes
Evaluation Count:47
no
Evaluation Count:0
0-47
107 return true;
executed: return true;
Execution Count:47
47
108 }
never executed: }
0
109 -
110 -
111 return false;
executed: return false;
Execution Count:25
25
112 } -
113 -
114 -
115 -
116 -
117 -
118 -
119 -
120 }
executed: }
Execution Count:296677
296677
121 -
122 -
123 return _q_checkEntry(entry, data, resolvingEntry);
executed: return _q_checkEntry(entry, data, resolvingEntry);
Execution Count:155225
155225
124} -
125QAbstractFileEngine *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)
TRUEFALSE
yes
Evaluation Count:163484
yes
Evaluation Count:25
25-163484
131 -
132 entry = copy;
executed: entry = copy;
Execution Count:163489
163489
133 else -
134 data.clear();
executed: data.clear();
Execution Count:25
25
135 -
136 return engine;
executed: return engine;
Execution Count:163509
163509
137} -
138 -
139 -
140 -
141 -
142 -
143bool 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
TRUEFALSE
yes
Evaluation Count:148162
no
Evaluation Count:0
0-148162
150 data.fillFromStatBuf(statBuffer); -
151 return true;
executed: return true;
Execution Count:148163
148163
152 } -
153 -
154 return false;
never executed: return false;
0
155} -
156void QFileSystemMetaData::fillFromStatBuf(const struct stat64 &statBuffer) -
157{ -
158 -
159 if (statBuffer.st_mode & 0400)
evaluated: statBuffer.st_mode & 0400
TRUEFALSE
yes
Evaluation Count:200529
yes
Evaluation Count:22
22-200529
160 entryFlags |= QFileSystemMetaData::OwnerReadPermission;
executed: entryFlags |= QFileSystemMetaData::OwnerReadPermission;
Execution Count:200529
200529
161 if (statBuffer.st_mode & 0200)
evaluated: statBuffer.st_mode & 0200
TRUEFALSE
yes
Evaluation Count:200398
yes
Evaluation Count:153
153-200398
162 entryFlags |= QFileSystemMetaData::OwnerWritePermission;
executed: entryFlags |= QFileSystemMetaData::OwnerWritePermission;
Execution Count:200398
200398
163 if (statBuffer.st_mode & 0100)
evaluated: statBuffer.st_mode & 0100
TRUEFALSE
yes
Evaluation Count:14223
yes
Evaluation Count:186328
14223-186328
164 entryFlags |= QFileSystemMetaData::OwnerExecutePermission;
executed: entryFlags |= QFileSystemMetaData::OwnerExecutePermission;
Execution Count:14223
14223
165 -
166 if (statBuffer.st_mode & (0400 >> 3))
evaluated: statBuffer.st_mode & (0400 >> 3)
TRUEFALSE
yes
Evaluation Count:196533
yes
Evaluation Count:4017
4017-196533
167 entryFlags |= QFileSystemMetaData::GroupReadPermission;
executed: entryFlags |= QFileSystemMetaData::GroupReadPermission;
Execution Count:196533
196533
168 if (statBuffer.st_mode & (0200 >> 3))
evaluated: statBuffer.st_mode & (0200 >> 3)
TRUEFALSE
yes
Evaluation Count:691
yes
Evaluation Count:199859
691-199859
169 entryFlags |= QFileSystemMetaData::GroupWritePermission;
executed: entryFlags |= QFileSystemMetaData::GroupWritePermission;
Execution Count:692
692
170 if (statBuffer.st_mode & (0100 >> 3))
evaluated: statBuffer.st_mode & (0100 >> 3)
TRUEFALSE
yes
Evaluation Count:12215
yes
Evaluation Count:188335
12215-188335
171 entryFlags |= QFileSystemMetaData::GroupExecutePermission;
executed: entryFlags |= QFileSystemMetaData::GroupExecutePermission;
Execution Count:12215
12215
172 -
173 if (statBuffer.st_mode & ((0400 >> 3) >> 3))
evaluated: statBuffer.st_mode & ((0400 >> 3) >> 3)
TRUEFALSE
yes
Evaluation Count:196485
yes
Evaluation Count:4065
4065-196485
174 entryFlags |= QFileSystemMetaData::OtherReadPermission;
executed: entryFlags |= QFileSystemMetaData::OtherReadPermission;
Execution Count:196485
196485
175 if (statBuffer.st_mode & ((0200 >> 3) >> 3))
evaluated: statBuffer.st_mode & ((0200 >> 3) >> 3)
TRUEFALSE
yes
Evaluation Count:648
yes
Evaluation Count:199902
648-199902
176 entryFlags |= QFileSystemMetaData::OtherWritePermission;
executed: entryFlags |= QFileSystemMetaData::OtherWritePermission;
Execution Count:649
649
177 if (statBuffer.st_mode & ((0100 >> 3) >> 3))
evaluated: statBuffer.st_mode & ((0100 >> 3) >> 3)
TRUEFALSE
yes
Evaluation Count:12215
yes
Evaluation Count:188335
12215-188335
178 entryFlags |= QFileSystemMetaData::OtherExecutePermission;
executed: entryFlags |= QFileSystemMetaData::OtherExecutePermission;
Execution Count:12215
12215
179 -
180 -
181 if ((statBuffer.st_mode & 0170000) == 0100000)
evaluated: (statBuffer.st_mode & 0170000) == 0100000
TRUEFALSE
yes
Evaluation Count:187910
yes
Evaluation Count:12640
12640-187910
182 entryFlags |= QFileSystemMetaData::FileType;
executed: entryFlags |= QFileSystemMetaData::FileType;
Execution Count:187910
187910
183 else if ((statBuffer.st_mode & 0170000) == 0040000)
evaluated: (statBuffer.st_mode & 0170000) == 0040000
TRUEFALSE
yes
Evaluation Count:12401
yes
Evaluation Count:240
240-12401
184 entryFlags |= QFileSystemMetaData::DirectoryType;
executed: entryFlags |= QFileSystemMetaData::DirectoryType;
Execution Count:12401
12401
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
TRUEFALSE
yes
Evaluation Count:200549
yes
Evaluation Count:2
2-200549
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:200551
200551
197 -
198void 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:22787
22787
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:160
160
231 -
232 case DT_LNK: -
233 knownFlagsMask = QFileSystemMetaData::LinkType; -
234 entryFlags = QFileSystemMetaData::LinkType; -
235 break;
executed: break;
Execution Count:1993
1993
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:61884
61884
249 -
250 case DT_UNKNOWN: -
251 default: -
252 clear(); -
253 }
never executed: }
0
254 -
255 -
256 -
257}
executed: }
Execution Count:86823
86823
258 -
259 -
260 -
261 -
262QString 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 -
275QString 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 -
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial