Collection of file manipulation tools, including File I/O designed to directly replace stdio, using MFile* in place of FILE*.
Opens a file stream with the name specified by path. The argument mode should be a string containing one of the following modes:
|"r"||read only, start at the beginning of the file|
|"w"||write only, erase existing file and start at the beginning|
Note: This usually should not be used directly and should be opened from the MFileTools interface
Close a file stream, if open.
Reads count amount of elements of data, each size bytes long, from the file, storing them at the location given by dest. Returns the number of items successfully read. If an error occurs, or the end-of-file is reached, the return value is a short item count (or zero)
Writes count amount of elements of data, each size bytes long, to the file, obtaining them from the location given by str. Returns the number of items successfully written.
Produces output according to the standard printf() style format and writes to the file. Returns the number of characters written to the file (excluding the null byte used to end output strings)
Sets the file position indicator. The new position, measured in bytes, is obtained by adding offset bytes to the position specified by whence. If whence is set to SEEK_SET, SEEK_CUR, or SEEK_END, the offset is relative to the start of the file, the current position indicator, or end-of-file respectively.
Obtains the current value of the file position indicator for the file
Sets the file position indicator to the beginning of the file.
MFile* fp = M_fopen("filename.txt", "r"); M_fseek(fp, 0L, SEEK_END); long size = M_ftell(fp); M_fseek(fp, 0L, SEEK_SET); char* buffer = new char[size]; M_fread(buffer, 1, size, fp); M_fclose(fp); delete  buffer;
Function descriptions adapted from man(3)