fflush()ing libcurl's FILE* for the file:// protocol...
Date: Wed, 03 Oct 2012 14:46:18 +0200
I have been using libcurl to write to the file system (and other
protocols of course), and now I have hit a problem.
There are callbacks for libcurl to call: READFUNCTION and WRITEFUNCTION
that read/write data from the remote host. In the case of file:// only
READFUNCTION is really used. Now my problem is that libcurl makes use of
FILE* internally which is fine. But my READFUNCTION can't know whether
all the data has been received yet (this might take several seconds,
after which READFUNCTION will realize that, yes it has provided all data
and return 0). The data that has already been provided by prior calls to
READFUNCTION will never reach the file system until READFUNCTION returns
0 and the FILE* is closed. The reason for this if of course that FILE*
has an internal buffer. And basically I want to be able to control when
this buffer is flushed to force the data to be written to disk prior to
my READFUNCTION realizing that all data has already been provided.
So therefore I propose that a new return value for READFUNCTION is added
which instructs libcurl to call fflush() on the FILE*, thereby forcing
the data to the file system. Does anyone have any opinion on this? Also
does this draft patch adhere to the design philosophy of libcurl? I'm
happy to improve my draft patch to a state where it can be included, so
I'd really like you review comments and opinions. :)
- text/x-patch attachment: libcurl-fflush.diff