5#include <QtCore/qdir.h>
6#include <QtCore/qset.h>
7#include <QtCore/qstringbuilder.h>
8#include <QtCore/private/qabstractfileengine_p.h>
9#ifdef QT_BUILD_CORE_LIB
10#include <QtCore/private/qresource_p.h>
12#include <QtCore/private/qduplicatetracker_p.h>
17
18
19
20
21
22
23
24
25
26
27
28
29
32
33
34
35
36
37QString QFileSystemEngine::slowCanonicalized(
const QString &path)
43 const QChar slash(u'/');
44 QString tmpPath = path;
45 qsizetype separatorPos = 0;
46 QSet<QString> nonSymlinks;
47 QDuplicateTracker<QString> known;
49 (
void)known.hasSeen(path);
52 if (separatorPos == 0) {
53 if (tmpPath.size() >= 2 && tmpPath.at(0) == slash && tmpPath.at(1) == slash) {
55 separatorPos = tmpPath.indexOf(slash, 2);
56 }
else if (tmpPath.size() >= 3 && tmpPath.at(1) == u':' && tmpPath.at(2) == slash) {
61 if (separatorPos != -1)
63 separatorPos = tmpPath.indexOf(slash, separatorPos + 1);
64 QString prefix = separatorPos == -1 ? tmpPath : tmpPath.left(separatorPos);
65 if (!nonSymlinks.contains(prefix)) {
68 QString target = fi.symLinkTarget();
69 if (separatorPos != -1) {
70 if (fi.isDir() && !target.endsWith(slash))
72 target.append(QStringView{tmpPath}.mid(separatorPos));
74 tmpPath = QDir::cleanPath(target);
77 if (known.hasSeen(tmpPath))
80 nonSymlinks.insert(prefix);
83 }
while (separatorPos != -1);
85 return QDir::cleanPath(tmpPath);
88static inline bool _q_checkEntry(QFileSystemEntry &entry, QFileSystemMetaData &data,
bool resolvingEntry)
91 if (!QFileSystemEngine::fillMetaData(entry, data, QFileSystemMetaData::ExistsAttribute)
101static inline bool _q_checkEntry(std::unique_ptr<QAbstractFileEngine> &engine,
bool resolvingEntry)
103 if (resolvingEntry) {
104 if (!(engine->fileFlags(QAbstractFileEngine::FlagsMask) & QAbstractFileEngine::ExistsFlag)) {
114 std::unique_ptr<QAbstractFileEngine> &engine,
115 bool resolvingEntry =
false)
117 QString
const &filePath = entry.filePath();
118 if ((engine = qt_custom_file_engine_handler_create(filePath)))
119 return _q_checkEntry(engine, resolvingEntry);
121#if defined(QT_BUILD_CORE_LIB)
122 for (qsizetype prefixSeparator = 0; prefixSeparator < filePath.size(); ++prefixSeparator) {
123 QChar
const ch = filePath[prefixSeparator];
128 if (prefixSeparator == 0) {
129 engine = std::make_unique<QResourceFileEngine>(filePath);
130 return _q_checkEntry(engine, resolvingEntry);
133 if (prefixSeparator == 1)
136 const QStringList &paths = QDir::searchPaths(filePath.left(prefixSeparator));
137 for (
int i = 0; i < paths.size(); i++) {
138 entry = QFileSystemEntry(QDir::cleanPath(
139 paths.at(i) % u'/' % QStringView{filePath}.mid(prefixSeparator + 1)));
141 if (_q_createLegacyEngine_recursive(entry, data, engine,
true))
158 return _q_checkEntry(entry, data, resolvingEntry);
164 return QFileSystemEngine::isCaseSensitive(entry, data);
168
169
170
171
172
173
174
175
176
177std::unique_ptr<QAbstractFileEngine>
178QFileSystemEngine::createLegacyEngine(QFileSystemEntry &entry, QFileSystemMetaData &data)
180 QFileSystemEntry copy = entry;
181 std::unique_ptr<QAbstractFileEngine> engine;
183 if (_q_createLegacyEngine_recursive(copy, data, engine))
193QString QFileSystemEngine::resolveUserName(
const QFileSystemEntry &entry, QFileSystemMetaData &metaData)
197 return QFileSystemEngine::owner(entry, QAbstractFileEngine::OwnerUser);
199 if (!metaData.hasFlags(QFileSystemMetaData::UserId))
200 QFileSystemEngine::fillMetaData(entry, metaData, QFileSystemMetaData::UserId);
201 if (!metaData.exists())
203 return resolveUserName(metaData.userId());
208QString QFileSystemEngine::resolveGroupName(
const QFileSystemEntry &entry, QFileSystemMetaData &metaData)
212 return QFileSystemEngine::owner(entry, QAbstractFileEngine::OwnerGroup);
214 if (!metaData.hasFlags(QFileSystemMetaData::GroupId))
215 QFileSystemEngine::fillMetaData(entry, metaData, QFileSystemMetaData::GroupId);
216 if (!metaData.exists())
218 return resolveGroupName(metaData.groupId());
223QFileSystemEntry QFileSystemEngine::getJunctionTarget(
const QFileSystemEntry &link,
224 QFileSystemMetaData &data)
227 return junctionTarget(link, data);
Combined button and popup list for selecting options.
static bool _q_createLegacyEngine_recursive(QFileSystemEntry &entry, QFileSystemMetaData &data, std::unique_ptr< QAbstractFileEngine > &engine, bool resolvingEntry=false)
static bool _q_checkEntry(QFileSystemEntry &entry, QFileSystemMetaData &data, bool resolvingEntry)
static bool _q_checkEntry(std::unique_ptr< QAbstractFileEngine > &engine, bool resolvingEntry)
Q_CORE_EXPORT bool qt_isCaseSensitive(const QFileSystemEntry &entry, QFileSystemMetaData &data)