The mi_file_write() function

The mi_file_write() function writes a specified number of bytes to an open operating-system file.

Syntax

mi_integer mi_file_write(fd, buf, nbytes)
   mi_integer fd;
   const char *buf;
   mi_integer nbytes;
fd
The file descriptor of the file to write to. The file descriptor is obtained by a previous call to mi_file_open().
buf
A pointer to a user-allocated character buffer of at least nbytes bytes that contains the data to write to the file.
nbytes
The maximum number of bytes to write to the file.
Valid in client LIBMI application? Valid in user-defined routine?
Yes Yes

Usage

The mi_file_write() function writes nbytes bytes of data to the file that the fd file descriptor identifies. The write 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 writes this data from the user-allocated buffer that buf references.

Server only: In a C UDR, this function can write to 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 written from the h to the open file.
MI_ERROR
The function was not successful.

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