Is there a way to flush a buffer into a file atomically?
By โatomicโ I mean: if, for example, someone terminates my application during recording, I would like to have the file in the state before or after the recording, but not in the damaged intermediate state.
If the answer is no, maybe this can be done with really small buffers? For example, can I unload 2 consecutive int32_t variables with one 8 bytes of fwrite (on the x64 platform) and make sure that both of these int32s are reset or not one of them, but not only one of them?
source share