summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qfileinfo.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/io/qfileinfo.cpp')
-rw-r--r--src/corelib/io/qfileinfo.cpp59
1 files changed, 55 insertions, 4 deletions
diff --git a/src/corelib/io/qfileinfo.cpp b/src/corelib/io/qfileinfo.cpp
index 12fd7d3048..baac3117ea 100644
--- a/src/corelib/io/qfileinfo.cpp
+++ b/src/corelib/io/qfileinfo.cpp
@@ -42,6 +42,7 @@
#include "qglobal.h"
#include "qdir.h"
#include "qfileinfo_p.h"
+#include "qdebug.h"
QT_BEGIN_NAMESPACE
@@ -262,8 +263,8 @@ QDateTime &QFileInfoPrivate::getFileTime(QAbstractFileEngine::FileTime request)
info objects, just append one to the file name given to the constructors
or setFile().
- The file's dates are returned by created(), lastModified() and
- lastRead(). Information about the file's access permissions is
+ The file's dates are returned by created(), lastModified(), lastRead() and
+ fileTime(). Information about the file's access permissions is
obtained with isReadable(), isWritable() and isExecutable(). The
file's ownership is available from owner(), ownerId(), group() and
groupId(). You can examine a file's permissions and ownership in a
@@ -1324,7 +1325,7 @@ QDateTime QFileInfo::created() const
/*!
Returns the date and local time when the file was last modified.
- \sa created(), lastRead()
+ \sa created(), lastRead(), fileTime()
*/
QDateTime QFileInfo::lastModified() const
{
@@ -1346,7 +1347,7 @@ QDateTime QFileInfo::lastModified() const
On platforms where this information is not available, returns the
same as lastModified().
- \sa created(), lastModified()
+ \sa created(), lastModified(), fileTime()
*/
QDateTime QFileInfo::lastRead() const
{
@@ -1363,6 +1364,45 @@ QDateTime QFileInfo::lastRead() const
}
/*!
+ \enum QFileInfo::FileTime
+ \since 5.10
+
+ This enum is used by the fileTime() function.
+
+ \value FileCreationTime When the file was created (not supported on UNIX).
+ \value FileModificationTime When the file was most recently modified.
+ \value FileAccessTime When the file was most recently accessed (e.g.
+ read or written to).
+
+ \sa fileTime()
+*/
+
+/*!
+ \since 5.10
+ Returns the file time specified by \a time.
+ If the time cannot be determined return QDateTime() (an invalid
+ date time).
+
+ \sa FileTime, QDateTime::isValid()
+*/
+QDateTime QFileInfo::fileTime(QFileInfo::FileTime time) const
+{
+ switch (time) {
+ case QFileInfo::FileCreationTime:
+ return created();
+
+ case QFileInfo::FileModificationTime:
+ return lastModified();
+
+ case QFileInfo::FileAccessTime:
+ return lastRead();
+
+ default:
+ Q_UNREACHABLE();
+ }
+}
+
+/*!
\internal
*/
QFileInfoPrivate* QFileInfo::d_func()
@@ -1406,4 +1446,15 @@ void QFileInfo::setCaching(bool enable)
Synonym for QList<QFileInfo>.
*/
+#ifndef QT_NO_DEBUG_STREAM
+QDebug operator<<(QDebug dbg, const QFileInfo &fi)
+{
+ QDebugStateSaver saver(dbg);
+ dbg.nospace();
+ dbg.noquote();
+ dbg << "QFileInfo(" << QDir::toNativeSeparators(fi.filePath()) << ')';
+ return dbg;
+}
+#endif
+
QT_END_NAMESPACE