ReadFile

Reads a file or a portion of one into memory

Synopsis

int ReadFile (char *filename, int32 size, long *buffer, long offset)

Description

ReadFile() uses the file system to read a file or a portion of a file into memory. It performs up to four retries on each block read if the filesystem returns an error.

ReadFile() is useful for loading a portion of a file, optionally starting at some offset into the file. For loading an entire file starting at offset zero, the LoadFile() function is three to four times faster.

ReadFile() fills the buffer with size bytes, beginning at offset.

Arguments

filename
Pointer to a string containing a valid pathname for a file in the currently mounted file system.
size
Number of bytes to read.
buffer
Pointer to a buffer into which the data will be read. Must be large enough to hold size bytes.
offset
Offset from the beginning of the file at which the read begins.

Return Value

The number of bytes read, or -1 if an error occurred.

Associated Files

lib3do.lib, parse3do.h

See Also

LoadFile