MiniGUI's general read/write operation provides a general interface to read from and write to various data source, such as files, memory, and so on.
#define MGUI_RWclose | ( | ctx | ) | (ctx)->close(ctx) |
Closes an MG_RWops object.
This macro close the MG_RWops object pointed to by ctx.
ctx | The pointer to the MG_RWops object. |
Definition at line 315 of file endianrw.h.
#define MGUI_RWeof | ( | ctx | ) | (ctx)->eof(ctx) |
Tests the end-of-file indicator for an data source.
This macro tests the end-of-file indicator for the data source pointed to by ctx.
ctx | The pointer to the MG_RWops object. |
Definition at line 330 of file endianrw.h.
#define MGUI_RWread | ( | ctx, | |||
ptr, | |||||
size, | |||||
n | ) | (ctx)->read(ctx, ptr, size, n) |
Reads data blocks from a data source.
This macro reads up to n objects each of size size from the data source ctx to the area pointed to by ptr.
ctx | The pointer to the MG_RWops object. | |
ptr | The buffer will save the data read. | |
size | The size of each object. | |
n | The number of objects to be read. |
Definition at line 283 of file endianrw.h.
#define MGUI_RWseek | ( | ctx, | |||
offset, | |||||
whence | ) | (ctx)->seek(ctx, offset, whence) |
Seeks an MG_RWops object.
This macro seeks to offset relative to whence.
ctx | The pointer to the MG_RWops object. | |
offset | The offset relative to whence. | |
whence | One of stdio's whence values: |
Definition at line 251 of file endianrw.h.
#define MGUI_RWtell | ( | ctx | ) | (ctx)->seek(ctx, 0, SEEK_CUR) |
Obtains the current value of the position indicator for a data source.
This macro obtains the current value of the position indicator for the data source pointed to by ctx.
ctx | The pointer to the MG_RWops object. |
Definition at line 266 of file endianrw.h.
#define MGUI_RWwrite | ( | ctx, | |||
ptr, | |||||
size, | |||||
n | ) | (ctx)->write(ctx, ptr, size, n) |
Writes data blocks to a data source.
This macro writes exactly n objects each of size size from the area pointed to by ptr to the data source ctx.
ctx | The pointer to the MG_RWops object. | |
ptr | The buffer contains the data to be written. | |
size | The size of each object. | |
n | The number of objects to be written. |
Definition at line 300 of file endianrw.h.
MG_RWops * MGUI_AllocRW | ( | void | ) |
Allocates an uninitialized MG_RWops object.
This function allocates an uninitialized MG_RWops object. You can specify the fields of the structure, and implemente a customized MG_RWops object.
void MGUI_FreeRW | ( | MG_RWops * | area | ) |
Frees an MG_RWops object.
This function frees the MG_RWops object pointed to by area.
area | The pointer to the MG_RWops object. |
void MGUI_InitMemRW | ( | MG_RWops * | area, | |
void * | mem, | |||
int | size | |||
) |
Initializes an MG_RWops object from a block of memory.
This function initializes an MG_RWops object pointed to by area from a block of memory pointed to by mem, which is size bytes long.
area | The pointer to the MG_RWops object. | |
mem | The pointer to the memory block. | |
size | The size of the memory block. |
MG_RWops * MGUI_RWFromFile | ( | const char * | file, | |
const char * | mode | |||
) |
Creates an MG_RWops object from a file.
This function uses the mode specified by mode and opens the file file by using stdio function fopen. If success, this function creates a MG_RWops object and returns it.
file | The file name. | |
mode | The mode will be passed to fopen. |
MG_RWops * MGUI_RWFromFP | ( | FILE * | fp, | |
int | autoclose | |||
) |
Creates an MG_RWops object from an opened stdio FILE object.
This function uses an opened stdio FILE object fp to create a MG_RWops object.
fp | The opened stdio FILE object. | |
autoclose | Indicates whether to close the FILE object when close method is called. |
MG_RWops * MGUI_RWFromMem | ( | void * | mem, | |
int | size | |||
) |
Creates an MG_RWops object from a block of memory.
This function creates an MG_RWops object from a block of memory pointed to by mem, which is size bytes long.
mem | The pointer to the memory block. | |
size | The size of the memory block. |
int MGUI_RWgetc | ( | MG_RWops * | area | ) |
Reads the next character from an data source.
This function reads the next character from the data source pointed to by area, and returns it as an unsigned char cast to an int, or EOF on end of file or error.
area | The pointer to the MG_RWops object. |