Home  /  Autodocs  /  dos.library

NAME

Flush
Flushes buffers for a buffered FileHandle (V36)

SYNOPSIS

success = Flush(fh)
D0 D1

LONG Flush(BPTR)

FUNCTION

Flushes any pending buffered writes to the FileHandle. All buffered writes will also be flushed on Close(). If the FileHandle was being used for input, it drops the buffer, and tries to Seek() back to the last read position (so subsequent reads or writes will occur at the expected position in the file).

INPUTS

fh
Filehandle to flush.

RESULT

success
Success or failure.

BUGS

Before V37 release, Flush() returned a random value. As of V37, it always returns success (this will be fixed in some future release).

The V36 and V37 releases didn't properly flush filehandles which have never had a buffered IO done on them. This commonly occurs on redirection of input of a command, or when opening a file for input and then calling CreateNewProc() with NP_Arguments, or when using a new FileHandle with SelectInput() and then calling RunCommand(). This is fixed in V39. A workaround would be to do FGetC(), then UnGetC(), then Flush().

SEE ALSO

FPutC(), FGetC(), UnGetC(), Seek(), Close(), CreateNewProc(), SelectInput(), RunCommand()