Warning, file /include/QtCore/qfileinfo.h was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004 #ifndef QFILEINFO_H
0005 #define QFILEINFO_H
0006
0007 #include <QtCore/qfile.h>
0008 #include <QtCore/qlist.h>
0009 #include <QtCore/qshareddata.h>
0010 #include <QtCore/qmetatype.h>
0011 #include <QtCore/qdatetime.h>
0012 #include <QtCore/qtimezone.h>
0013
0014 QT_BEGIN_NAMESPACE
0015
0016
0017 class QDir;
0018 class QDirIteratorPrivate;
0019 class QFileInfoPrivate;
0020
0021 class Q_CORE_EXPORT QFileInfo
0022 {
0023 friend class QDirIteratorPrivate;
0024 public:
0025 explicit QFileInfo(QFileInfoPrivate *d);
0026
0027 #ifdef QT_IMPLICIT_QFILEINFO_CONSTRUCTION
0028 #define QFILEINFO_MAYBE_EXPLICIT Q_IMPLICIT
0029 #else
0030 #define QFILEINFO_MAYBE_EXPLICIT explicit
0031 #endif
0032
0033 QFileInfo();
0034 QFILEINFO_MAYBE_EXPLICIT QFileInfo(const QString &file);
0035 QFILEINFO_MAYBE_EXPLICIT QFileInfo(const QFileDevice &file);
0036 QFILEINFO_MAYBE_EXPLICIT QFileInfo(const QDir &dir, const QString &file);
0037 QFileInfo(const QFileInfo &fileinfo);
0038 #ifdef Q_QDOC
0039 QFileInfo(const std::filesystem::path &file);
0040 QFileInfo(const QDir &dir, const std::filesystem::path &file);
0041 #elif QT_CONFIG(cxx17_filesystem)
0042 template<typename T, QtPrivate::ForceFilesystemPath<T> = 0>
0043 QFILEINFO_MAYBE_EXPLICIT QFileInfo(const T &file) : QFileInfo(QtPrivate::fromFilesystemPath(file)) { }
0044
0045 template<typename T, QtPrivate::ForceFilesystemPath<T> = 0>
0046 QFILEINFO_MAYBE_EXPLICIT QFileInfo(const QDir &dir, const T &file) : QFileInfo(dir, QtPrivate::fromFilesystemPath(file))
0047 {
0048 }
0049 #endif
0050
0051 #undef QFILEINFO_MAYBE_EXPLICIT
0052
0053 ~QFileInfo();
0054
0055 QFileInfo &operator=(const QFileInfo &fileinfo);
0056 QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QFileInfo)
0057
0058 void swap(QFileInfo &other) noexcept
0059 { d_ptr.swap(other.d_ptr); }
0060
0061 bool operator==(const QFileInfo &fileinfo) const;
0062 inline bool operator!=(const QFileInfo &fileinfo) const { return !(operator==(fileinfo)); }
0063
0064 void setFile(const QString &file);
0065 void setFile(const QFileDevice &file);
0066 void setFile(const QDir &dir, const QString &file);
0067 #ifdef Q_QDOC
0068 void setFile(const std::filesystem::path &file);
0069 #elif QT_CONFIG(cxx17_filesystem)
0070 template<typename T, QtPrivate::ForceFilesystemPath<T> = 0>
0071 void setFile(const T &file) { setFile(QtPrivate::fromFilesystemPath(file)); }
0072 #endif
0073
0074 bool exists() const;
0075 static bool exists(const QString &file);
0076 void refresh();
0077
0078 QString filePath() const;
0079 QString absoluteFilePath() const;
0080 QString canonicalFilePath() const;
0081 #if QT_CONFIG(cxx17_filesystem) || defined(Q_QDOC)
0082 std::filesystem::path filesystemFilePath() const
0083 { return QtPrivate::toFilesystemPath(filePath()); }
0084 std::filesystem::path filesystemAbsoluteFilePath() const
0085 { return QtPrivate::toFilesystemPath(absoluteFilePath()); }
0086 std::filesystem::path filesystemCanonicalFilePath() const
0087 { return QtPrivate::toFilesystemPath(canonicalFilePath()); }
0088 #endif
0089 QString fileName() const;
0090 QString baseName() const;
0091 QString completeBaseName() const;
0092 QString suffix() const;
0093 QString bundleName() const;
0094 QString completeSuffix() const;
0095
0096 QString path() const;
0097 QString absolutePath() const;
0098 QString canonicalPath() const;
0099 #if QT_CONFIG(cxx17_filesystem) || defined(Q_QDOC)
0100 std::filesystem::path filesystemPath() const { return QtPrivate::toFilesystemPath(path()); }
0101 std::filesystem::path filesystemAbsolutePath() const
0102 { return QtPrivate::toFilesystemPath(absolutePath()); }
0103 std::filesystem::path filesystemCanonicalPath() const
0104 { return QtPrivate::toFilesystemPath(canonicalPath()); }
0105 #endif
0106 QDir dir() const;
0107 QDir absoluteDir() const;
0108
0109 bool isReadable() const;
0110 bool isWritable() const;
0111 bool isExecutable() const;
0112 bool isHidden() const;
0113 bool isNativePath() const;
0114
0115 bool isRelative() const;
0116 inline bool isAbsolute() const { return !isRelative(); }
0117 bool makeAbsolute();
0118
0119 bool isFile() const;
0120 bool isDir() const;
0121 bool isSymLink() const;
0122 bool isSymbolicLink() const;
0123 bool isShortcut() const;
0124 bool isAlias() const;
0125 bool isJunction() const;
0126 bool isRoot() const;
0127 bool isBundle() const;
0128
0129 QString symLinkTarget() const;
0130 QString readSymLink() const;
0131 QString junctionTarget() const;
0132
0133 #if QT_CONFIG(cxx17_filesystem) || defined(Q_QDOC)
0134 std::filesystem::path filesystemSymLinkTarget() const
0135 { return QtPrivate::toFilesystemPath(symLinkTarget()); }
0136
0137 std::filesystem::path filesystemReadSymLink() const
0138 { return QtPrivate::toFilesystemPath(readSymLink()); }
0139
0140 std::filesystem::path filesystemJunctionTarget() const
0141 { return QtPrivate::toFilesystemPath(junctionTarget()); }
0142 #endif
0143
0144 QString owner() const;
0145 uint ownerId() const;
0146 QString group() const;
0147 uint groupId() const;
0148
0149 bool permission(QFile::Permissions permissions) const;
0150 QFile::Permissions permissions() const;
0151
0152 qint64 size() const;
0153
0154 QDateTime birthTime() const { return fileTime(QFile::FileBirthTime); }
0155 QDateTime metadataChangeTime() const { return fileTime(QFile::FileMetadataChangeTime); }
0156 QDateTime lastModified() const { return fileTime(QFile::FileModificationTime); }
0157 QDateTime lastRead() const { return fileTime(QFile::FileAccessTime); }
0158 QDateTime fileTime(QFile::FileTime time) const;
0159
0160 QDateTime birthTime(const QTimeZone &tz) const { return fileTime(QFile::FileBirthTime, tz); }
0161 QDateTime metadataChangeTime(const QTimeZone &tz) const { return fileTime(QFile::FileMetadataChangeTime, tz); }
0162 QDateTime lastModified(const QTimeZone &tz) const { return fileTime(QFile::FileModificationTime, tz); }
0163 QDateTime lastRead(const QTimeZone &tz) const { return fileTime(QFile::FileAccessTime, tz); }
0164 QDateTime fileTime(QFile::FileTime time, const QTimeZone &tz) const;
0165
0166 bool caching() const;
0167 void setCaching(bool on);
0168 void stat();
0169
0170 protected:
0171 QSharedDataPointer<QFileInfoPrivate> d_ptr;
0172
0173 private:
0174 QFileInfoPrivate* d_func();
0175 inline const QFileInfoPrivate* d_func() const
0176 {
0177 return d_ptr.constData();
0178 }
0179 };
0180
0181 Q_DECLARE_SHARED(QFileInfo)
0182
0183 typedef QList<QFileInfo> QFileInfoList;
0184
0185 #ifndef QT_NO_DEBUG_STREAM
0186 Q_CORE_EXPORT QDebug operator<<(QDebug, const QFileInfo &);
0187 #endif
0188
0189 QT_END_NAMESPACE
0190
0191 QT_DECL_METATYPE_EXTERN(QFileInfo, Q_CORE_EXPORT)
0192
0193 #endif