25 friend class QDirIteratorPrivate;
26 friend class QDirListingPrivate;
27 friend class QFileInfoPrivate;
29 explicit QFileInfo(QFileInfoPrivate *d);
31#ifdef QT_IMPLICIT_QFILEINFO_CONSTRUCTION
32#define QFILEINFO_MAYBE_EXPLICIT Q_IMPLICIT
34#define QFILEINFO_MAYBE_EXPLICIT explicit
41 QFileInfo(
const QFileInfo &fileinfo);
43 QFileInfo(
const std::filesystem::path &file);
44 QFileInfo(
const QDir &dir,
const std::filesystem::path &file);
45#elif QT_CONFIG(cxx17_filesystem)
46 template<
typename T, QtPrivate::ForceFilesystemPath<T> = 0>
47 QFILEINFO_MAYBE_EXPLICIT QFileInfo(
const T &file) : QFileInfo(QtPrivate::fromFilesystemPath(file)) { }
49 template<
typename T, QtPrivate::ForceFilesystemPath<T> = 0>
50 QFILEINFO_MAYBE_EXPLICIT QFileInfo(
const QDir &dir,
const T &file) : QFileInfo(dir, QtPrivate::fromFilesystemPath(file))
55#undef QFILEINFO_MAYBE_EXPLICIT
59 QFileInfo &operator=(
const QFileInfo &fileinfo);
60 QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QFileInfo)
62 void swap(QFileInfo &other)
noexcept
63 { d_ptr.swap(other.d_ptr); }
65#if QT_CORE_REMOVED_SINCE(6
, 8
)
66 bool operator==(
const QFileInfo &fileinfo)
const;
67 inline bool operator!=(
const QFileInfo &fileinfo)
const {
return !(operator==(fileinfo)); }
70 void setFile(
const QString &file);
71 void setFile(
const QFileDevice &file);
72 void setFile(
const QDir &dir,
const QString &file);
74 void setFile(
const std::filesystem::path &file);
75#elif QT_CONFIG(cxx17_filesystem)
76 template<
typename T, QtPrivate::ForceFilesystemPath<T> = 0>
77 void setFile(
const T &file) { setFile(QtPrivate::fromFilesystemPath(file)); }
81 static bool exists(
const QString &file);
84 QString filePath()
const;
85 QString absoluteFilePath()
const;
86 QString canonicalFilePath()
const;
87#if QT_CONFIG(cxx17_filesystem) || defined(Q_QDOC)
88 std::filesystem::path filesystemFilePath()
const
89 {
return QtPrivate::toFilesystemPath(filePath()); }
90 std::filesystem::path filesystemAbsoluteFilePath()
const
91 {
return QtPrivate::toFilesystemPath(absoluteFilePath()); }
92 std::filesystem::path filesystemCanonicalFilePath()
const
93 {
return QtPrivate::toFilesystemPath(canonicalFilePath()); }
95 QString fileName()
const;
96 QString baseName()
const;
97 QString completeBaseName()
const;
98 QString suffix()
const;
99 QString bundleName()
const;
100 QString completeSuffix()
const;
102 QString path()
const;
103 QString absolutePath()
const;
104 QString canonicalPath()
const;
105#if QT_CONFIG(cxx17_filesystem) || defined(Q_QDOC)
106 std::filesystem::path filesystemPath()
const {
return QtPrivate::toFilesystemPath(path()); }
107 std::filesystem::path filesystemAbsolutePath()
const
108 {
return QtPrivate::toFilesystemPath(absolutePath()); }
109 std::filesystem::path filesystemCanonicalPath()
const
110 {
return QtPrivate::toFilesystemPath(canonicalPath()); }
113 QDir absoluteDir()
const;
115 bool isReadable()
const;
116 bool isWritable()
const;
117 bool isExecutable()
const;
118 bool isHidden()
const;
119 bool isNativePath()
const;
121 bool isRelative()
const;
122 inline bool isAbsolute()
const {
return !isRelative(); }
127 bool isSymLink()
const;
128 bool isSymbolicLink()
const;
129 bool isOther()
const;
130 bool isShortcut()
const;
131 bool isAlias()
const;
132 bool isJunction()
const;
134 bool isBundle()
const;
136 QString symLinkTarget()
const;
137 QString readSymLink()
const;
138 QString junctionTarget()
const;
140#if QT_CONFIG(cxx17_filesystem) || defined(Q_QDOC)
141 std::filesystem::path filesystemSymLinkTarget()
const
142 {
return QtPrivate::toFilesystemPath(symLinkTarget()); }
144 std::filesystem::path filesystemReadSymLink()
const
145 {
return QtPrivate::toFilesystemPath(readSymLink()); }
147 std::filesystem::path filesystemJunctionTarget()
const
148 {
return QtPrivate::toFilesystemPath(junctionTarget()); }
151 QString owner()
const;
152 uint ownerId()
const;
153 QString group()
const;
154 uint groupId()
const;
156 bool permission(QFile::Permissions permissions)
const;
157 QFile::Permissions permissions()
const;
161 QDateTime birthTime()
const {
return fileTime(QFile::FileBirthTime); }
162 QDateTime metadataChangeTime()
const {
return fileTime(QFile::FileMetadataChangeTime); }
163 QDateTime lastModified()
const {
return fileTime(QFile::FileModificationTime); }
164 QDateTime lastRead()
const {
return fileTime(QFile::FileAccessTime); }
165 QDateTime fileTime(QFile::FileTime time)
const;
167 QDateTime birthTime(
const QTimeZone &tz)
const {
return fileTime(QFile::FileBirthTime, tz); }
168 QDateTime metadataChangeTime(
const QTimeZone &tz)
const {
return fileTime(QFile::FileMetadataChangeTime, tz); }
169 QDateTime lastModified(
const QTimeZone &tz)
const {
return fileTime(QFile::FileModificationTime, tz); }
170 QDateTime lastRead(
const QTimeZone &tz)
const {
return fileTime(QFile::FileAccessTime, tz); }
171 QDateTime fileTime(QFile::FileTime time,
const QTimeZone &tz)
const;
173 bool caching()
const;
174 void setCaching(
bool on);
178 QSharedDataPointer<QFileInfoPrivate> d_ptr;
181 friend Q_CORE_EXPORT
bool comparesEqual(
const QFileInfo &lhs,
const QFileInfo &rhs);
182 Q_DECLARE_EQUALITY_COMPARABLE_NON_NOEXCEPT(QFileInfo)
183 QFileInfoPrivate* d_func();
184 inline const QFileInfoPrivate* d_func()
const
186 return d_ptr.constData();