Question

Does the Boost library provide something similar to fsync()?

Motivation: to be portable beyond POSIX - e.g. such that on Windows a similar function is used.

No correct solution

OTHER TIPS

No, boost has no such thing. And as mentioned by brian beuning in the comments, synchronising the OS to the device is very much OS-dependent.

However you don’t have to call the Windows APIs directly as the Microsoft’s C runtime library does have fsync(). It has been named _commit, and you remain quite portable as you can continue to work with file descriptors instead of having to change your code to work with Windows HANDLEs.

You can introduce your own portability helper along the lines of:

ifdef __WINDOWS__
#include <io.h>
#define fsync  _commit
endif
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top