mmioSeek
Appearance
The mmioSeek function seeks within a file that was opened using mmioOpen.
Syntax
#define INCL_MMIOOS2 #include <os2.h> LONG mmioSeek(HMMIO hmmio, LONG lOffset, LONG lOrigin);
Parameters
- lOffset (LONG) - input
- Specifies an offset, in bytes, to move the file position to.
- lOrigin (LONG) - input
- Specifies how the lOffset parameter is interpreted:
- SEEK_SET: Seek to an absolute (bytes from the beginning of the file) seek position specified in the lOffset parameter. This is the default.
- SEEK_CUR: Seek to a relative (bytes from the current file position) seek position specified in the lOffset parameter.
- SEEK_END: Seek to lOffset bytes from the end of the file.
- MMIO_SEEK_IFRAME: Seek to the nearest I-frame based on one of the previous flags. This flag can only be used with digital video-only data tracks (or files).
Return Value
- rc (LONG) - returns
- Returns the new file position (in bytes) from the beginning of the file. If an error occurs, `MMIO_ERROR` is returned. A call to mmioGetLastError might return the following error:
- MMIOERR_SEEK_FAILED: Probable hardware error.
Remarks
Seeking past the end of the file does not result in an error; **mmioSeek** will return the offset of the new file position. Be careful when seeking past the end of the file. To determine where the end of a file is, call **mmioSeek** with the lOffset parameter equal to 0 and the lOrigin parameter equal to `SEEK_END`.
> Note: It is invalid to seek backwards (negative) from the beginning of the file.
In the case of a user-supplied memory (MEM) file, a `SEEK_END` will seek from the end of the buffer, which might be different from the actual end of the data.
Example Code
The following code illustrates how to seek to the end of a file to determine its size.
HMMIO hmmio1;
LONG lOffset;
LONG lOrigin = 0L;
LONG lFilePosition;
...
lOffset = 0L;
lOrigin = SEEK_END;
lFilePosition = mmioSeek(hmmio1, lOffset, lOrigin);
if (lFilePosition == MMIO_ERROR)
{
/* error */
}
else
{
/* lFilePosition contains the size of the file in bytes */
}
...