Is there an alternative to fsync for windows? (C++ builder)
Fsync required to include unistd.h and it's only for unix systems
Thanks!
Is there an alternative to fsync for windows? (C++ builder)
Fsync required to include unistd.h and it's only for unix systems
Thanks!
_commit
looks about right, it takes a file descriptor just like fsync
does:
The _commit function forces the operating system to write the file associated with fd to disk. This call ensures that the specified file is flushed immediately, not at the operating system's discretion.
FlushFileBuffers
–
Mahaffey The fflush
function may do what you need, but it only applies to file handles.
Alternately, FlushFileBuffers
may work for you, but it's Windows specific.
fflush
is meant to work on FILE *
types, so you should be good to go. –
Siloxane fsync
or fflush
does at all. You might want to open a new question and include that specific information. –
Siloxane fflush
flushes the program's I/O buffers to the kernel syscalls. It does not emulate or call fsync
or FlushFileBuffers
, both of which make sure that the kernel has written its buffers to disk. This is an important distinction. –
Tercel From the man-page:
fflush() forces a write of all user-space buffered data for the given output or update stream via the stream's underlying write function.
The mentioned write function tells the operating system what the contents of the file should be. At this point all changes will be held in filesystem caches before actually being committed to disk.
The POSIX function fsync()
tells the operating system to sync all changes from its caches to disk. As others have said you can use FlushFileBuffers
on the Windows platform.
© 2022 - 2024 — McMap. All rights reserved.
FlushFileBuffers
? – King