file_load(char* name,void* buffer,long* size)

Opens the file with the given name, reads it into the buffer, and closes the file.

Parameters:

name - file name, or NULL for deallocating the given buffer.
buffer - pointer to a preallocated buffer, or NULL. If NULL is given, a buffer is allocated by the engine.
size - pointer to a long variable, set to the file length, or NULL.

Returns:

Pointer to the buffer, or NULL if the instruction failed.

Modifies:

buffer, size

Remarks:

Speed:

slow

Example:

void* pTerrain = file_load("terrain.hmp",NULL,&size);
add_buffer("terrain1.hmp",pTerrain,size); ... file_load(NULL,pTerrain,NULL); // free the buffer before exiting the application. ... STRING* find_pathname(STRING* filename) { int size = 0; file_load(chr_(filename),&size,&size); if (size > 0) return path_name; else return NULL; // file not found in path }

See also:

file_save, add_buffer ► latest version online