mmioRead
Appearance
The mmioRead function reads from a file opened by mmioOpen and updates the file position.
Syntax
#define INCL_MMIOOS2 #include <os2.h> LONG mmioRead(HMMIO hmmio, PCHAR pchBuffer, LONG cBytes);
Parameters
- pchBuffer (PCHAR) - input
- The buffer to read to.
- cBytes (LONG) - input
- The number of bytes to read from the file into the pchBuffer parameter.
Return Value
- rc (LONG) - returns
- Returns the number of bytes actually read. If no more bytes can be read because the end of file has been reached, 0 is returned. If an error occurs, `MMIO_ERROR` is returned. A call to mmioGetLastError might return one of the following errors:
- MMIOERR_WRITE_ONLY_FILE: File not opened in Read mode.
- MMIOERR_READ_FAILED: Unable to read; probable hardware error.
- MMIOERR_WRITE_FAILED: Writing to a full buffer before trying to read the next buffer failed.
- MMIOERR_SEEK_FAILED: Unable to seek; probable hardware error.
- MMIOERR_INVALID_BUFFER_LENGTH: The buffer length is invalid.
- MMIOERR_NO_BUFFER_ALLOCATED: Write operation expected a buffer but none was allocated.
Remarks
If the `MMIO_TRANSLATEDATA` flag was in the ulTranslate field of the MMIOINFO structure when the file was opened, the data will be translated from its native encoding scheme to the encoding scheme of the standard presentation format for the media type. Data in the pchBuffer parameter is returned to the application in the standard presentation format.
With images, for example, the standard data presentation format is uncompressed OS/2 bit-map data. For audio, the standard presentation is PCM data. The data will conform to the definition found in the media header supplied by mmioGetHeader.
Example Code
The following code illustrates how to read from a file.
HMMIO hmmio1;
PCHAR pchBuffer;
LONG cBytes;
LONG lBytesRead;
...
lBytesRead = mmioRead(hmmio1, pchBuffer, cBytes);
if (lBytesRead < 0L)
/* error */
else
{
/* lBytesRead contains the number of bytes read */
}
...