Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qdirentryinfo_p.h
Go to the documentation of this file.
1// Copyright (C) 2024 Ahmad Samir <a.samirh78@gmail.com>
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 QDIRENTRYINFO_P_H
5#define QDIRENTRYINFO_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 <QtCore/private/qfileinfo_p.h>
19#include <QtCore/private/qfilesystementry_p.h>
20#include <QtCore/private/qfilesystemmetadata_p.h>
21
23
25{
26 const QFileSystemMetaData &ensureFilled(QFileSystemMetaData::MetaDataFlags what)
27 {
28 if (!metaData.hasFlags(what))
30 return metaData;
31 }
32
33public:
35 {
36 if (!fileInfoOpt) {
37 fileInfoOpt.emplace(new QFileInfoPrivate(entry, metaData));
38 metaData.clear();
39 }
40 return *fileInfoOpt;
41 }
42
44 { return fileInfoOpt ? fileInfoOpt->fileName() : entry.fileName(); }
46 { return fileInfoOpt ? fileInfoOpt->baseName() : entry.baseName(); }
48 { return fileInfoOpt ? fileInfoOpt->completeBaseName() : entry.completeBaseName(); }
50 { return fileInfoOpt ? fileInfoOpt->suffix() : entry.suffix(); }
52 { return fileInfoOpt ? fileInfoOpt->completeSuffix() : entry.completeSuffix(); }
54 { return fileInfoOpt ? fileInfoOpt->filePath() : entry.filePath(); }
55
57
59 {
60 // QFileInfo caches these strings
61 return fileInfo().canonicalFilePath();
62 }
63
65 // QFileInfo caches these strings
66 return fileInfo().absoluteFilePath();
67 }
68
70 // QFileInfo caches these strings
71 return fileInfo().absolutePath();
72 }
73
74
75 bool isDir() {
76 if (fileInfoOpt)
77 return fileInfoOpt->isDir();
78
80 }
81
82 bool isFile() {
83 if (fileInfoOpt)
84 return fileInfoOpt->isFile();
85
86 return ensureFilled(QFileSystemMetaData::FileType).isFile();
87 }
88
89 bool isSymLink() {
90 if (fileInfoOpt)
91 return fileInfoOpt->isSymLink();
92
94 }
95
97 if (fileInfoOpt)
98 return fileInfoOpt->isSymbolicLink();
99
100 return ensureFilled(QFileSystemMetaData::LinkType).isLink();
101 }
102
103 bool exists() {
104 if (fileInfoOpt)
105 return fileInfoOpt->exists();
106
107 return ensureFilled(QFileSystemMetaData::ExistsAttribute).exists();
108 }
109
110 bool isHidden() {
111 if (fileInfoOpt)
112 return fileInfoOpt->isHidden();
113
114 return ensureFilled(QFileSystemMetaData::HiddenAttribute).isHidden();
115 }
116
117 bool isReadable() {
118 if (fileInfoOpt)
119 return fileInfoOpt->isReadable();
120
122 }
123
124 bool isWritable() {
125 if (fileInfoOpt)
126 return fileInfoOpt->isWritable();
127
129 }
130
132 if (fileInfoOpt)
133 return fileInfoOpt->isExecutable();
134
136 }
137
138 qint64 size() { return fileInfo().size(); }
139
144
145private:
146 friend class QDirListingPrivate;
147 friend class QDirListing;
148
150 QFileSystemMetaData metaData;
151 std::optional<QFileInfo> fileInfoOpt;
152};
153
155
156#endif // QDIRENTRYINFO_P_H
\inmodule QtCore\reentrant
Definition qdatetime.h:283
QString suffix() const
QString baseName()
QString filePath()
const QFileInfo & fileInfo()
QString absoluteFilePath()
QString canonicalFilePath()
QDateTime fileTime(QFile::FileTime type, const QTimeZone &tz)
QString completeSuffix() const
QString fileName()
QString completeBaseName() const
QString bundleName()
QString absolutePath()
The QDirListing class provides an STL-style iterator for directory entries.
Definition qdirlisting.h:18
QString bundleName() const
QString absoluteFilePath() const
QDateTime fileTime(QFile::FileTime time) const
QString absolutePath() const
Returns the absolute path of the file system entry this QFileInfo refers to, excluding the entry's na...
qint64 size() const
Returns the file size in bytes.
QString canonicalFilePath() const
Returns the file system entry's canonical path, including the entry's name, that is,...
static bool fillMetaData(const QFileSystemEntry &entry, QFileSystemMetaData &data, QFileSystemMetaData::MetaDataFlags what)
bool hasFlags(MetaDataFlags flags) const
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
\inmodule QtCore
Definition qtimezone.h:26
Combined button and popup list for selecting options.
GLenum type
GLbyte GLbyte tz
GLuint entry
long long qint64
Definition qtypes.h:60