Reputation: 2039
Is QFileInfo
synchronized with source file? Or it just stores information from the time when the instance was created?
In otherwords, if I create QFileInfo
instance for my file. Then I change the file. And then, I create second instance of QFileInfo
for this file, will they have different lastModified value?
Upvotes: 3
Views: 197
Reputation: 2020
QFileInfo is not syncronized, the information is read when the object is created.
I have used this small example to verify it.
If you run this in a terminal and then change the file you will see the date changing when you save the file.
#include <QCoreApplication>
#include <QDebug>
#include <QFileInfo>
#include <QDateTime>
#include <QThread>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
while (1)
{
QFileInfo f("./file.txt");
qDebug() << f.lastModified().toString();
QThread::sleep ( 1 );
}
return a.exec();
}
Upvotes: 5