-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement File#fsync on Windows #9257
Conversation
This issue was closed by mistake. I removed kubo:file-fsync-on-windows branch on my repository and it made this PR closed. |
Why is it better to use _commit instead of the public API FlushFileBuffers ? |
Does this sentence imply that |
I will rephrase. Why is _commit preferred instead of FlushFileBuffers? Since CreateFileW is used to create the handle and FlushFileBuffers is the suggested function to use, it seems strange to me to use _commit. Does it do something else that is needed or they are aliases? |
I use I have no other reasons to use private def system_fsync(flush_metadata = true) : Nil
if LibC.FlushFileBuffers(windows_handle) == 0
raise IO::Error.from_winerror("Error syncing file")
end
end
|
Ok, thanks for the explanation 🙇 |
It's intended that we migrate from the "half-posix" file API to the full windows API. I used the unix-like wrappers only because of the ease of storing a fd instead of a |
This PR uses
_commit
to implementFile#fsync
on Windows.Metadata is also flushed as
fsync
._commit
callsFlushFileBuffers
internally. (I checked it by looking the source code of crt installed with MSVC.)CreateFileW
document: