BFILE library: bfread() - buffered file read

Name

bfread() - buffered file read

Synopsis

#include "bfile.h"

int bfread(BFILE *bfp,
	size_t *nread,
	void *ptr,
	size_t size);

Decription

The bfread() function reads data from an open file. The BFILE must have been set up with bfsetup() and must not be in an error condition. Up to size bytes are read and stored at the memory area pointed to by ptr. The number of bytes actually read is stored at *nread. If the end-of-file has already been reached, no data will be read, so *nread will be zero. This is not an error. If bfread() is called again, another attempt will be made to read data. Note that the number of bytes read is independent of whether or not an error occurred, since some data may have been read before the error occurred. If an error occurs, the BFILE is put into an error condition, which can only be cleared by bferror().

Return value

Returns 0 if successful, or an errno value otherwise.

See also

bfile(), bfile_dtor(), bferror(), bfsetup().


This function is part of the BFILE library.