📄 goutputstream.html
字号:
<a name="id3191827"></a><h3><a name="g-output-stream-flush"></a>g_output_stream_flush ()</h3><a class="indexterm" name="id3191838"></a><pre class="programlisting"><ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean">gboolean</a> g_output_stream_flush (<a class="link" href="GOutputStream.html" title="GOutputStream">GOutputStream</a> *stream, <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>Flushed any outstanding buffers in the stream. Will block during the operation. Closing the stream will implicitly cause a flush.</p><p>This function is optional for inherited classes.</p><p>If <em class="parameter"><code>cancellable</code></em> is not <ahref="/usr/share/gtk-doc/html/liboil/liboil-liboiljunk.html#NULL:CAPS"><code class="literal">NULL</code></a>, then the operation can be cancelled bytriggering the cancellable object from another thread. If the operationwas cancelled, the error <a class="link" href="gio-GIOError.html#G-IO-ERROR-CANCELLED:CAPS"><code class="literal">G_IO_ERROR_CANCELLED</code></a> will be returned.</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>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> <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> on error</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3192015"></a><h3><a name="g-output-stream-close"></a>g_output_stream_close ()</h3><a class="indexterm" name="id3192026"></a><pre class="programlisting"><ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean">gboolean</a> g_output_stream_close (<a class="link" href="GOutputStream.html" title="GOutputStream">GOutputStream</a> *stream, <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>Closes the stream, releasing resources related to it.</p><p>Once the stream is closed, all other operations will return <a class="link" href="gio-GIOError.html#G-IO-ERROR-CLOSED:CAPS"><code class="literal">G_IO_ERROR_CLOSED</code></a>.Closing a stream multiple times will not return an error.</p><p>Closing a stream will automatically flush any outstanding buffers in thestream.</p><p>Streams will be automatically closed when the last referenceis dropped, but you might want to call this function to make sure resources are released as early as possible.</p><p>Some streams might keep the backing store of the stream (e.g. a file descriptor)open after the stream is closed. See the documentation for the individualstream for details.</p><p>On failure the first error that happened will be reported, but the closeoperation will finish as much as possible. A stream that failed toclose will still return <a class="link" href="gio-GIOError.html#G-IO-ERROR-CLOSED:CAPS"><code class="literal">G_IO_ERROR_CLOSED</code></a> for all operations. Still, itis important to check and report the error to the user, otherwisethere might be a loss of data as all data might not be written.</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 <a class="link" href="gio-GIOError.html#G-IO-ERROR-CANCELLED:CAPS"><code class="literal">G_IO_ERROR_CANCELLED</code></a> will be returned.Cancelling a close will still leave the stream closed, but there some streamscan use a faster close that doesn't block to e.g. check errors. Oncancellation (as with any error) there is no guarantee that all writtendata will reach the target.</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>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> <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> on failure</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3192242"></a><h3><a name="g-output-stream-write-async"></a>g_output_stream_write_async ()</h3><a class="indexterm" name="id3192254"></a><pre class="programlisting">void g_output_stream_write_async (<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, int io_priority, <a class="link" href="GCancellable.html" title="GCancellable">GCancellable</a> *cancellable, <a class="link" href="GAsyncResult.html#GAsyncReadyCallback">GAsyncReadyCallback</a> callback, <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gpointer">gpointer</a> user_data);</pre><p>Request an asynchronous write of <em class="parameter"><code>count</code></em> bytes from <em class="parameter"><code>buffer</code></em> into the stream. When the operation is finished <em class="parameter"><code>callback</code></em> will be called.You can then call <a class="link" href="GOutputStream.html#g-output-stream-write-finish"><code class="function">g_output_stream_write_finish()</code></a> to get the result of the operation.</p><p>During an async request no other sync and async calls are allowed, and will result in <a class="link" href="gio-GIOError.html#G-IO-ERROR-PENDING:CAPS"><code class="literal">G_IO_ERROR_PENDING</code></a> errors. </p><p>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 will be passed to the<em class="parameter"><code>callback</code></em>. It is not an error if this is not the same as the requested size, as it can happen e.g. on a partial I/O error, but generally we try to write as many bytes as requested. </p><p>Any outstanding I/O request with higher priority (lower numerical value) will be executed before an outstanding request with lower priority. Default priority is <ahref="/usr/share/gtk-doc/html/glib/glib-The-Main-Event-Loop.html#G-PRIORITY-DEFAULT:CAPS"><code class="literal">G_PRIORITY_DEFAULT</code></a>.</p><p>The asyncronous methods have a default fallback that uses threads to implement asynchronicity, so they are optional for inheriting classes. However, if you override one you must override all.</p><p>For the synchronous, blocking version of this function, see <a class="link" href="GOutputStream.html#g-output-stream-write"><code class="function">g_output_stream_write()</code></a>.</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>io_priority</code></em> :</span></p></td><td> the io priority of the request.</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>callback</code></em> :</span></p></td><td> callback to call when the request is satisfied</td></tr><tr><td><p><span class="term"><em class="parameter"><code>user_data</code></em> :</span></p></td><td> the data to pass to callback function</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3192582"></a><h3><a name="g-output-stream-write-finish"></a>g_output_stream_write_finish ()</h3><a class="indexterm" name="id3192595"></a><pre class="programlisting"><ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gssize">gssize</a> g_output_stream_write_finish (<a class="link" href="GOutputStream.html" title="GOutputStream">GOutputStream</a> *stream, <a class="link" href="GAsyncResult.html" title="GAsyncResult">GAsyncResult</a> *result, <ahref="/usr/share/gtk-doc/html/glib/glib-Error-Reporting.html#GError">GError</a> **error);</pre><p>Finishes a stream write operation.</p><p></p>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -