mirror of
https://github.com/CCExtractor/ccextractor.git
synced 2026-02-15 05:26:07 +00:00
Option --forceflush inoperative on Windows #150
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @lelegard on GitHub (May 30, 2016).
Originally assigned to: @cfsmp3 on GitHub.
Hi,
I would like to report an invisible bug with
-ff/--forceflushon Windows. It is "invisible" in the sense that it has no symptom, no crash, but failed to work properly, ie. it does not flush the file.Here is a small patch to fix the problem: ccextractor.0.80.winfsync.patch.zip
The problem is simple. Flush is done using
fync(). This function does not exist on Windows. In filelib_ccx/ccx_encoders_common.c, there is a replacement functionfsync(int fd)forWIN32. This function calls the native Win32 functionFlushFileBuffers(fd). But the problem is thatFlushFileBuffersuses aHANDLEas parameter, not anint, the traditional UNIX file descriptor.So, it is only by chance that
FlushFileBuffersdoes not crash the application. Adding, some traces, we can see thatFlushFileBuffersquite logically fails with errorERROR_INVALID_HANDLE.The valid way to emulate
fsync()on Windows isFlushFileBuffers((HANDLE)_get_osfhandle(fd)). This is what the patch does andFlushFileBuffersno longer fails.@cfsmp3 commented on GitHub (Jun 9, 2016):
Merged.