📄 group__general__rw__fns.htm
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"><title>MiniGUI V1.6.10 API Reference: General read/write operations</title><link href="doxygen.css" rel="stylesheet" type="text/css"></head><body><!-- Generated by Doxygen 1.4.2 --><div class="qindex"><a class="qindex" href="index.htm">Main Page</a> | <a class="qindex" href="modules.htm">Modules</a> | <a class="qindex" href="classes.htm">Alphabetical List</a> | <a class="qindex" href="annotated.htm">Data Structures</a> | <a class="qindex" href="dirs.htm">Directories</a> | <a class="qindex" href="files.htm">File List</a> | <a class="qindex" href="functions.htm">Data Fields</a> | <a class="qindex" href="globals.htm">Globals</a> | <a class="qindex" href="pages.htm">Related Pages</a></div><h1>General read/write operations<br><small>[<a class="el" href="group__global__fns.htm">Global/general functions</a>]</small></h1><h2>Data Structures</h2><ul><li>struct <a class="el" href="struct__MG__RWops.htm">_MG_RWops</a></ul><h2>Defines</h2><ul><li>#define <a class="el" href="group__general__rw__fns.htm#ga11">MGUI_RWseek</a>(ctx, offset, whence) (ctx)->seek(ctx, offset, whence)<dl class="el"><dd class="mdescRight">Seeks an MG_RWops object. <a href="#ga11"></a><br></dl><li>#define <a class="el" href="group__general__rw__fns.htm#ga12">MGUI_RWtell</a>(ctx) (ctx)->seek(ctx, 0, SEEK_CUR)<dl class="el"><dd class="mdescRight">Obtains the current value of the position indicator for a data source. <a href="#ga12"></a><br></dl><li>#define <a class="el" href="group__general__rw__fns.htm#ga13">MGUI_RWread</a>(ctx, ptr, size, n) (ctx)->read(ctx, ptr, size, n)<dl class="el"><dd class="mdescRight">Reads data blocks from a data source. <a href="#ga13"></a><br></dl><li>#define <a class="el" href="group__general__rw__fns.htm#ga14">MGUI_RWwrite</a>(ctx, ptr, size, n) (ctx)->write(ctx, ptr, size, n)<dl class="el"><dd class="mdescRight">Writes data blocks to a data source. <a href="#ga14"></a><br></dl><li>#define <a class="el" href="group__general__rw__fns.htm#ga15">MGUI_RWclose</a>(ctx) (ctx)->close(ctx)<dl class="el"><dd class="mdescRight">Closes an MG_RWops object. <a href="#ga15"></a><br></dl><li>#define <a class="el" href="group__general__rw__fns.htm#ga16">MGUI_RWeof</a>(ctx) (ctx)->eof(ctx)<dl class="el"><dd class="mdescRight">Tests the end-of-file indicator for an data source. <a href="#ga16"></a><br></dl></ul><h2>Typedefs</h2><ul><li>typedef <a class="el" href="struct__MG__RWops.htm">_MG_RWops</a> <a class="el" href="group__general__rw__fns.htm#ga0">MG_RWops</a></ul><h2>Functions</h2><ul><li>MG_EXPORT <a class="el" href="struct__MG__RWops.htm">MG_RWops</a> * <a class="el" href="group__general__rw__fns.htm#ga1">MGUI_RWFromFile</a> (const char *file, const char *mode)<dl class="el"><dd class="mdescRight">Creates an MG_RWops object from a file. <a href="#ga1"></a><br></dl><li>MG_EXPORT <a class="el" href="struct__MG__RWops.htm">MG_RWops</a> * <a class="el" href="group__general__rw__fns.htm#ga2">MGUI_RWFromFP</a> (FILE *fp, int autoclose)<dl class="el"><dd class="mdescRight">Creates an MG_RWops object from an opened stdio FILE object. <a href="#ga2"></a><br></dl><li>MG_EXPORT <a class="el" href="struct__MG__RWops.htm">MG_RWops</a> * <a class="el" href="group__general__rw__fns.htm#ga3">MGUI_RWFromMem</a> (void *mem, int size)<dl class="el"><dd class="mdescRight">Creates an MG_RWops object from a block of memory. <a href="#ga3"></a><br></dl><li>MG_EXPORT void <a class="el" href="group__general__rw__fns.htm#ga4">MGUI_InitMemRW</a> (<a class="el" href="struct__MG__RWops.htm">MG_RWops</a> *area, void *mem, int size)<dl class="el"><dd class="mdescRight">Initializes an MG_RWops object from a block of memory. <a href="#ga4"></a><br></dl><li>MG_EXPORT <a class="el" href="struct__MG__RWops.htm">MG_RWops</a> * <a class="el" href="group__general__rw__fns.htm#ga5">MGUI_AllocRW</a> (void)<dl class="el"><dd class="mdescRight">Allocates an uninitialized MG_RWops object. <a href="#ga5"></a><br></dl><li>MG_EXPORT void <a class="el" href="group__general__rw__fns.htm#ga6">MGUI_FreeRW</a> (<a class="el" href="struct__MG__RWops.htm">MG_RWops</a> *area)<dl class="el"><dd class="mdescRight">Frees an MG_RWops object. <a href="#ga6"></a><br></dl><li>MG_EXPORT int <a class="el" href="group__general__rw__fns.htm#ga7">MGUI_RWgetc</a> (<a class="el" href="struct__MG__RWops.htm">MG_RWops</a> *area)<dl class="el"><dd class="mdescRight">Reads the next character from an data source. <a href="#ga7"></a><br></dl></ul><hr><a name="_details"></a><h2>Detailed Description</h2>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. <hr><h2>Define Documentation</h2><a class="anchor" name="ga15" doxytag="endianrw.h::MGUI_RWclose"></a><p><table class="mdTable" cellpadding="2" cellspacing="0"> <tr> <td class="mdRow"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top">#define MGUI_RWclose </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">ctx </td> <td class="mdname1" valign="top" nowrap> </td> <td class="md" valign="top"> ) </td> <td class="md" nowrap> (ctx)->close(ctx)</td> </tr> </table> </td> </tr></table><table cellspacing="5" cellpadding="0" border="0"> <tr> <td> </td> <td><p>Closes an MG_RWops object. <p>This macro close the MG_RWops object pointed to by <em>ctx</em>.<p><dl compact><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign="top"></td><td valign="top"><em>ctx</em> </td><td>The pointer to the MG_RWops object.</td></tr> </table></dl><dl compact><dt><b>Returns:</b></dt><dd>Upon successful completion 0 is returned, otherwise non-zero on error.</dd></dl><dl compact><dt><b>See also:</b></dt><dd><a class="el" href="group__general__rw__fns.htm#ga13">MGUI_RWread</a> </dd></dl><p>Definition at line <a class="el" href="endianrw_8h-source.htm#l00314">314</a> of file <a class="el" href="endianrw_8h-source.htm">endianrw.h</a>. </td> </tr></table><a class="anchor" name="ga16" doxytag="endianrw.h::MGUI_RWeof"></a><p><table class="mdTable" cellpadding="2" cellspacing="0"> <tr> <td class="mdRow"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top">#define MGUI_RWeof </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">ctx </td> <td class="mdname1" valign="top" nowrap> </td> <td class="md" valign="top"> ) </td> <td class="md" nowrap> (ctx)->eof(ctx)</td> </tr> </table> </td> </tr></table><table cellspacing="5" cellpadding="0" border="0"> <tr> <td> </td> <td><p>Tests the end-of-file indicator for an data source. <p>This macro tests the end-of-file indicator for the data source pointed to by <em>ctx</em>.<p><dl compact><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign="top"></td><td valign="top"><em>ctx</em> </td><td>The pointer to the MG_RWops object.</td></tr> </table></dl><dl compact><dt><b>Returns:</b></dt><dd>Non-zero if end-of-file indicator is set.</dd></dl><dl compact><dt><b>See also:</b></dt><dd><a class="el" href="group__general__rw__fns.htm#ga12">MGUI_RWtell</a> </dd></dl><p>Definition at line <a class="el" href="endianrw_8h-source.htm#l00329">329</a> of file <a class="el" href="endianrw_8h-source.htm">endianrw.h</a>. </td> </tr></table><a class="anchor" name="ga13" doxytag="endianrw.h::MGUI_RWread"></a><p><table class="mdTable" cellpadding="2" cellspacing="0"> <tr> <td class="mdRow"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top">#define MGUI_RWread </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">ctx, <tr> <td class="md" nowrap align="right"></td> <td class="md"></td> <td class="md" nowrap>ptr, <tr> <td class="md" nowrap align="right"></td> <td class="md"></td> <td class="md" nowrap>size, <tr> <td class="md" nowrap align="right"></td> <td class="md"></td> <td class="md" nowrap>n </td> <td class="mdname1" valign="top" nowrap> </td> <td class="md" valign="top"> ) </td> <td class="md" nowrap> (ctx)->read(ctx, ptr, size, n)</td> </tr> </table> </td> </tr></table><table cellspacing="5" cellpadding="0" border="0"> <tr> <td> </td> <td><p>Reads data blocks from a data source. <p>This macro reads up to <em>n</em> objects each of size <em>size</em> from the data source <em>ctx</em> to the area pointed to by <em>ptr</em>.<p><dl compact><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign="top"></td><td valign="top"><em>ctx</em> </td><td>The pointer to the MG_RWops object. </td></tr> <tr><td valign="top"></td><td valign="top"><em>ptr</em> </td><td>The buffer will save the data read. </td></tr> <tr><td valign="top"></td><td valign="top"><em>size</em> </td><td>The size of each object. </td></tr> <tr><td valign="top"></td><td valign="top"><em>n</em> </td><td>The number of objects to be read. </td></tr> </table></dl><dl compact><dt><b>Returns:</b></dt><dd>The number of objects read, or -1 if the read failed.</dd></dl><dl compact><dt><b>See also:</b></dt><dd><a class="el" href="group__general__rw__fns.htm#ga14">MGUI_RWwrite</a> </dd></dl><p>Definition at line <a class="el" href="endianrw_8h-source.htm#l00282">282</a> of file <a class="el" href="endianrw_8h-source.htm">endianrw.h</a>. </td> </tr></table><a class="anchor" name="ga11" doxytag="endianrw.h::MGUI_RWseek"></a><p><table class="mdTable" cellpadding="2" cellspacing="0"> <tr> <td class="mdRow"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top">#define MGUI_RWseek </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">ctx, <tr> <td class="md" nowrap align="right"></td> <td class="md"></td> <td class="md" nowrap>offset, <tr> <td class="md" nowrap align="right"></td> <td class="md"></td> <td class="md" nowrap>whence </td> <td class="mdname1" valign="top" nowrap> </td> <td class="md" valign="top"> ) </td> <td class="md" nowrap> (ctx)->seek(ctx, offset, whence)</td> </tr> </table> </td> </tr></table><table cellspacing="5" cellpadding="0" border="0"> <tr> <td> </td> <td><p>Seeks an MG_RWops object. <p>This macro seeks to <em>offset</em> relative to <em>whence</em>.<p><dl compact><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign="top"></td><td valign="top"><em>ctx</em> </td><td>The pointer to the MG_RWops object. </td></tr> <tr><td valign="top"></td><td valign="top"><em>offset</em> </td><td>The offset relative to <em>whence</em>. </td></tr> <tr><td valign="top"></td><td valign="top"><em>whence</em> </td><td>One of stdio's <em>whence</em> values:</td></tr> </table></dl><ul><li>SEEK_SET<br> the offset is relative to the start of the file.</li><li>SEEK_CUR<br> the offset is relative to the current position indicator.</li><li>SEEK_END<br> the offset is relative to the end of the file.</li></ul><p><dl compact><dt><b>Returns:</b></dt><dd>The final offset in the data source.</dd></dl><dl compact><dt><b>See also:</b></dt><dd><a class="el" href="group__general__rw__fns.htm#ga12">MGUI_RWtell</a> </dd></dl><p>Definition at line <a class="el" href="endianrw_8h-source.htm#l00250">250</a> of file <a class="el" href="endianrw_8h-source.htm">endianrw.h</a>. </td> </tr></table><a class="anchor" name="ga12" doxytag="endianrw.h::MGUI_RWtell"></a><p><table class="mdTable" cellpadding="2" cellspacing="0"> <tr> <td class="mdRow"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top">#define MGUI_RWtell </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">ctx </td> <td class="mdname1" valign="top" nowrap> </td> <td class="md" valign="top"> ) </td> <td class="md" nowrap> (ctx)->seek(ctx, 0, SEEK_CUR)</td> </tr> </table> </td> </tr></table><table cellspacing="5" cellpadding="0" border="0"> <tr> <td> </td> <td><p>Obtains the current value of the position indicator for a data source. <p>This macro obtains the current value of the position indicator for the data source pointed to by <em>ctx</em>.<p><dl compact><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign="top"></td><td valign="top"><em>ctx</em> </td><td>The pointer to the MG_RWops object.</td></tr> </table></dl><dl compact><dt><b>Returns:</b></dt><dd>The current value of the position indicator.</dd></dl><dl compact><dt><b>See also:</b></dt><dd><a class="el" href="group__general__rw__fns.htm#ga11">MGUI_RWseek</a> </dd></dl><p>Definition at line <a class="el" href="endianrw_8h-source.htm#l00265">265</a> of file <a class="el" href="endianrw_8h-source.htm">endianrw.h</a>. </td> </tr></table><a class="anchor" name="ga14" doxytag="endianrw.h::MGUI_RWwrite"></a><p><table class="mdTable" cellpadding="2" cellspacing="0"> <tr> <td class="mdRow"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top">#define MGUI_RWwrite </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">ctx, <tr> <td class="md" nowrap align="right"></td> <td class="md"></td> <td class="md" nowrap>ptr, <tr> <td class="md" nowrap align="right"></td> <td class="md"></td> <td class="md" nowrap>size, <tr> <td class="md" nowrap align="right"></td> <td class="md"></td> <td class="md" nowrap>n </td> <td class="mdname1" valign="top" nowrap> </td> <td class="md" valign="top"> ) </td> <td class="md" nowrap> (ctx)->write(ctx, ptr, size, n)</td> </tr> </table> </td> </tr></table><table cellspacing="5" cellpadding="0" border="0"> <tr> <td> </td> <td><p>Writes data blocks to a data source. <p>This macro writes exactly <em>n</em> objects each of size <em>size</em> from the area pointed to by <em>ptr</em> to the data source <em>ctx</em>.<p><dl compact><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign="top"></td><td valign="top"><em>ctx</em> </td><td>The pointer to the MG_RWops object. </td></tr> <tr><td valign="top"></td><td valign="top"><em>ptr</em> </td><td>The buffer contains the data to be written. </td></tr> <tr><td valign="top"></td><td valign="top"><em>size</em> </td><td>The size of each object. </td></tr> <tr><td valign="top"></td><td valign="top"><em>n</em> </td><td>The number of objects to be written. </td></tr> </table></dl><dl compact><dt><b>Returns:</b></dt><dd>The number written, or -1 if the write failed.</dd></dl><dl compact><dt><b>See also:</b></dt><dd><a class="el" href="group__general__rw__fns.htm#ga13">MGUI_RWread</a> </dd></dl><p>Definition at line <a class="el" href="endianrw_8h-source.htm#l00299">299</a> of file <a class="el" href="endianrw_8h-source.htm">endianrw.h</a>. </td> </tr></table><hr><h2>Typedef Documentation</h2><a class="anchor" name="ga0" doxytag="endianrw.h::MG_RWops"></a><p><table class="mdTable" cellpadding="2" cellspacing="0"> <tr> <td class="mdRow"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top">typedef struct <a class="el" href="struct__MG__RWops.htm">_MG_RWops</a> <a class="el" href="struct__MG__RWops.htm">MG_RWops</a> </td> </tr> </table> </td>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -