The mi_file_seek() function
The mi_file_seek() function sets the file seek position for the next read or write operation on the open file.
Syntax
mi_integer mi_file_seek(fd, offset, whence)
mi_integer fd;
mi_integer offset;
mi_integer whence;
- fd
- The file descriptor for the operating-system file on which to set the seek position. The file descriptor is obtained by a previous call to the mi_file_open() function.
- offset
- A pointer to the integer offset from the specified whence seek position.
- whence
- This value determines how to interpret the offset value.
Valid in client LIBMI application? | Valid in user-defined routine? |
---|---|
Yes | Yes |
Usage
The mi_file_seek() function
uses the whence and offset arguments to determine the
new seek position of the file that fd identifies, as follows:
- The whence argument identifies the position from which
to start the seek operation.Valid values include the following whence constants for both client and server files.
- Whence constant
- Starting seek position
- SEEK_SET
- Set position equal to offset bytes
- SEEK_CUR
- Set position to current location plus offset
- SEEK_END
- Set position to EOF plus offset
- The offset argument identifies the offset, in bytes, from
the starting seek position (which the whence argument specifies)
at which to begin the seek.
This offset value can be negative for all values of whence. To obtain the current seek position for an open smart large object, use the mi_file_tell() function.
Server only: In a C UDR, this
function can move to a new seek position in a file that resides on
either the server or client computer. You specify the location of
the file when you open it with the mi_file_open() function.
Return values
- >=0
- The new seek position, measured in number of bytes from the beginning of the file.
- MI_ERROR
- The function was not successful.
The mi_file_seek() function does not throw an MI_Exception event when it encounters a runtime error. Therefore, it does not cause callbacks to start.