Name
FSeek -- seek file to new position (V6.0)
Synopsis
DOSINT64 oldpos = FSeek(APTR handle, DOSINT64 pos, int mode);
Function
This function has to seek the file handle's read/write cursor to the specified position. Additionally, it has to return the position of the read/write cursor before the seek operation. The specified position is relative to the seek mode passed in parameter 3. This can be one of the following modes:

HWFSEEKMODE_CURRENT:
New seek position is relative to the current position.

HWFSEEKMODE_BEGINNING:
New seek position is relative to the beginning of the file.

HWFSEEKMODE_END:
New seek position is relative to the end of the file.

Note that FSeek() is often called with a 0 zero position and HWFSEEKMODE_CURRENT to query the position of the read/write cursor.

If there was an error, FSeek() has to return -1.

If you set the HWFOPENFLAGS_NOSEEK flag in your FOpen() implementation, your FSeek() implementation only has to support rewinding the file and querying the position of the cursor. In terms of code, this means that FSeek() only has to support the following two operations if HWFOPENFLAGS_NOSEEK is set:

 
FSeek(fh, 0, HWFSEEKMODE_BEGINNING);     // rewind
pos = FSeek(fh, 0, HFSEEKMODE_CURRENT);  // query cursor position

For any other operation, it has to return -1, i.e. an error has occurred.

This function must be implemented in a thread-safe manner.

Inputs
handle
file handle returned by FOpen()
pos
destination seek position
mode
seek mode (see above)
Results
oldpos
previous position of file cursor or -1 on error

Show TOC