QFSFileEngine: handle refreshing of file times better

Clear the known times when we write to it and always refresh for the
Access time.

Change-Id: I8d96dea9955d4c749b99fffd14cd6c03b4253197
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
This commit is contained in:
Thiago Macieira 2017-07-01 22:23:34 -07:00
parent 8e40050efe
commit 48e35e06ca
3 changed files with 20 additions and 20 deletions

View File

@ -524,6 +524,25 @@ bool QFSFileEngine::seek(qint64 pos)
return d->nativeSeek(pos);
}
/*!
\reimp
*/
QDateTime QFSFileEngine::fileTime(FileTime time) const
{
Q_D(const QFSFileEngine);
if (time == AccessTime) {
// always refresh for the access time
d->metaData.clearFlags(QFileSystemMetaData::AccessTime);
}
if (d->doStat(QFileSystemMetaData::Times))
return d->metaData.fileTime(time);
return QDateTime();
}
/*!
\internal
*/
@ -708,6 +727,7 @@ qint64 QFSFileEnginePrivate::readLineFdFh(char *data, qint64 maxlen)
qint64 QFSFileEngine::write(const char *data, qint64 len)
{
Q_D(QFSFileEngine);
d->metaData.clearFlags(QFileSystemMetaData::Times);
// On Windows' stdlib implementation, the results of calling fread and
// fwrite are undefined if not called either in sequence, or if preceded

View File

@ -699,16 +699,6 @@ bool QFSFileEngine::setFileTime(const QDateTime &newDate, FileTime time)
#endif
}
QDateTime QFSFileEngine::fileTime(FileTime time) const
{
Q_D(const QFSFileEngine);
if (d->doStat(QFileSystemMetaData::Times))
return d->metaData.fileTime(time);
return QDateTime();
}
uchar *QFSFileEnginePrivate::map(qint64 offset, qint64 size, QFile::MemoryMapFlags flags)
{
#if (defined(Q_OS_LINUX) || defined(Q_OS_ANDROID)) && Q_PROCESSOR_WORDSIZE == 4

View File

@ -947,16 +947,6 @@ bool QFSFileEngine::setFileTime(const QDateTime &newDate, FileTime time)
return true;
}
QDateTime QFSFileEngine::fileTime(FileTime time) const
{
Q_D(const QFSFileEngine);
if (d->doStat(QFileSystemMetaData::Times))
return d->metaData.fileTime(time);
return QDateTime();
}
uchar *QFSFileEnginePrivate::map(qint64 offset, qint64 size,
QFile::MemoryMapFlags flags)
{