1 | // Copyright (C) 2016 The Qt Company Ltd. |
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
3 | |
4 | #ifndef QDIR_P_H |
5 | #define QDIR_P_H |
6 | |
7 | // |
8 | // W A R N I N G |
9 | // ------------- |
10 | // |
11 | // This file is not part of the Qt API. It exists purely as an |
12 | // implementation detail. This header file may change from version to |
13 | // version without notice, or even be removed. |
14 | // |
15 | // We mean it. |
16 | // |
17 | |
18 | #include "qfilesystementry_p.h" |
19 | #include "qfilesystemmetadata_p.h" |
20 | |
21 | #include <QtCore/qmutex.h> |
22 | |
23 | #include <memory> |
24 | |
25 | QT_BEGIN_NAMESPACE |
26 | |
27 | class QDirPrivate : public QSharedData |
28 | { |
29 | public: |
30 | enum PathNormalization { |
31 | DefaultNormalization = 0x00, |
32 | AllowUncPaths = 0x01, |
33 | RemotePath = 0x02 |
34 | }; |
35 | Q_DECLARE_FLAGS(PathNormalizations, PathNormalization) |
36 | Q_FLAGS(PathNormalizations) |
37 | |
38 | explicit QDirPrivate(const QString &path, const QStringList &nameFilters_ = QStringList(), |
39 | QDir::SortFlags sort_ = QDir::SortFlags(QDir::Name | QDir::IgnoreCase), |
40 | QDir::Filters filters_ = QDir::AllEntries); |
41 | |
42 | explicit QDirPrivate(const QDirPrivate ©); // Copies everything except mutex and fileEngine |
43 | |
44 | bool exists() const; |
45 | |
46 | void initFileLists(const QDir &dir) const; |
47 | |
48 | static void sortFileList(QDir::SortFlags, const QFileInfoList &, QStringList *, QFileInfoList *); |
49 | |
50 | static inline QChar getFilterSepChar(const QString &nameFilter); |
51 | |
52 | static inline QStringList splitFilters(const QString &nameFilter, QChar sep = {}); |
53 | |
54 | void setPath(const QString &path); |
55 | |
56 | enum MetaDataClearing { KeepMetaData, IncludingMetaData }; |
57 | void clearCache(MetaDataClearing mode); |
58 | |
59 | QString resolveAbsoluteEntry() const; |
60 | |
61 | QStringList nameFilters; |
62 | QDir::SortFlags sort; |
63 | QDir::Filters filters; |
64 | |
65 | std::unique_ptr<QAbstractFileEngine> fileEngine; |
66 | |
67 | QFileSystemEntry dirEntry; |
68 | |
69 | struct FileCache |
70 | { |
71 | QMutex mutex; |
72 | QStringList files; |
73 | QFileInfoList fileInfos; |
74 | std::atomic<bool> fileListsInitialized = false; |
75 | QFileSystemEntry absoluteDirEntry; |
76 | QFileSystemMetaData metaData; |
77 | }; |
78 | mutable FileCache fileCache; |
79 | }; |
80 | |
81 | Q_DECLARE_OPERATORS_FOR_FLAGS(QDirPrivate::PathNormalizations) |
82 | |
83 | Q_AUTOTEST_EXPORT QString qt_normalizePathSegments(const QString &name, QDirPrivate::PathNormalizations flags, bool *ok = nullptr); |
84 | |
85 | QT_END_NAMESPACE |
86 | |
87 | #endif |
88 | |