J
JG
Does anyone know a standard (or supported on Linux, Mac, Win32) way to
clear a read stream buffer (standard ANSI C file stream)?
I would even settle for a platform specific way of doing it.
And no, I know I can use direct low level I/O or non-buffered to do
reads, but for my app, I need the buffering. I can implement myself,
but this is not optimal.
Example, I open a read only file using fopen(). I periodically know
from external methods, that the underlying file has been updated.
Before I do my next read on the stream, I want to flush the read
buffers and force it to read from disk (or kernel cache).
fflush seems to work on Linux, but not sure it is standard.
I don't see any function to do this, but it seems very needed.
I can also trigger a flush of the buffers by fseeking to a much
different area of the file. Does any fseek, even offseting by 1 index
always force a flusshing of the buffers?
clear a read stream buffer (standard ANSI C file stream)?
I would even settle for a platform specific way of doing it.
And no, I know I can use direct low level I/O or non-buffered to do
reads, but for my app, I need the buffering. I can implement myself,
but this is not optimal.
Example, I open a read only file using fopen(). I periodically know
from external methods, that the underlying file has been updated.
Before I do my next read on the stream, I want to flush the read
buffers and force it to read from disk (or kernel cache).
fflush seems to work on Linux, but not sure it is standard.
I don't see any function to do this, but it seems very needed.
I can also trigger a flush of the buffers by fseeking to a much
different area of the file. Does any fseek, even offseting by 1 index
always force a flusshing of the buffers?