82.6.3 Advancing the File I/O Buffer

When you reach the end of the file I/O buffer, you must advance the buffer to fill it from the disk (if you are reading), and flush it to the disk (if you are writing). Use the mmioAdvance function to advance a file I/O buffer. The mmioAdvance function has the following syntax:

UINT mmioAdvance(hmmio, lpmmioinfo, wFlags)

The hmmio parameter specifies the file handle for a file opened for buffered I/O.

The lpmmioinfo parameter specifies a far pointer to an MMIOINFO structure containing information on the I/O buffer for the file.

The wFlags parameter specifies options for the operation. To fill an I/O buffer, use the MMIO_READ flag. To flush an I/O buffer, use the MMIO_WRITE flag. To flush the current buffer and fill it with more data from the file, use both flags.

The return value is zero if the operation is successful; otherwise, the return value specifies an error code.

The following illustrations show how the file I/O buffer is advanced as a file is read or written.

These illustrations are not available for this release

82.6.3.1 Using the MmioAdvance Function

To fill a file I/O buffer from disk, call mmioAdvance with the MMIO_READ flag. If there is not enough data remaining in the file to fill the buffer, the pchEndRead field in the MMIOINFO structure points to the location following the last valid byte in the buffer.

To flush a buffer to disk, first set the MMIO_DIRTY flag in the dwFlags field of the MMIOINFO structure. Then call mmioAdvance with the MMIO_WRITE flag.