📄 goutputstream.html
字号:
</div><hr><div class="refsect2" lang="en"><a name="id3191004"></a><h3><a name="GOutputStream-struct"></a>GOutputStream</h3><a class="indexterm" name="id3191016"></a><pre class="programlisting">typedef struct _GOutputStream GOutputStream;</pre><p>Base class for writing output. </p><p>All classes derived from GOutputStream should implement synchronous writing, splicing, flushing and closing streams, but may implementasynchronous versions.</p><p></p></div><hr><div class="refsect2" lang="en"><a name="id3191043"></a><h3><a name="g-output-stream-write"></a>g_output_stream_write ()</h3><a class="indexterm" name="id3191054"></a><pre class="programlisting"><ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gssize">gssize</a> g_output_stream_write (<a class="link" href="GOutputStream.html" title="GOutputStream">GOutputStream</a> *stream, const void *buffer, <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gsize">gsize</a> count, <a class="link" href="GCancellable.html" title="GCancellable">GCancellable</a> *cancellable, <ahref="/usr/share/gtk-doc/html/glib/glib-Error-Reporting.html#GError">GError</a> **error);</pre><p>Tries to write <em class="parameter"><code>count</code></em> bytes from <em class="parameter"><code>buffer</code></em> into the stream. Will blockduring the operation.</p><p>If count is zero returns zero and does nothing. A value of <em class="parameter"><code>count</code></em>larger than <ahref="/usr/share/gtk-doc/html/glib/glib-Limits-of-Basic-Types.html#G-MAXSSIZE:CAPS"><code class="literal">G_MAXSSIZE</code></a> will cause a <a class="link" href="gio-GIOError.html#G-IO-ERROR-INVALID-ARGUMENT:CAPS"><code class="literal">G_IO_ERROR_INVALID_ARGUMENT</code></a> error.</p><p>On success, the number of bytes written to the stream is returned.It is not an error if this is not the same as the requested size, as itcan happen e.g. on a partial i/o error, or if there is not enoughstorage in the stream. All writes either block until at least one byteis written, so zero is never returned (unless <em class="parameter"><code>count</code></em> is zero).</p><p>If <em class="parameter"><code>cancellable</code></em> is not NULL, then the operation can be cancelled bytriggering the cancellable object from another thread. If the operationwas cancelled, the error G_IO_ERROR_CANCELLED will be returned. If anoperation was partially finished when the operation was cancelled thepartial result will be returned, without an error.</p><p>On error -1 is returned and <em class="parameter"><code>error</code></em> is set accordingly.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>stream</code></em> :</span></p></td><td> a <a class="link" href="GOutputStream.html" title="GOutputStream"><span class="type">GOutputStream</span></a>.</td></tr><tr><td><p><span class="term"><em class="parameter"><code>buffer</code></em> :</span></p></td><td> the buffer containing the data to write. </td></tr><tr><td><p><span class="term"><em class="parameter"><code>count</code></em> :</span></p></td><td> the number of bytes to write</td></tr><tr><td><p><span class="term"><em class="parameter"><code>cancellable</code></em> :</span></p></td><td> optional cancellable object</td></tr><tr><td><p><span class="term"><em class="parameter"><code>error</code></em> :</span></p></td><td> location to store the error occuring, or <ahref="/usr/share/gtk-doc/html/liboil/liboil-liboiljunk.html#NULL:CAPS"><code class="literal">NULL</code></a> to ignore</td></tr><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td><td> Number of bytes written, or -1 on error</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3191299"></a><h3><a name="g-output-stream-write-all"></a>g_output_stream_write_all ()</h3><a class="indexterm" name="id3191311"></a><pre class="programlisting"><ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean">gboolean</a> g_output_stream_write_all (<a class="link" href="GOutputStream.html" title="GOutputStream">GOutputStream</a> *stream, const void *buffer, <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gsize">gsize</a> count, <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gsize">gsize</a> *bytes_written, <a class="link" href="GCancellable.html" title="GCancellable">GCancellable</a> *cancellable, <ahref="/usr/share/gtk-doc/html/glib/glib-Error-Reporting.html#GError">GError</a> **error);</pre><p>Tries to write <em class="parameter"><code>count</code></em> bytes from <em class="parameter"><code>buffer</code></em> into the stream. Will blockduring the operation.</p><p>This function is similar to <a class="link" href="GOutputStream.html#g-output-stream-write"><code class="function">g_output_stream_write()</code></a>, except it tries towrite as many bytes as requested, only stopping on an error.</p><p>On a successful write of <em class="parameter"><code>count</code></em> bytes, <ahref="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> is returned, and <em class="parameter"><code>bytes_written</code></em>is set to <em class="parameter"><code>count</code></em>.</p><p>If there is an error during the operation FALSE is returned and <em class="parameter"><code>error</code></em>is set to indicate the error status, <em class="parameter"><code>bytes_written</code></em> is updated to containthe number of bytes written into the stream before the error occurred.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>stream</code></em> :</span></p></td><td> a <a class="link" href="GOutputStream.html" title="GOutputStream"><span class="type">GOutputStream</span></a>.</td></tr><tr><td><p><span class="term"><em class="parameter"><code>buffer</code></em> :</span></p></td><td> the buffer containing the data to write. </td></tr><tr><td><p><span class="term"><em class="parameter"><code>count</code></em> :</span></p></td><td> the number of bytes to write</td></tr><tr><td><p><span class="term"><em class="parameter"><code>bytes_written</code></em> :</span></p></td><td> location to store the number of bytes that was written to the stream</td></tr><tr><td><p><span class="term"><em class="parameter"><code>cancellable</code></em> :</span></p></td><td> optional <a class="link" href="GCancellable.html" title="GCancellable"><span class="type">GCancellable</span></a> object, <ahref="/usr/share/gtk-doc/html/liboil/liboil-liboiljunk.html#NULL:CAPS"><code class="literal">NULL</code></a> to ignore.</td></tr><tr><td><p><span class="term"><em class="parameter"><code>error</code></em> :</span></p></td><td> location to store the error occuring, or <ahref="/usr/share/gtk-doc/html/liboil/liboil-liboiljunk.html#NULL:CAPS"><code class="literal">NULL</code></a> to ignore</td></tr><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td><td> <ahref="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> on success, <ahref="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#FALSE:CAPS"><code class="literal">FALSE</code></a> if there was an error</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3191608"></a><h3><a name="g-output-stream-splice"></a>g_output_stream_splice ()</h3><a class="indexterm" name="id3191619"></a><pre class="programlisting"><ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gssize">gssize</a> g_output_stream_splice (<a class="link" href="GOutputStream.html" title="GOutputStream">GOutputStream</a> *stream, <a class="link" href="GInputStream.html" title="GInputStream">GInputStream</a> *source, <a class="link" href="GOutputStream.html#GOutputStreamSpliceFlags">GOutputStreamSpliceFlags</a> flags, <a class="link" href="GCancellable.html" title="GCancellable">GCancellable</a> *cancellable, <ahref="/usr/share/gtk-doc/html/glib/glib-Error-Reporting.html#GError">GError</a> **error);</pre><p>Splices an input stream into an output stream.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>stream</code></em> :</span></p></td><td> a <a class="link" href="GOutputStream.html" title="GOutputStream"><span class="type">GOutputStream</span></a>.</td></tr><tr><td><p><span class="term"><em class="parameter"><code>source</code></em> :</span></p></td><td> a <a class="link" href="GInputStream.html" title="GInputStream"><span class="type">GInputStream</span></a>.</td></tr><tr><td><p><span class="term"><em class="parameter"><code>flags</code></em> :</span></p></td><td> a set of <a class="link" href="GOutputStream.html#GOutputStreamSpliceFlags"><span class="type">GOutputStreamSpliceFlags</span></a>.</td></tr><tr><td><p><span class="term"><em class="parameter"><code>cancellable</code></em> :</span></p></td><td> optional <a class="link" href="GCancellable.html" title="GCancellable"><span class="type">GCancellable</span></a> object, <ahref="/usr/share/gtk-doc/html/liboil/liboil-liboiljunk.html#NULL:CAPS"><code class="literal">NULL</code></a> to ignore. </td></tr><tr><td><p><span class="term"><em class="parameter"><code>error</code></em> :</span></p></td><td> a <ahref="/usr/share/gtk-doc/html/glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> location to store the error occuring, or <ahref="/usr/share/gtk-doc/html/liboil/liboil-liboiljunk.html#NULL:CAPS"><code class="literal">NULL</code></a> to ignore.</td></tr><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td><td> a <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gssize"><span class="type">gssize</span></a> containing the size of the data spliced.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en">
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -