📄 glib-io-channels.html
字号:
</tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id2909067"></a><h3><a name="g-io-channel-unix-get-fd"></a>g_io_channel_unix_get_fd ()</h3><a class="indexterm" name="id2909078"></a><pre class="programlisting"><a href="glib-Basic-Types.html#gint">gint</a> g_io_channel_unix_get_fd (<a href="glib-IO-Channels.html#GIOChannel">GIOChannel</a> *channel);</pre><p>Returns the file descriptor of the UNIX <a href="glib-IO-Channels.html#GIOChannel"><span class="type">GIOChannel</span></a>.</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><em class="parameter"><code>channel</code></em> :</span></td><td>a <a href="glib-IO-Channels.html#GIOChannel"><span class="type">GIOChannel</span></a>, created with <a href="glib-IO-Channels.html#g-io-channel-unix-new"><code class="function">g_io_channel_unix_new()</code></a>.</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td>the file descriptor of the <a href="glib-IO-Channels.html#GIOChannel"><span class="type">GIOChannel</span></a>.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id2909170"></a><h3><a name="g-io-channel-init"></a>g_io_channel_init ()</h3><a class="indexterm" name="id2909181"></a><pre class="programlisting">void g_io_channel_init (<a href="glib-IO-Channels.html#GIOChannel">GIOChannel</a> *channel);</pre><p>Initializes a <a href="glib-IO-Channels.html#GIOChannel"><span class="type">GIOChannel</span></a> struct. This is called by each of the above functionswhen creating a <a href="glib-IO-Channels.html#GIOChannel"><span class="type">GIOChannel</span></a>, and so is not often needed by the applicationprogrammer (unless you are creating a new type of <a href="glib-IO-Channels.html#GIOChannel"><span class="type">GIOChannel</span></a>).</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><em class="parameter"><code>channel</code></em> :</span></td><td>a <a href="glib-IO-Channels.html#GIOChannel"><span class="type">GIOChannel</span></a>.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id2909261"></a><h3><a name="g-io-channel-new-file"></a>g_io_channel_new_file ()</h3><a class="indexterm" name="id2909272"></a><pre class="programlisting"><a href="glib-IO-Channels.html#GIOChannel">GIOChannel</a>* g_io_channel_new_file (const <a href="glib-Basic-Types.html#gchar">gchar</a> *filename, const <a href="glib-Basic-Types.html#gchar">gchar</a> *mode, <a href="glib-Error-Reporting.html#GError">GError</a> **error);</pre><p>Open a file <em class="parameter"><code>filename</code></em> as a <a href="glib-IO-Channels.html#GIOChannel"><span class="type">GIOChannel</span></a> using mode <em class="parameter"><code>mode</code></em>. Thischannel will be closed when the last reference to it is dropped,so there is no need to call <a href="glib-IO-Channels.html#g-io-channel-close"><code class="function">g_io_channel_close()</code></a> (though doingso will not cause problems, as long as no attempt is made toaccess the channel after it is closed).</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><em class="parameter"><code>filename</code></em> :</span></td><td> A string containing the name of a file.</td></tr><tr><td><span class="term"><em class="parameter"><code>mode</code></em> :</span></td><td> One of "r", "w", "a", "r+", "w+", "a+". These have the same meaning as in <code class="function">fopen()</code>.</td></tr><tr><td><span class="term"><em class="parameter"><code>error</code></em> :</span></td><td> A location to return an error of type <code class="literal">G_FILE_ERROR</code>.</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td> A <a href="glib-IO-Channels.html#GIOChannel"><span class="type">GIOChannel</span></a> on success, <code class="literal">NULL</code> on failure.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id2909443"></a><h3><a name="g-io-channel-read-chars"></a>g_io_channel_read_chars ()</h3><a class="indexterm" name="id2909454"></a><pre class="programlisting"><a href="glib-IO-Channels.html#GIOStatus">GIOStatus</a> g_io_channel_read_chars (<a href="glib-IO-Channels.html#GIOChannel">GIOChannel</a> *channel, <a href="glib-Basic-Types.html#gchar">gchar</a> *buf, <a href="glib-Basic-Types.html#gsize">gsize</a> count, <a href="glib-Basic-Types.html#gsize">gsize</a> *bytes_read, <a href="glib-Error-Reporting.html#GError">GError</a> **error);</pre><p>Replacement for <a href="glib-IO-Channels.html#g-io-channel-read"><code class="function">g_io_channel_read()</code></a> with the new API.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><em class="parameter"><code>channel</code></em> :</span></td><td> a <a href="glib-IO-Channels.html#GIOChannel"><span class="type">GIOChannel</span></a></td></tr><tr><td><span class="term"><em class="parameter"><code>buf</code></em> :</span></td><td> a buffer to read data into</td></tr><tr><td><span class="term"><em class="parameter"><code>count</code></em> :</span></td><td> the size of the buffer. Note that the buffer may not be complelely filled even if there is data in the buffer if the remaining data is not a complete character.</td></tr><tr><td><span class="term"><em class="parameter"><code>bytes_read</code></em> :</span></td><td> The number of bytes read. This may be zero even on success if count < 6 and the channel's encoding is non-<code class="literal">NULL</code>. This indicates that the next UTF-8 character is too wide for the buffer.</td></tr><tr><td><span class="term"><em class="parameter"><code>error</code></em> :</span></td><td> A location to return an error of type <a href="glib-Character-Set-Conversion.html#GConvertError"><span class="type">GConvertError</span></a> or <a href="glib-IO-Channels.html#GIOChannelError"><span class="type">GIOChannelError</span></a>.</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td> the status of the operation.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id2909651"></a><h3><a name="g-io-channel-read-unichar"></a>g_io_channel_read_unichar ()</h3><a class="indexterm" name="id2909663"></a><pre class="programlisting"><a href="glib-IO-Channels.html#GIOStatus">GIOStatus</a> g_io_channel_read_unichar (<a href="glib-IO-Channels.html#GIOChannel">GIOChannel</a> *channel, <a href="glib-Unicode-Manipulation.html#gunichar">gunichar</a> *thechar, <a href="glib-Error-Reporting.html#GError">GError</a> **error);</pre><p>This function cannot be called on a channel with <code class="literal">NULL</code> encoding.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><em class="parameter"><code>channel</code></em> :</span></td><td> a <a href="glib-IO-Channels.html#GIOChannel"><span class="type">GIOChannel</span></a></td></tr><tr><td><span class="term"><em class="parameter"><code>thechar</code></em> :</span></td><td> a location to return a character</td></tr><tr><td><span class="term"><em class="parameter"><code>error</code></em> :</span></td><td> A location to return an error of type <a href="glib-Character-Set-Conversion.html#GConvertError"><span class="type">GConvertError</span></a> or <a href="glib-IO-Channels.html#GIOChannelError"><span class="type">GIOChannelError</span></a></td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td> a <a href="glib-IO-Channels.html#GIOStatus"><span class="type">GIOStatus</span></a></td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id2909804"></a><h3><a name="g-io-channel-read-line"></a>g_io_channel_read_line ()</h3><a class="indexterm" name="id2909815"></a><pre class="programlisting"><a href="glib-IO-Channels.html#GIOStatus">GIOStatus</a> g_io_channel_read_line (<a href="glib-IO-Channels.html#GIOChannel">GIOChannel</a> *channel, <a href="glib-Basic-Types.html#gchar">gchar</a> **str_return, <a href="glib-Basic-Types.html#gsize">gsize</a> *length, <a href="glib-Basic-Types.html#gsize">gsize</a> *terminator_pos, <a href="glib-Error-Reporting.html#GError">GError</a> **error);</pre><p>Reads a line, including the terminating character(s),from a <a href="glib-IO-Channels.html#GIOChannel"><span class="type">GIOChannel</span></a> into a newly-allocated string.<em class="parameter"><code>str_return</code></em> will contain allocated memory if the returnis <code class="literal">G_IO_STATUS_NORMAL</code>.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><em class="parameter"><code>channel</code></em> :</span></td><td> a <a href="glib-IO-Channels.html#GIOChannel"><span class="type">GIOChannel</span></a></td></tr><tr><td><span class="term"><em class="parameter"><code>str_return</code></em> :</span></td><td> The line read from the <a href="glib-IO-Channels.html#GIOChannel"><span class="type">GIOChannel</span></a>, including the line terminator. This data should be freed with <a href="glib-Memory-Allocation.html#g-free"><code class="function">g_free()</code></a> when no longer needed. This is a nul-terminated string. If a <em class="parameter"><code>length</code></em> of zero is returned, this will be <code class="literal">NULL</code> instead.</td></tr><tr><td><span class="term"><em class="parameter"><code>length</code></em> :</span></td><td> location to store length of the read data, or <code class="literal">NULL</code></td></tr><tr><td><span class="term"><em class="parameter"><code>terminator_pos</code></em> :</span></td><td> location to store position of line terminator, or <code class="literal">NULL</code></td></tr><tr><td><span class="term"><em class="parameter"><code>error</code></em> :</span></td><td> A location to return an error of type <a href="glib-Character-Set-Conversion.html#GConvertError"><span class="type">GConvertError</span></a> or <a href="glib-IO-Channels.html#GIOChannelError"><span class="type">GIOChannelError</span></a></td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td> the status of the operation.</td></tr></tbody>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -