24 friend class QDirIteratorPrivate;
25 friend class QDirListingPrivate;
26 friend class QFileInfoPrivate;
28 explicit QFileInfo(QFileInfoPrivate *d);
30#ifdef QT_IMPLICIT_QFILEINFO_CONSTRUCTION
31#define QFILEINFO_MAYBE_EXPLICIT Q_IMPLICIT
33#define QFILEINFO_MAYBE_EXPLICIT explicit
40 QFileInfo(
const QFileInfo &fileinfo);
42 QFileInfo(
const std::filesystem::path &file);
43 QFileInfo(
const QDir &dir,
const std::filesystem::path &file);
44#elif QT_CONFIG(cxx17_filesystem)
45 template<
typename T, QtPrivate::ForceFilesystemPath<T> = 0>
46 QFILEINFO_MAYBE_EXPLICIT QFileInfo(
const T &file) : QFileInfo(QtPrivate::fromFilesystemPath(file)) { }
48 template<
typename T, QtPrivate::ForceFilesystemPath<T> = 0>
49 QFILEINFO_MAYBE_EXPLICIT QFileInfo(
const QDir &dir,
const T &file) : QFileInfo(dir, QtPrivate::fromFilesystemPath(file))
54#undef QFILEINFO_MAYBE_EXPLICIT
58 QFileInfo &operator=(
const QFileInfo &fileinfo);
59 QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QFileInfo)
61 void swap(QFileInfo &other)
noexcept
62 { d_ptr.swap(other.d_ptr); }
64#if QT_CORE_REMOVED_SINCE(6
, 8
)
65 bool operator==(
const QFileInfo &fileinfo)
const;
66 inline bool operator!=(
const QFileInfo &fileinfo)
const {
return !(operator==(fileinfo)); }
69 void setFile(
const QString &file);
70 void setFile(
const QFileDevice &file);
71 void setFile(
const QDir &dir,
const QString &file);
73 void setFile(
const std::filesystem::path &file);
74#elif QT_CONFIG(cxx17_filesystem)
75 template<
typename T, QtPrivate::ForceFilesystemPath<T> = 0>
76 void setFile(
const T &file) { setFile(QtPrivate::fromFilesystemPath(file)); }
80 static bool exists(
const QString &file);
83 QString filePath()
const;
84 QString absoluteFilePath()
const;
85 QString canonicalFilePath()
const;
86#if QT_CONFIG(cxx17_filesystem) || defined(Q_QDOC)
87 std::filesystem::path filesystemFilePath()
const
88 {
return QtPrivate::toFilesystemPath(filePath()); }
89 std::filesystem::path filesystemAbsoluteFilePath()
const
90 {
return QtPrivate::toFilesystemPath(absoluteFilePath()); }
91 std::filesystem::path filesystemCanonicalFilePath()
const
92 {
return QtPrivate::toFilesystemPath(canonicalFilePath()); }
94 QString fileName()
const;
95 QString baseName()
const;
96 QString completeBaseName()
const;
97 QString suffix()
const;
98 QString bundleName()
const;
99 QString completeSuffix()
const;
101 QString path()
const;
102 QString absolutePath()
const;
103 QString canonicalPath()
const;
104#if QT_CONFIG(cxx17_filesystem) || defined(Q_QDOC)
105 std::filesystem::path filesystemPath()
const {
return QtPrivate::toFilesystemPath(path()); }
106 std::filesystem::path filesystemAbsolutePath()
const
107 {
return QtPrivate::toFilesystemPath(absolutePath()); }
108 std::filesystem::path filesystemCanonicalPath()
const
109 {
return QtPrivate::toFilesystemPath(canonicalPath()); }
112 QDir absoluteDir()
const;
114 bool isReadable()
const;
115 bool isWritable()
const;
116 bool isExecutable()
const;
117 bool isHidden()
const;
118 bool isNativePath()
const;
120 bool isRelative()
const;
121 inline bool isAbsolute()
const {
return !isRelative(); }
126 bool isSymLink()
const;
127 bool isSymbolicLink()
const;
128 bool isOther()
const;
129 bool isShortcut()
const;
130 bool isAlias()
const;
131 bool isJunction()
const;
133 bool isBundle()
const;
135 QString symLinkTarget()
const;
136 QString readSymLink()
const;
137 QString junctionTarget()
const;
139#if QT_CONFIG(cxx17_filesystem) || defined(Q_QDOC)
140 std::filesystem::path filesystemSymLinkTarget()
const
141 {
return QtPrivate::toFilesystemPath(symLinkTarget()); }
143 std::filesystem::path filesystemReadSymLink()
const
144 {
return QtPrivate::toFilesystemPath(readSymLink()); }
146 std::filesystem::path filesystemJunctionTarget()
const
147 {
return QtPrivate::toFilesystemPath(junctionTarget()); }
150 QString owner()
const;
151 uint ownerId()
const;
152 QString group()
const;
153 uint groupId()
const;
155 bool permission(QFile::Permissions permissions)
const;
156 QFile::Permissions permissions()
const;
160 QDateTime birthTime()
const {
return fileTime(QFile::FileBirthTime); }
161 QDateTime metadataChangeTime()
const {
return fileTime(QFile::FileMetadataChangeTime); }
162 QDateTime lastModified()
const {
return fileTime(QFile::FileModificationTime); }
163 QDateTime lastRead()
const {
return fileTime(QFile::FileAccessTime); }
164 QDateTime fileTime(QFile::FileTime time)
const;
166 QDateTime birthTime(
const QTimeZone &tz)
const {
return fileTime(QFile::FileBirthTime, tz); }
167 QDateTime metadataChangeTime(
const QTimeZone &tz)
const {
return fileTime(QFile::FileMetadataChangeTime, tz); }
168 QDateTime lastModified(
const QTimeZone &tz)
const {
return fileTime(QFile::FileModificationTime, tz); }
169 QDateTime lastRead(
const QTimeZone &tz)
const {
return fileTime(QFile::FileAccessTime, tz); }
170 QDateTime fileTime(QFile::FileTime time,
const QTimeZone &tz)
const;
172 bool caching()
const;
173 void setCaching(
bool on);
177 QSharedDataPointer<QFileInfoPrivate> d_ptr;
180 friend Q_CORE_EXPORT
bool comparesEqual(
const QFileInfo &lhs,
const QFileInfo &rhs);
181 Q_DECLARE_EQUALITY_COMPARABLE_NON_NOEXCEPT(QFileInfo)
182 QFileInfoPrivate* d_func();
183 inline const QFileInfoPrivate* d_func()
const
185 return d_ptr.constData();