The mi_file_read() function

The mi_file_read() function reads a specified number of bytes from an open operating-system file into a buffer.

Syntax

mi_integer mi_file_read(fd, buf, nbytes)
   mi_integer fd;
   char *buf;
   mi_integer nbytes;
fd
The file descriptor of the file from which to read the data. The file descriptor is obtained by a previous call to the mi_file_open() function.
buf
A pointer to a user-allocated character buffer to contain the data read from the file.
nbytes
The maximum number of bytes to read into the buf character buffer.
Valid in client LIBMI application? Valid in user-defined routine?
Yes Yes

Usage

The mi_file_read() function reads nbytes bytes of data from the file that the fd file descriptor identifies. The read begins at the current file seek position for fd. You can use the mi_file_tell() function to obtain the current seek position. The function reads this data into the user-allocated buffer that buf references.

Server only: In a C UDR, this function can read from files 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 actual number of bytes that the function has read from the open file to the buf character buffer.
MI_ERROR
The function was not successful.

The mi_file_read() function does not throw an MI_Exception event when it encounters a runtime error. Therefore, it does not cause callbacks to start.