1 <html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><title>gio.InputStream</title><link rel="stylesheet" type="text/css" href="style.css"><meta name="generator" content="DocBook XSL Stylesheets V1.76.1"><link rel="home" href="index.html" title="PyGObject Reference Manual"><link rel="up" href="gio-class-reference.html" title="PyGio Class Reference"><link rel="prev" href="class-gioicon.html" title="gio.Icon"><link rel="next" href="class-gioloadableicon.html" title="gio.LoadableIcon"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">gio.InputStream</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="class-gioicon.html">Prev</a> </td><th width="60%" align="center">PyGio Class Reference</th><td width="20%" align="right"> <a accesskey="n" href="class-gioloadableicon.html">Next</a></td></tr></table><hr></div><div class="refentry" title="gio.InputStream"><a name="class-gioinputstream"></a><div class="titlepage"></div><div class="refnamediv"><h2>gio.InputStream</h2><p>gio.InputStream — Base class for implementing streaming input</p></div><div class="refsect1" title="Synopsis"><a name="id515261"></a><h2>Synopsis</h2><table bgcolor="#D0E0F0" width="100%"><tr><td><pre class="classsynopsis">class <span class="ooclass"><span class="classname">gio.InputStream</span></span>(<span class="ooclass"><span class="classname"><a class="link" href="class-gobject.html" title="gobject.GObject">gobject.GObject</a></span></span>):
2 <code class="methodsynopsis"> def <span class="methodname"><a class="link" href="class-gioinputstream.html#method-gioinputstream--clear-pending" title="gio.InputStream.clear_pending">clear_pending</a></span>(<span class="methodparam"></span>)</code><br><code class="methodsynopsis"> def <span class="methodname"><a class="link" href="class-gioinputstream.html#method-gioinputstream--close" title="gio.InputStream.close">close</a></span>(<span class="methodparam"><span class="parameter"><strong class="parameter"><code>cancellable</code></strong></span><span class="initializer">=None</span></span>)</code><br><code class="methodsynopsis"> def <span class="methodname"><a class="link" href="class-gioinputstream.html#method-gioinputstream--close-async" title="gio.InputStream.close_async">close_async</a></span>(<span class="methodparam"><span class="parameter"><strong class="parameter"><code>callback</code></strong></span></span>, <span class="methodparam"><span class="parameter"><strong class="parameter"><code>io_priority</code></strong></span><span class="initializer">=glib.PRIORITY_DEFAULT</span></span>, <span class="methodparam"><span class="parameter"><strong class="parameter"><code>cancellable</code></strong></span><span class="initializer">=None</span></span>, <span class="methodparam"><span class="parameter"><strong class="parameter"><code>user_data</code></strong></span><span class="initializer">=None</span></span>)</code><br><code class="methodsynopsis"> def <span class="methodname"><a class="link" href="class-gioinputstream.html#method-gioinputstream--close-finish" title="gio.InputStream.close_finish">close_finish</a></span>(<span class="methodparam"><span class="parameter"><strong class="parameter"><code>result</code></strong></span></span>)</code><br><code class="methodsynopsis"> def <span class="methodname"><a class="link" href="class-gioinputstream.html#method-gioinputstream--has-pending" title="gio.InputStream.has_pending">has_pending</a></span>(<span class="methodparam"></span>)</code><br><code class="methodsynopsis"> def <span class="methodname"><a class="link" href="class-gioinputstream.html#method-gioinputstream--is-closed" title="gio.InputStream.is_closed">is_closed</a></span>(<span class="methodparam"></span>)</code><br><code class="methodsynopsis"> def <span class="methodname"><a class="link" href="class-gioinputstream.html#method-gioinputstream--read" title="gio.InputStream.read">read</a></span>(<span class="methodparam"><span class="parameter"><strong class="parameter"><code>count</code></strong></span><span class="initializer">=-1</span></span>, <span class="methodparam"><span class="parameter"><strong class="parameter"><code>cancellable</code></strong></span><span class="initializer">=None</span></span>)</code><br><code class="methodsynopsis"> def <span class="methodname"><a class="link" href="class-gioinputstream.html#method-gioinputstream--read-async" title="gio.InputStream.read_async">read_async</a></span>(<span class="methodparam"><span class="parameter"><strong class="parameter"><code>count</code></strong></span></span>, <span class="methodparam"><span class="parameter"><strong class="parameter"><code>callback</code></strong></span></span>, <span class="methodparam"><span class="parameter"><strong class="parameter"><code>io_priority</code></strong></span><span class="initializer">=glib.PRIORITY_DEFAULT</span></span>, <span class="methodparam"><span class="parameter"><strong class="parameter"><code>cancellable</code></strong></span><span class="initializer">=None</span></span>, <span class="methodparam"><span class="parameter"><strong class="parameter"><code>user_data</code></strong></span><span class="initializer">=None</span></span>)</code><br><code class="methodsynopsis"> def <span class="methodname"><a class="link" href="class-gioinputstream.html#method-gioinputstream--read-finish" title="gio.InputStream.read_finish">read_finish</a></span>(<span class="methodparam"><span class="parameter"><strong class="parameter"><code>result</code></strong></span></span>)</code><br><code class="methodsynopsis"> def <span class="methodname"><a class="link" href="class-gioinputstream.html#method-gioinputstream--read-part" title="gio.InputStream.read_part">read_part</a></span>(<span class="methodparam"><span class="parameter"><strong class="parameter"><code>count</code></strong></span><span class="initializer">=-1</span></span>, <span class="methodparam"><span class="parameter"><strong class="parameter"><code>cancellable</code></strong></span><span class="initializer">=None</span></span>)</code><br><code class="methodsynopsis"> def <span class="methodname"><a class="link" href="class-gioinputstream.html#method-gioinputstream--set-pending" title="gio.InputStream.set_pending">set_pending</a></span>(<span class="methodparam"></span>)</code><br><code class="methodsynopsis"> def <span class="methodname"><a class="link" href="class-gioinputstream.html#method-gioinputstream--skip" title="gio.InputStream.skip">skip</a></span>(<span class="methodparam"><span class="parameter"><strong class="parameter"><code>count</code></strong></span></span>, <span class="methodparam"><span class="parameter"><strong class="parameter"><code>cancellable</code></strong></span><span class="initializer">=None</span></span>)</code><br><code class="methodsynopsis"> def <span class="methodname"><a class="link" href="class-gioinputstream.html#method-gioinputstream--skip-async" title="gio.InputStream.skip_async">skip_async</a></span>(<span class="methodparam"><span class="parameter"><strong class="parameter"><code>count</code></strong></span></span>, <span class="methodparam"><span class="parameter"><strong class="parameter"><code>callback</code></strong></span></span>, <span class="methodparam"><span class="parameter"><strong class="parameter"><code>io_priority</code></strong></span><span class="initializer">=glib.PRIORITY_DEFAULT</span></span>, <span class="methodparam"><span class="parameter"><strong class="parameter"><code>cancellable</code></strong></span><span class="initializer">=None</span></span>, <span class="methodparam"><span class="parameter"><strong class="parameter"><code>user_data</code></strong></span><span class="initializer">=None</span></span>)</code><br><code class="methodsynopsis"> def <span class="methodname"><a class="link" href="class-gioinputstream.html#method-gioinputstream--skip-finish" title="gio.InputStream.skip_finish">skip_finish</a></span>(<span class="methodparam"><span class="parameter"><strong class="parameter"><code>result</code></strong></span></span>)</code><br></pre></td></tr></table></div><div class="refsect1" title="Ancestry"><a name="id515798"></a><h2>Ancestry</h2><pre class="synopsis">+-- <a class="link" href="class-gobject.html" title="gobject.GObject">gobject.GObject</a>
3 +-- <a class="link" href="class-gioinputstream.html" title="gio.InputStream">gio.InputStream</a>
4 </pre></div><div class="refsect1" title="Description"><a name="id515820"></a><h2>Description</h2><p>
5 <a class="link" href="class-gioinputstream.html" title="gio.InputStream"><code class="classname">gio.InputStream</code></a>
6 has functions to read from a stream (
7 <code class="methodname"><a class="link" href="class-gioinputstream.html#method-gioinputstream--read" title="gio.InputStream.read">gio.InputStream.read</a></code>()
9 <code class="methodname"><a class="link" href="class-gioinputstream.html#method-gioinputstream--close" title="gio.InputStream.close">gio.InputStream.close</a></code>()
10 ) and to skip some content (
11 <code class="methodname"><a class="link" href="class-gioinputstream.html#method-gioinputstream--skip" title="gio.InputStream.skip">gio.InputStream.skip</a></code>()
14 To copy the content of an input stream to an output stream without manually
15 handling the reads and writes, use
16 <code class="methodname"><PYGTKDOCLINK HREF="method-giooutputstream--skip">gio.OutputStream.splice</PYGTKDOCLINK></code>().
18 All of these functions have async variants too.
19 </p></div><div class="refsect1" title="Methods"><a name="id515868"></a><h2>Methods</h2><div class="refsect2" title="gio.InputStream.clear_pending"><a name="method-gioinputstream--clear-pending"></a><h3>gio.InputStream.clear_pending</h3><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">clear_pending</span>(<span class="methodparam"></span>)</code></pre><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody></tbody></table><p>
20 The <code class="methodname">clear_pending</code>() method clears the pending flag on stream.
21 </p></div><div class="refsect2" title="gio.InputStream.close"><a name="method-gioinputstream--close"></a><h3>gio.InputStream.close</h3><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">close</span>(<span class="methodparam"><span class="parameter"><strong class="parameter"><code>cancellable</code></strong></span><span class="initializer">=None</span></span>)</code></pre><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><p><span class="term"><strong class="parameter"><code>cancellable</code></strong> :</span></p></td><td>optional
22 <a class="link" href="class-giocancellable.html" title="gio.Cancellable"><code class="classname">gio.Cancellable</code></a>
23 object, <code class="literal">None</code> to ignore.
24 </td></tr><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td><td><code class="literal">True</code> on success
25 <code class="literal">False</code> on failure.
26 </td></tr></tbody></table><p>
27 The <code class="methodname">close</code>() method closes the stream, releasing
28 resources related to it.
30 Once the stream is closed, all other operations will return gio.ERROR_CLOSED.
31 Closing a stream multiple times will not return an error.
33 Streams will be automatically closed when the last reference is dropped, but
34 you might want to call this function to make sure resources are released as
37 Some streams might keep the backing store of the stream (e.g. a file descriptor)
38 open after the stream is closed. See the documentation for the individual
41 On failure the first error that happened will be reported, but the close operation
42 will finish as much as possible. A stream that failed to close will still return
43 gio.ERROR_CLOSED for all operations. Still, it is important to check and report
44 the error to the user.
46 If cancellable is not <code class="literal">None</code>, then the operation can be cancelled by
47 triggering the cancellable object from another thread. If the operation was cancelled,
48 the error gio.ERROR_CANCELLED will be returned. Cancelling a close will still leave
49 the stream closed, but some streams can use a faster close that doesn't block to e.g.
51 </p></div><div class="refsect2" title="gio.InputStream.close_async"><a name="method-gioinputstream--close-async"></a><h3>gio.InputStream.close_async</h3><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">close_async</span>(<span class="methodparam"><span class="parameter"><strong class="parameter"><code>callback</code></strong></span></span>, <span class="methodparam"><span class="parameter"><strong class="parameter"><code>io_priority</code></strong></span><span class="initializer">=glib.PRIORITY_DEFAULT</span></span>, <span class="methodparam"><span class="parameter"><strong class="parameter"><code>cancellable</code></strong></span><span class="initializer">=None</span></span>, <span class="methodparam"><span class="parameter"><strong class="parameter"><code>user_data</code></strong></span><span class="initializer">=None</span></span>)</code></pre><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><p><span class="term"><em class="parameter"><code>callback</code></em> :</span></p></td><td>a GAsyncReadyCallback to call when the request is satisfied.
52 </td></tr><tr><td><p><span class="term"><em class="parameter"><code>io_priority</code></em> :</span></p></td><td>the
53 <a class="xref" href="glib-constants.html#glib-priority-constants" title="Glib Priority Constants">Glib Priority Constants</a>
55 </td></tr><tr><td><p><span class="term"><em class="parameter"><code>cancellable</code></em> :</span></p></td><td>optional
56 <a class="link" href="class-giocancellable.html" title="gio.Cancellable"><code class="classname">gio.Cancellable</code></a>
57 object, <code class="literal">None</code> to ignore.</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.
58 </td></tr></tbody></table><p>
59 The <code class="methodname">close_async</code>() method asynchronously requests an
60 asynchronous closes of the stream, releasing resources related to it.
63 <code class="methodname"><a class="link" href="class-gioinputstream.html#method-gioinputstream--close" title="gio.InputStream.close">gio.InputStream.close</a></code>()
64 which is the synchronous version of this call.
66 When the operation is finished, callback will be called. You can then call
67 <code class="methodname"><a class="link" href="class-gioinputstream.html#method-gioinputstream--close-finish" title="gio.InputStream.close_finish">gio.InputStream.close_finish</a></code>()
68 to get the result of the operation.
69 </p></div><div class="refsect2" title="gio.InputStream.close_finish"><a name="method-gioinputstream--close-finish"></a><h3>gio.InputStream.close_finish</h3><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">close_finish</span>(<span class="methodparam"><span class="parameter"><strong class="parameter"><code>result</code></strong></span></span>)</code></pre><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><p><span class="term"><strong class="parameter"><code>result</code></strong> :</span></p></td><td>a <a class="link" href="class-gioasyncresult.html" title="gio.AsyncResult"><code class="classname">gio.AsyncResult</code></a>.
70 </td></tr><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td><td><code class="literal">True</code> if the stream was closed successfully.
71 </td></tr></tbody></table><p>
72 The <code class="methodname">close_finish</code>() method finishes an asynchronous
73 file append operation started with
74 <code class="methodname"><a class="link" href="class-gioinputstream.html#method-gioinputstream--close-async" title="gio.InputStream.close_async">gio.InputStream.close_async</a></code>().
75 </p></div><div class="refsect2" title="gio.InputStream.has_pending"><a name="method-gioinputstream--has-pending"></a><h3>gio.InputStream.has_pending</h3><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">has_pending</span>(<span class="methodparam"></span>)</code></pre><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td><td><code class="literal">True</code> if stream has pending actions.
76 </td></tr></tbody></table><p>
77 The <code class="methodname">has_pending</code>() method checks if an input stream has pending actions.
78 </p></div><div class="refsect2" title="gio.InputStream.is_closed"><a name="method-gioinputstream--is-closed"></a><h3>gio.InputStream.is_closed</h3><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">is_closed</span>(<span class="methodparam"></span>)</code></pre><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td><td><code class="literal">True</code> if the stream is closed.
79 </td></tr></tbody></table><p>
80 The <code class="methodname">is_closed</code>() method checks if an input stream is closed.
81 </p></div><div class="refsect2" title="gio.InputStream.read"><a name="method-gioinputstream--read"></a><h3>gio.InputStream.read</h3><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">read</span>(<span class="methodparam"><span class="parameter"><strong class="parameter"><code>count</code></strong></span><span class="initializer">=-1</span></span>, <span class="methodparam"><span class="parameter"><strong class="parameter"><code>cancellable</code></strong></span><span class="initializer">=None</span></span>)</code></pre><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><p><span class="term"><strong class="parameter"><code>count</code></strong> :</span></p></td><td>optionally the number of bytes that will be read from the stream.
82 </td></tr><tr><td><p><span class="term"><strong class="parameter"><code>cancellable</code></strong> :</span></p></td><td>optional
83 <a class="link" href="class-giocancellable.html" title="gio.Cancellable"><code class="classname">gio.Cancellable</code></a>
84 object, <code class="literal">None</code> to ignore.
85 </td></tr><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td><td>The number of bytes read, or -1 on error.
86 </td></tr></tbody></table><p>
87 The <code class="methodname">read</code>() method tries to read count bytes from
88 the stream into the buffer starting at buffer. Will block during this read.
90 This function is similar to
91 <code class="methodname"><a class="link" href="class-gioinputstream.html#method-gioinputstream--read-part" title="gio.InputStream.read_part">gio.InputStream.read_part</a></code>(),
92 except it tries to read as many bytes as requested, only stopping on an error or end of stream.
94 On a successful read of count bytes, or if we reached the end of the stream,
95 <code class="literal">True</code> is returned, and bytes_read is set to the number of bytes read into buffer.
97 If cancellable is not <code class="literal">None</code>, then the operation can be cancelled by
98 triggering the cancellable object from another thread. If the operation was cancelled,
99 the error gio.ERROR_CANCELLED will be returned. Cancelling a close will still leave
100 the stream closed, but some streams can use a faster close that doesn't block to e.g.
103 If there is an error during the operation <code class="literal">False</code> is returned and error
104 is set to indicate the error status, bytes_read is updated to contain the number of
105 bytes read into buffer before the error occurred.
106 </p></div><div class="refsect2" title="gio.InputStream.read_async"><a name="method-gioinputstream--read-async"></a><h3>gio.InputStream.read_async</h3><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">read_async</span>(<span class="methodparam"><span class="parameter"><strong class="parameter"><code>count</code></strong></span></span>, <span class="methodparam"><span class="parameter"><strong class="parameter"><code>callback</code></strong></span></span>, <span class="methodparam"><span class="parameter"><strong class="parameter"><code>io_priority</code></strong></span><span class="initializer">=glib.PRIORITY_DEFAULT</span></span>, <span class="methodparam"><span class="parameter"><strong class="parameter"><code>cancellable</code></strong></span><span class="initializer">=None</span></span>, <span class="methodparam"><span class="parameter"><strong class="parameter"><code>user_data</code></strong></span><span class="initializer">=None</span></span>)</code></pre><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><p><span class="term"><em class="parameter"><code>count</code></em> :</span></p></td><td>the number of bytes that will be read from the stream.
107 </td></tr><tr><td><p><span class="term"><em class="parameter"><code>callback</code></em> :</span></p></td><td>a GAsyncReadyCallback to call when the request is satisfied.
108 </td></tr><tr><td><p><span class="term"><em class="parameter"><code>io_priority</code></em> :</span></p></td><td>the
109 <a class="xref" href="glib-constants.html#glib-priority-constants" title="Glib Priority Constants">Glib Priority Constants</a>
111 </td></tr><tr><td><p><span class="term"><em class="parameter"><code>cancellable</code></em> :</span></p></td><td>optional
112 <a class="link" href="class-giocancellable.html" title="gio.Cancellable"><code class="classname">gio.Cancellable</code></a>
113 object, <code class="literal">None</code> to ignore.</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.
114 </td></tr></tbody></table><p>
115 The <code class="methodname">read_async</code>() method requests an asynchronous read
116 of count bytes from the stream into the buffer.
118 For more details, see
119 <code class="methodname"><a class="link" href="class-gioinputstream.html#method-gioinputstream--read" title="gio.InputStream.read">gio.InputStream.read</a></code>()
120 which is the synchronous version of this call.
122 When the operation is finished, callback will be called. You can then call
123 <code class="methodname"><a class="link" href="class-gioinputstream.html#method-gioinputstream--read-finish" title="gio.InputStream.read_finish">gio.InputStream.read_finish</a></code>()
124 to get the result of the operation.
126 During an async request no other sync and async calls are allowed, and
127 will result in gio.ERROR_PENDING errors.
129 A value of count larger than G_MAXSSIZE will cause a gio.ERROR_INVALID_ARGUMENT error.
131 On success, the number of bytes read into the buffer will be passed to the callback.
132 It is not an error if this is not the same as the requested size, as it can happen e.g.
133 near the end of a file, but generally we try to read as many bytes as requested. Zero
134 is returned on end of file (or if count is zero), but never otherwise.
136 Any outstanding i/o request with higher priority (lower numerical value) will be
137 executed before an outstanding request with lower priority. Default priority is glib.PRIORITY_DEFAULT.
139 The asyncronous methods have a default fallback that uses threads to implement asynchronicity, so
140 they are optional for inheriting classes. However, if you override one you must override all.
141 </p></div><div class="refsect2" title="gio.InputStream.read_finish"><a name="method-gioinputstream--read-finish"></a><h3>gio.InputStream.read_finish</h3><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">read_finish</span>(<span class="methodparam"><span class="parameter"><strong class="parameter"><code>result</code></strong></span></span>)</code></pre><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><p><span class="term"><strong class="parameter"><code>result</code></strong> :</span></p></td><td>a <a class="link" href="class-gioasyncresult.html" title="gio.AsyncResult"><code class="classname">gio.AsyncResult</code></a>.
142 </td></tr><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td><td>The number of bytes read in, or -1 on error.
143 </td></tr></tbody></table><p>
144 The <code class="methodname">read_finish</code>() method finishes an asynchronous
145 stream read operation started by
146 <code class="methodname"><a class="link" href="class-gioinputstream.html#method-gioinputstream--read-async" title="gio.InputStream.read_async">gio.InputStream.read_async</a></code>().
147 </p></div><div class="refsect2" title="gio.InputStream.read_part"><a name="method-gioinputstream--read-part"></a><h3>gio.InputStream.read_part</h3><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">read_part</span>(<span class="methodparam"><span class="parameter"><strong class="parameter"><code>count</code></strong></span><span class="initializer">=-1</span></span>, <span class="methodparam"><span class="parameter"><strong class="parameter"><code>cancellable</code></strong></span><span class="initializer">=None</span></span>)</code></pre><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><p><span class="term"><strong class="parameter"><code>count</code></strong> :</span></p></td><td>optionally the number of bytes that will be read from the stream.
148 </td></tr><tr><td><p><span class="term"><strong class="parameter"><code>cancellable</code></strong> :</span></p></td><td>optional
149 <a class="link" href="class-giocancellable.html" title="gio.Cancellable"><code class="classname">gio.Cancellable</code></a>
150 object, <code class="literal">None</code> to ignore.
151 </td></tr><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td><td>The number of bytes read, or -1 on error.
152 </td></tr></tbody></table><p>
153 The <code class="methodname">read_part</code>() method tries to read count bytes from
154 the stream into the buffer starting at buffer. Will block during this read.
156 If count is zero returns zero and does nothing. A value of count larger than
157 G_MAXSSIZE will cause a gio.ERROR_INVALID_ARGUMENT error.
159 On success, the number of bytes read into the buffer is returned. It is
160 not an error if this is not the same as the requested size, as it can
161 happen e.g. near the end of a file. Zero is returned on end of file
162 (or if count is zero), but never otherwise.
164 If cancellable is not <code class="literal">None</code>, then the operation can be cancelled by
165 triggering the cancellable object from another thread. If the operation was cancelled,
166 the error gio.ERROR_CANCELLED will be returned. Cancelling a close will still leave
167 the stream closed, but some streams can use a faster close that doesn't block to e.g.
170 On error -1 is returned and error is set accordingly.
171 </p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3>
172 This method roughly corresponds to C GIO g_input_stream_read.
173 </div></div><div class="refsect2" title="gio.InputStream.set_pending"><a name="method-gioinputstream--set-pending"></a><h3>gio.InputStream.set_pending</h3><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">set_pending</span>(<span class="methodparam"></span>)</code></pre><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td><td><code class="literal">True</code> if pending was previously
174 unset and is now set.
175 </td></tr></tbody></table><p>
176 The <code class="methodname">set_pending</code>() method sets stream to have actions pending.
177 If the pending flag is already set or stream is closed,
178 it will return <code class="literal">False</code> and set error.
179 </p></div><div class="refsect2" title="gio.InputStream.skip"><a name="method-gioinputstream--skip"></a><h3>gio.InputStream.skip</h3><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">skip</span>(<span class="methodparam"><span class="parameter"><strong class="parameter"><code>count</code></strong></span></span>, <span class="methodparam"><span class="parameter"><strong class="parameter"><code>cancellable</code></strong></span><span class="initializer">=None</span></span>)</code></pre><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><p><span class="term"><strong class="parameter"><code>count</code></strong> :</span></p></td><td>the number of bytes that will be skipped from the stream.
180 </td></tr><tr><td><p><span class="term"><strong class="parameter"><code>cancellable</code></strong> :</span></p></td><td>optional
181 <a class="link" href="class-giocancellable.html" title="gio.Cancellable"><code class="classname">gio.Cancellable</code></a>
182 object, <code class="literal">None</code> to ignore.
183 </td></tr><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td><td>The number of bytes skipped, or -1 on error
184 </td></tr></tbody></table><p>
185 The <code class="methodname">skip</code>() method tries to skip count bytes
186 from the stream. Will block during the operation.
189 <code class="methodname"><a class="link" href="class-gioinputstream.html#method-gioinputstream--read" title="gio.InputStream.read">read</a></code>(),
190 from a behaviour standpoint, but the bytes that are skipped are not
191 returned to the user. Some streams have an implementation that is more
192 efficient than reading the data.
194 This function is optional for inherited classes, as the default implementation emulates it using read.
196 If cancellable is not <code class="literal">None</code>, then the operation can be cancelled by
197 triggering the cancellable object from another thskip. If the operation was cancelled,
198 the error gio.ERROR_CANCELLED will be returned. Cancelling a close will still leave
199 the stream closed, but some streams can use a faster close that doesn't block to e.g.
201 </p></div><div class="refsect2" title="gio.InputStream.skip_async"><a name="method-gioinputstream--skip-async"></a><h3>gio.InputStream.skip_async</h3><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">skip_async</span>(<span class="methodparam"><span class="parameter"><strong class="parameter"><code>count</code></strong></span></span>, <span class="methodparam"><span class="parameter"><strong class="parameter"><code>callback</code></strong></span></span>, <span class="methodparam"><span class="parameter"><strong class="parameter"><code>io_priority</code></strong></span><span class="initializer">=glib.PRIORITY_DEFAULT</span></span>, <span class="methodparam"><span class="parameter"><strong class="parameter"><code>cancellable</code></strong></span><span class="initializer">=None</span></span>, <span class="methodparam"><span class="parameter"><strong class="parameter"><code>user_data</code></strong></span><span class="initializer">=None</span></span>)</code></pre><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><p><span class="term"><em class="parameter"><code>count</code></em> :</span></p></td><td>the number of bytes that will be skipped from the stream.
202 </td></tr><tr><td><p><span class="term"><em class="parameter"><code>callback</code></em> :</span></p></td><td>a GAsyncskipyCallback to call when the request is satisfied.
203 </td></tr><tr><td><p><span class="term"><em class="parameter"><code>io_priority</code></em> :</span></p></td><td>the
204 <a class="xref" href="glib-constants.html#glib-priority-constants" title="Glib Priority Constants">Glib Priority Constants</a>
206 </td></tr><tr><td><p><span class="term"><em class="parameter"><code>cancellable</code></em> :</span></p></td><td>optional
207 <a class="link" href="class-giocancellable.html" title="gio.Cancellable"><code class="classname">gio.Cancellable</code></a>
208 object, <code class="literal">None</code> to ignore.</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.
209 </td></tr></tbody></table><p>
210 The <code class="methodname">skip_async</code>() method request an asynchronous
211 skip of count bytes from the stream.
213 For more details, see
214 <code class="methodname"><a class="link" href="class-gioinputstream.html#method-gioinputstream--skip" title="gio.InputStream.skip">gio.InputStream.skip</a></code>()
215 which is the synchronous version of this call.
217 When the operation is finished, callback will be called. You can then call
218 <code class="methodname"><a class="link" href="class-gioinputstream.html#method-gioinputstream--skip-finish" title="gio.InputStream.skip_finish">gio.InputStream.skip_finish</a></code>()
219 to get the result of the operation.
221 During an async request no other sync and async calls are allowed, and
222 will result in gio.ERROR_PENDING errors.
224 A value of count larger than G_MAXSSIZE will cause a gio.ERROR_INVALID_ARGUMENT error.
226 On success, the number of bytes skipped will be passed to the callback. It is
227 not an error if this is not the same as the requested size, as it can happen
228 e.g. near the end of a file, but generally we try to skip as many bytes as requested.
229 Zero is returned on end of file (or if count is zero), but never otherwise.
231 Any outstanding i/o request with higher priority (lower numerical value) will be
232 executed before an outstanding request with lower priority. Default priority is glib.PRIORITY_DEFAULT.
234 The asyncronous methods have a default fallback that uses thskips to implement asynchronicity, so
235 they are optional for inheriting classes. However, if you override one you must override all.
236 </p></div><div class="refsect2" title="gio.InputStream.skip_finish"><a name="method-gioinputstream--skip-finish"></a><h3>gio.InputStream.skip_finish</h3><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">skip_finish</span>(<span class="methodparam"><span class="parameter"><strong class="parameter"><code>result</code></strong></span></span>)</code></pre><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><p><span class="term"><strong class="parameter"><code>result</code></strong> :</span></p></td><td>a <a class="link" href="class-gioasyncresult.html" title="gio.AsyncResult"><code class="classname">gio.AsyncResult</code></a>.
237 </td></tr><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td><td>The number of bytes skipped in, or -1 on error.
238 </td></tr></tbody></table><p>
239 The <code class="methodname">skip_finish</code>() method finishes an asynchronous
240 stream skip operation started by
241 <code class="methodname"><a class="link" href="class-gioinputstream.html#method-gioinputstream--skip-async" title="gio.InputStream.skip_async">gio.InputStream.skip_async</a></code>().
242 </p></div></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="class-gioicon.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="gio-class-reference.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="class-gioloadableicon.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">gio.Icon </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> gio.LoadableIcon</td></tr></table></div></body></html>