I am programming win32 using fopen fread fwrite in C.
How can I force windows to write data through to the disk? Is than an API call for this?
I have a program that must absolutely make sure that data is saved to disk before it saves to a different indexing file, otherwise if there are crashes the index file can sometimes update but the other file doesn’t causing a bad inconsistency.
fflush() does what you want. If you decide to use the Win32 APIs to do your file IO instead of the C STDIO lib, then supply the FILE_FLAG_WRITE_THROUGH flag to CreateFile(), which does exactly what you want.