When is Qfile copy really done?
I am making an internal update script to update the curren program like this:
ui->pushButton_updateWasherFile->setText("File does not exist on card");
ui->pushButton_updateWasherFile->setText("Done (please reboot)");
This works, but I'm not tottaly happy with it, cause when it say's please reboot (so finished) I have to wait a few seconds to make sure the file is written to my NAND memory. If I do an instant reboot, the file is lost, if to fast, then the file is corrupt. This means he is still writing to the memory.
How can I see if it is really finished writing to the NAND?
I'm running in embedded linux 3.3.6 with JSSF2 file system.
You don't know. At least, Qt has no way of knowing this. It is the OS in conjunction with the file system that handles this, and even then there might be additional buffering in the hardware layer. There is no way Qt can know when a file operation is really done. At least, not that I'm aware of.
This seems te be a problem. What is a good way to make sure the file is written then: just wait a x amount of seconds?
That would depend on your OS, I think.
Just an idea that struck me. Try opening the file after x seconds, if it succeeds, it might have been saved. Or even better, try testing with QFileInfo::created(), QFileInfo::lastModified(), etc. Probably some of those would help you determine whether filesystem is ready for reboot. It might vary depending on OS, mind you.
I will test it! Thank you