Pregunta

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 hay solución correcta

Otros consejos

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
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top