[Qt-interest] QFile and fsynch(): how does it handle it?

Rui Maciel rui.maciel at gmail.com
Wed Nov 25 17:56:00 CET 2009


Marco Borm wrote:

> The point is that if you want to write into file: just do it.
> Syncing every file operation wastes performances without any benefit in
> _nearly_ any situation.

Yes, but that wasn't the intended objective. The point of this whole thread was 
that QFile doesn't offer the programmer a fsync() method and neither ensures that 
the data is committed to disk. But thankfully (someone correct me if I'm wrong) it 
appears to be possible to fsync() using the file handle returned by 
QFile::handle(), which mitigates this.


> What do you think happens if you system crashes while fsync() is
> running? You can not prevent losing data which isn't written to disk and
> because your PC has a RAM this is always the case.

That wasn't the point.


> The only situation where you have to sync is before starting a operation
> which depends on the successful completion of a previous one. In that
> case you have to sync to take sure that the other operation is "on
> disk". Because Qt doesn't know what you indention is, it can't sync for
> you. Unfortunately, and that is bad, there is also no Qt sync function you
> can call yourself.

That was exactly the point.


Rui Maciel




More information about the Qt-interest-old mailing list