5#ifndef QFILESYSTEMENGINE_P_H
6#define QFILESYSTEMENGINE_P_H
22#include <QtCore/private/qsystemerror_p.h>
29#define Q_RETURN_ON_INVALID_FILENAME(message, result)
38 return name.contains(
'\0');
43 return name.contains(QLatin1Char(
'\0'));
48 return qIsFilenameBroken(entry.nativeFilePath());
51#define Q_CHECK_FILE_NAME(name, result)
53 if (Q_UNLIKELY((name).isEmpty()))
55 if (Q_UNLIKELY(qIsFilenameBroken(name)))
59Q_CORE_EXPORT
bool qt_isCaseSensitive(
const QFileSystemEntry &entry, QFileSystemMetaData &data);
64 using TriStateResult = QAbstractFileEngine::TriStateResult;
66 static bool isCaseSensitive(
const QFileSystemEntry &entry, QFileSystemMetaData &data);
68 static QFileSystemEntry getLinkTarget(
const QFileSystemEntry &link, QFileSystemMetaData &data);
69 static QFileSystemEntry getRawLinkPath(
const QFileSystemEntry &link,
70 QFileSystemMetaData &data);
71 static QFileSystemEntry getJunctionTarget(
const QFileSystemEntry &link, QFileSystemMetaData &data);
72 static QFileSystemEntry canonicalName(
const QFileSystemEntry &entry, QFileSystemMetaData &data);
73 static QFileSystemEntry absoluteName(
const QFileSystemEntry &entry);
74 static QByteArray id(
const QFileSystemEntry &entry);
75 static QString resolveUserName(
const QFileSystemEntry &entry, QFileSystemMetaData &data);
76 static QString resolveGroupName(
const QFileSystemEntry &entry, QFileSystemMetaData &data);
79 static QString resolveUserName(uint userId);
80 static QString resolveGroupName(uint groupId);
83#if defined(Q_OS_DARWIN)
84 static QString bundleName(
const QFileSystemEntry &entry);
86 static QString bundleName(
const QFileSystemEntry &) {
return QString(); }
89 static bool fillMetaData(
const QFileSystemEntry &entry, QFileSystemMetaData &data,
90 QFileSystemMetaData::MetaDataFlags what);
92 static TriStateResult cloneFile(
int srcfd,
int dstfd,
const QFileSystemMetaData &knownData);
93 static bool fillMetaData(
int fd, QFileSystemMetaData &data);
94 static QByteArray id(
int fd);
95 static bool setFileTime(
int fd,
const QDateTime &newDate,
96 QFile::FileTime whatTime, QSystemError &error);
97 static bool setPermissions(
int fd, QFile::Permissions permissions, QSystemError &error);
100 static QFileSystemEntry junctionTarget(
const QFileSystemEntry &link, QFileSystemMetaData &data);
101 static bool uncListSharesOnServer(
const QString &server, QStringList *list);
102 static bool fillMetaData(
int fd, QFileSystemMetaData &data,
103 QFileSystemMetaData::MetaDataFlags what);
104 static bool fillMetaData(HANDLE fHandle, QFileSystemMetaData &data,
105 QFileSystemMetaData::MetaDataFlags what);
106 static bool fillPermissions(
const QFileSystemEntry &entry, QFileSystemMetaData &data,
107 QFileSystemMetaData::MetaDataFlags what);
108 static QByteArray id(HANDLE fHandle);
109 static bool setFileTime(HANDLE fHandle,
const QDateTime &newDate,
110 QFile::FileTime whatTime, QSystemError &error);
111 static QString owner(
const QFileSystemEntry &entry, QAbstractFileEngine::FileOwner own);
112 static QString nativeAbsoluteFilePath(
const QString &path);
113 static bool isDirPath(
const QString &path,
bool *existed);
116 static QString homePath();
117 static QString rootPath();
118 static QString tempPath();
120 static bool createDirectory(
const QFileSystemEntry &entry,
bool createParents,
121 std::optional<QFile::Permissions> permissions = std::nullopt)
124 return mkpath(entry, permissions);
125 return mkdir(entry, permissions);
128 static bool mkdir(
const QFileSystemEntry &entry,
129 std::optional<QFile::Permissions> permissions = std::nullopt);
130 static bool mkpath(
const QFileSystemEntry &entry,
131 std::optional<QFile::Permissions> permissions = std::nullopt);
133 static bool removeDirectory(
const QFileSystemEntry &entry,
bool removeEmptyParents)
135 if (removeEmptyParents)
136 return rmpath(entry);
140 static bool rmdir(
const QFileSystemEntry &entry);
141 static bool rmpath(
const QFileSystemEntry &entry);
143 static bool createLink(
const QFileSystemEntry &source,
const QFileSystemEntry &target, QSystemError &error);
145 static bool copyFile(
const QFileSystemEntry &source,
const QFileSystemEntry &target, QSystemError &error);
146 static bool supportsMoveFileToTrash();
147 static bool moveFileToTrash(
const QFileSystemEntry &source, QFileSystemEntry &newLocation, QSystemError &error);
148 static bool renameFile(
const QFileSystemEntry &source,
const QFileSystemEntry &target, QSystemError &error);
149 static bool renameOverwriteFile(
const QFileSystemEntry &source,
const QFileSystemEntry &target, QSystemError &error);
150 static bool removeFile(
const QFileSystemEntry &entry, QSystemError &error);
152 static bool setPermissions(
const QFileSystemEntry &entry, QFile::Permissions permissions,
153 QSystemError &error);
156 static bool setFileTime(
const QFileSystemEntry &entry,
const QDateTime &newDate,
157 QFile::FileTime whatTime, QSystemError &error);
159 static bool setCurrentPath(
const QFileSystemEntry &entry);
160 static QFileSystemEntry currentPath();
162 static std::unique_ptr<QAbstractFileEngine>
163 createLegacyEngine(QFileSystemEntry &entry, QFileSystemMetaData &data);
166 static QString slowCanonicalized(
const QString &path);
168 static void clearWinStatData(QFileSystemMetaData &data);
The QAbstractFileEngineIterator class provides an iterator interface for custom file engines.
virtual ~QAbstractFileEnginePrivate()
QAbstractFileEnginePrivate(QAbstractFileEngine *q)
QFile::FileError fileError
QAbstractFileEngine *const q_ptr
\inmodule QtCore \reentrant
QDirPrivate(const QDirPrivate ©)
void clearCache(MetaDataClearing mode)
void initFileLists(const QDir &dir) const
QString resolveAbsoluteEntry() const
bool operator()(const QDirSortItem &, const QDirSortItem &) const
QDirSortItemComparator(QDir::SortFlags flags, QCollator *coll=nullptr)
int compareStrings(const QString &a, const QString &b, Qt::CaseSensitivity cs) const
const_iterator & operator++() noexcept
The prefix ++ operator ({++i}) advances the iterator to the next item in the hash and returns an iter...
const_iterator(const iterator &o) noexcept
Constructs a copy of other.
constexpr const_iterator() noexcept=default
Constructs an uninitialized iterator.
const_iterator operator++(int) noexcept
This is an overloaded member function, provided for convenience. It differs from the above function o...
std::forward_iterator_tag iterator_category
const T * operator->() const noexcept
Returns a pointer to the current item's value.
bool operator==(const const_iterator &o) const noexcept
Returns true if other points to the same item as this iterator; otherwise returns false.
const T & value() const noexcept
Returns the current item's value.
const Key & key() const noexcept
Returns the current item's key.
bool operator!=(const const_iterator &o) const noexcept
Returns true if other points to a different item than this iterator; otherwise returns false.
const T & operator*() const noexcept
Returns the current item's value.
key_iterator & operator++() noexcept
The prefix ++ operator ({++i}) advances the iterator to the next item in the hash and returns an iter...
key_iterator() noexcept=default
bool operator!=(key_iterator o) const noexcept
Returns true if other points to a different item than this iterator; otherwise returns false.
key_iterator operator++(int) noexcept
This is an overloaded member function, provided for convenience. It differs from the above function o...
const Key & operator*() const noexcept
Returns the current item's key.
const Key * operator->() const noexcept
Returns a pointer to the current item's key.
key_iterator(const_iterator o) noexcept
bool operator==(key_iterator o) const noexcept
Returns true if other points to the same item as this iterator; otherwise returns false.
const_iterator::iterator_category iterator_category
const_iterator base() const noexcept
Returns the underlying const_iterator this key_iterator is based on.
QHash & operator=(const QHash &other) noexcept(std::is_nothrow_destructible< Node >::value)
Assigns other to this hash and returns a reference to this hash.
key_value_iterator try_emplace(const_iterator, K &&key, Args &&...args)
T & operator[](const K &key)
key_iterator keyEnd() const noexcept
const T operator[](const K &key) const noexcept
std::pair< const_iterator, const_iterator > equal_range(const Key &key) const noexcept
TryEmplaceResult insertOrAssign(const Key &key, Value &&value)
float load_factor() const noexcept
Returns the current load factor of the QHash's internal hash table.
const_iterator constFind(const Key &key) const noexcept
std::pair< key_value_iterator, bool > insert_or_assign(Key &&key, Value &&value)
~QHash()
Destroys the hash.
iterator erase(const_iterator it)
std::pair< key_value_iterator, bool > try_emplace(K &&key, Args &&...args)
iterator emplace(const Key &key, Args &&... args)
key_value_iterator keyValueBegin()
const_iterator constFind(const K &key) const noexcept
T value(const K &key, const T &defaultValue) const noexcept
QHash(const QHash &other) noexcept
Constructs a copy of other.
auto asKeyValueRange() const &&
TryEmplaceResult tryEmplace(K &&key, Args &&...args)
TryEmplaceResult tryInsert(const Key &key, const T &value)
iterator emplace(Key &&key, Args &&... args)
Inserts a new element into the container.
friend bool comparesEqual(const QHash &lhs, const QHash &rhs) noexcept
TryEmplaceResult tryEmplace(const Key &key, Args &&...args)
\variable QHash::TryEmplaceResult::iterator
const_key_value_iterator constKeyValueEnd() const noexcept
bool empty() const noexcept
This function is provided for STL compatibility.
std::pair< key_value_iterator, bool > insert_or_assign(K &&key, Value &&value)
const_iterator cbegin() const noexcept
std::pair< key_value_iterator, bool > try_emplace(const Key &key, Args &&...args)
key_value_iterator insert_or_assign(const_iterator, K &&key, Value &&value)
iterator begin()
Returns an \l{STL-style iterators}{STL-style iterator} pointing to the first item in the hash.
void insert(const QHash &hash)
const_iterator find(const Key &key) const noexcept
This is an overloaded member function, provided for convenience. It differs from the above function o...
std::pair< key_value_iterator, bool > try_emplace(Key &&key, Args &&...args)
static float max_load_factor() noexcept
QKeyValueIterator< const Key &, const T &, const_iterator > const_key_value_iterator
\inmodule QtCore
const_key_value_iterator keyValueBegin() const noexcept
TryEmplaceResult insertOrAssign(K &&key, Value &&value)
key_value_iterator keyValueEnd()
const_iterator end() const noexcept
This is an overloaded member function, provided for convenience. It differs from the above function o...
Key key_type
Typedef for Key.
iterator find(const K &key)
const_key_value_iterator constKeyValueBegin() const noexcept
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
qsizetype count(const K &key) const
std::pair< iterator, iterator > equal_range(const K &key)
key_iterator keyBegin() const noexcept
iterator Iterator
Qt-style synonym for QHash::iterator.
key_value_iterator insert_or_assign(const_iterator, const Key &key, Value &&value)
bool contains(const K &key) const
TryEmplaceResult tryInsert(K &&key, const T &value)
std::pair< const_iterator, const_iterator > equal_range(const K &key) const noexcept
size_t bucket_count() const noexcept
const_iterator ConstIterator
Qt-style synonym for QHash::const_iterator.
key_value_iterator try_emplace(const_iterator, Key &&key, Args &&...args)
auto asKeyValueRange() &&
auto asKeyValueRange() const &
const_iterator constBegin() const noexcept
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the first item in the hash.
qsizetype count() const noexcept
This is an overloaded member function, provided for convenience. It differs from the above function o...
QHash(std::initializer_list< std::pair< Key, T > > list)
T value(const K &key) const noexcept
const_iterator find(const K &key) const noexcept
iterator find(const Key &key)
Returns an iterator pointing to the item with the key in the hash.
iterator end() noexcept
Returns an \l{STL-style iterators}{STL-style iterator} pointing to the imaginary item after the last ...
QHash(QHash &&other) noexcept
Move-constructs a QHash instance, making it point at the same object that other was pointing to.
std::pair< key_value_iterator, bool > insert_or_assign(const Key &key, Value &&value)
std::pair< iterator, iterator > equal_range(const Key &key)
const_iterator cend() const noexcept
key_value_iterator insert_or_assign(const_iterator, Key &&key, Value &&value)
static size_t max_bucket_count() noexcept
bool remove(const K &key)
QKeyValueIterator< const Key &, T &, iterator > key_value_iterator
\inmodule QtCore
TryEmplaceResult insertOrAssign(Key &&key, Value &&value)
QHash() noexcept=default
Constructs an empty hash.
const T & const_reference
TryEmplaceResult tryEmplace(Key &&key, Args &&...args)
key_value_iterator try_emplace(const_iterator, const Key &key, Args &&...args)
T mapped_type
Typedef for T.
const_key_value_iterator keyValueEnd() const noexcept
const_iterator begin() const noexcept
This is an overloaded member function, provided for convenience. It differs from the above function o...
const_iterator constEnd() const noexcept
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the imaginary item after the ...
constexpr size_t bucketForHash(size_t nBuckets, size_t hash) noexcept
constexpr size_t bucketsForCapacity(size_t requestedCapacity) noexcept
constexpr bool isRelocatable()
constexpr bool HasStdHashSpecializationWithoutSeed
size_t calculateHash(const T &t, size_t seed=0)
std::conditional_t< std::is_same_v< HashKey, q20::remove_cvref_t< KeyArgument > >, KeyArgument, HashKey > HeterogenousConstructProxy
constexpr bool HasQHashOverload
constexpr bool HasStdHashSpecializationWithSeed
std::unique_ptr< QAbstractFileEngine > qt_custom_file_engine_handler_create(const QString &path)
static void appendIfMatchesNonDirListingFlags(const QDirListing::DirEntry &dirEntry, QDir::Filters filters, QFileInfoList &l)
static qsizetype rootLength(QStringView name, QDirPrivate::PathNormalizations flags)
static bool qt_cleanPath(QString *path)
bool comparesEqual(const QDir &lhs, const QDir &rhs)
static bool treatAsAbsolute(const QString &path)
static bool checkPermissions(const QDirListing::DirEntry &dirEntry, QDir::Filters filters)
bool qt_normalizePathSegments(QString *path, QDirPrivate::PathNormalizations flags)
static bool checkDotOrDotDot(const QDirListing::DirEntry &dirEntry, QDir::Filters filters)
Q_AUTOTEST_EXPORT bool qt_normalizePathSegments(QString *path, QDirPrivate::PathNormalizations flags)
Q_CORE_EXPORT bool qt_isCaseSensitive(const QFileSystemEntry &entry, QFileSystemMetaData &data)
bool qIsFilenameBroken(const QFileSystemEntry &entry)
bool qIsFilenameBroken(const QString &name)
#define Q_RETURN_ON_INVALID_FILENAME(message, result)
bool qIsFilenameBroken(const QByteArray &name)
qsizetype erase_if(QMultiHash< Key, T > &hash, Predicate pred)
size_t qHash(const QMultiHash< Key, T > &key, size_t seed=0) noexcept(noexcept(qHash(std::declval< Key & >())) &&noexcept(qHash(std::declval< T & >())))
qsizetype erase_if(QHash< Key, T > &hash, Predicate pred)
QDirSortItem(const QFileInfo &fi, QDir::SortFlags sort)
friend bool operator==(Bucket lhs, Bucket rhs) noexcept
size_t offset() const noexcept
bool isUnused() const noexcept
Bucket(const Data *d, size_t bucket) noexcept
Bucket(Span *s, size_t i) noexcept
void advance(const Data *d) noexcept
Node & nodeAtOffset(size_t offset)
iterator toIterator(const Data *d) const noexcept
friend bool operator!=(Bucket lhs, Bucket rhs) noexcept
void advanceWrapped(const Data *d) noexcept
Bucket(iterator it) noexcept
size_t toBucketIndex(const Data *d) const noexcept
Bucket findBucketWithHash(const K &key, size_t hash) const noexcept
iterator begin() const noexcept
QHashPrivate::Span< Node > Span
size_t nextBucket(size_t bucket) const noexcept
typename Node::ValueType T
InsertionResult findOrInsert(const K &key) noexcept
Node * findNode(const K &key) const noexcept
QHashPrivate::iterator< Node > iterator
static Data * detached(Data *d)
iterator detachedIterator(iterator other) const noexcept
constexpr iterator end() const noexcept
bool shouldGrow() const noexcept
typename Node::KeyType Key
void rehash(size_t sizeHint=0)
Q_ALWAYS_INLINE void reallocationHelper(const Data &other, size_t nSpans)
void erase(Bucket bucket) noexcept(std::is_nothrow_destructible< Node >::value)
static Data * detached(Data *d, size_t size)
float loadFactor() const noexcept
static auto allocateSpans(size_t numBuckets)
Data(const Data &other, size_t reserved)
static constexpr size_t maxNumBuckets() noexcept
Bucket findBucket(const K &key) const noexcept
qsizetype free() noexcept(std::is_nothrow_destructible_v< T >)
bool contains(const T &val) const noexcept
static qsizetype freeChain(MultiNode *n) noexcept(std::is_nothrow_destructible_v< T >)
MultiNode(MultiNode &&other)
void insertMulti(Args &&... args)
MultiNode(const MultiNode &other)
static void createInPlace(MultiNode *n, const Key &k, Args &&... args)
MultiNode(const Key &k, Chain *c)
static void createInPlace(MultiNode *n, Key &&k, Args &&... args)
MultiNode(Key &&k, Chain *c) noexcept(std::is_nothrow_move_assignable_v< Key >)
MultiNodeChain< T > Chain
void emplaceValue(Args &&... args)
static void createInPlace(Node *n, const Key &k, Args &&...)
QHashDummyValue ValueType
void emplaceValue(Args &&...)
bool valuesEqual(const Node *) const
static void createInPlace(Node *n, Key &&k, Args &&...)
void emplaceValue(Args &&... args)
bool valuesEqual(const Node *other) const
static void createInPlace(Node *n, const Key &k, Args &&... args)
static void createInPlace(Node *n, Key &&k, Args &&... args)
T && takeValue() noexcept(std::is_nothrow_move_assignable_v< T >)
static constexpr size_t SpanShift
static constexpr size_t LocalBucketMask
static constexpr size_t UnusedEntry
static constexpr size_t NEntries
unsigned char & nextFree()
unsigned char data[sizeof(Node)]
const Node & at(size_t i) const noexcept
void moveLocal(size_t from, size_t to) noexcept
void freeData() noexcept(std::is_nothrow_destructible< Node >::value)
void erase(size_t bucket) noexcept(std::is_nothrow_destructible< Node >::value)
unsigned char offsets[SpanConstants::NEntries]
Node & atOffset(size_t o) noexcept
size_t offset(size_t i) const noexcept
bool hasNode(size_t i) const noexcept
void moveFromSpan(Span &fromSpan, size_t fromIndex, size_t to) noexcept(std::is_nothrow_move_constructible_v< Node >)
const Node & atOffset(size_t o) const noexcept
Node & at(size_t i) noexcept
Node * node() const noexcept
size_t span() const noexcept
iterator operator++() noexcept
size_t index() const noexcept
QHashPrivate::Span< Node > Span
bool isUnused() const noexcept
bool operator!=(iterator other) const noexcept
bool atEnd() const noexcept
bool operator==(iterator other) const noexcept
TryEmplaceResult(QHash::iterator it, bool b)
TryEmplaceResult()=default