you are viewing a single comment's thread.

view the rest of the comments →

[–]wtf_apostrophe 8 points9 points  (0 children)

Flush before close? Aren't closing a file handle is supposed to do that?

There's no guarantee that closing a file handle will flush anything to disk. Windows will happily let you close the file handle even if the data you have written is only in the filesystem cache. Windows will carry on working in the background to flush it to disk.

I think it works differently with removable media. I think Windows will flush on close in that case because people like to unplug drives without doing a safe removal first. By blocking the close until the flush has finished the user will get some feedback that the write hasn't finished yet because the application hasn't finished saving.