summaryrefslogtreecommitdiffstats
path: root/docs/reference/pygio-seekable.xml
blob: 1081143b8ecd3f2fb1f20414553bcccb7a58e506 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
<?xml version="1.0" standalone="no"?>
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
    "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd">

<refentry id="class-gioseekable">
    <refnamediv>
        <refname>gio.Seekable</refname>
        <refpurpose>Stream seeking interface.</refpurpose>
    </refnamediv>

    <refsect1>
        <title>Synopsis</title>

    <classsynopsis language="python">
        <ooclass><classname>gio.Seekable</classname></ooclass>
        <ooclass><classname><link linkend="class-gobjectginterface">gobject.GInterface</link></classname></ooclass>

    <methodsynopsis language="python">
        <methodname><link linkend="method-gioseekable--tell">tell</link></methodname>
    </methodsynopsis>
    
    <methodsynopsis language="python">
        <methodname><link linkend="method-gioseekable--can_seek">can_seek</link></methodname>
    </methodsynopsis>
    
    <methodsynopsis language="python">
        <methodname><link linkend="method-gioseekable--seek">seek</link></methodname>
        <methodparam><parameter role="keyword">offset</parameter></methodparam>
        <methodparam><parameter role="keyword">type</parameter><initializer>0</initializer></methodparam>
        <methodparam><parameter role="keyword">cancellable</parameter><initializer><literal>None</literal></initializer></methodparam>
    </methodsynopsis>
    
    <methodsynopsis language="python">
        <methodname><link linkend="method-gioseekable--can_truncate">can_truncate</link></methodname>
    </methodsynopsis>
    
    <methodsynopsis language="python">
        <methodname><link linkend="method-gioseekable--truncate">truncate</link></methodname>
        <methodparam><parameter role="keyword">offset</parameter></methodparam>
        <methodparam><parameter role="keyword">cancellable</parameter><initializer><literal>None</literal></initializer></methodparam>
    </methodsynopsis>
    
    </classsynopsis>

    </refsect1>

    <refsect1>
        <title>Ancestry</title>

<synopsis>+-- <link linkend="class-gobjectginterface">gobject.GInterface</link>
  +-- <link linkend="class-gioseekable">gio.Seekable</link>
</synopsis>

    </refsect1>

    <refsect1>
	<title>Known Implementation</title>
        <para>
            <link linkend="class-gioseekable"><classname>gio.Seekable</classname></link> is implemented by
            <link linkend="class-giofileoutputstream"><classname>gio.FileOutputStream</classname></link>,
            <link linkend="class-giomemoryinputstream"><classname>gio.MemoryInputStream</classname></link>,
            <link linkend="class-giofileinputstream"><classname>gio.FileInputStream</classname></link> and
            <link linkend="class-giomemoryoutputstream"><classname>gio.MemoryOutputStream</classname></link>.
        </para>
    </refsect1>

    <refsect1>
        <title>Description</title>

        <para>
            <link linkend="class-gioseekable"><classname>gio.Seekable</classname></link>
            is implemented by streams (implementations of 
            <link linkend="class-gioinputstream"><classname>gio.InputStream</classname></link> or
            <link linkend="class-giooutputstream"><classname>gio.OutputStream</classname></link>)
            that support seeking.
        </para>
    </refsect1>

    <refsect1>
        <title>Methods</title>

        <refsect2 id="method-gioseekable--tell">
            <title>gio.Seekable.tell</title>

            <programlisting><methodsynopsis language="python">
                <methodname>tell</methodname>
            </methodsynopsis></programlisting>
            
            <variablelist>
                <varlistentry>
                    <term><emphasis>Returns</emphasis>&nbsp;:</term>
                    <listitem><simpara>
                            the offset from the beginning of the buffer
                    </simpara></listitem>
                </varlistentry>
            </variablelist>
    
            <para>
                Tells the current position within the stream.
            </para>
        </refsect2>

        <refsect2 id="method-gioseekable--can_seek">
            <title>gio.Seekable.can_seek</title>

            <programlisting><methodsynopsis language="python">
                <methodname>can_seek</methodname>
            </methodsynopsis></programlisting>
            
            <variablelist>
                <varlistentry>
                    <term><emphasis>Returns</emphasis>&nbsp;:</term>
                    <listitem><simpara><literal>True</literal> if this
                    <classname>gio.Seekable</classname> can be seeked with
                    the <methodname>seek</methodname>() method, <literal>False</literal>
                    if not. </simpara></listitem>
                </varlistentry>
            </variablelist>
    
            <para>
                The <methodname>can_seek</methodname>() method checks if the
                <link linkend="method-gioseekable--seek"><methodname>seek</methodname>()</link>
                can be used on this <classname>gio.Seekable</classname>.
            </para>
        </refsect2>
        <refsect2 id="method-gioseekable--seek">
            <title>gio.Seekable.seek</title>

            <programlisting><methodsynopsis language="python">
                <methodname>seek</methodname>
                <methodparam><parameter role="keyword">offset</parameter></methodparam>
                <methodparam><parameter role="keyword">type</parameter><initializer>0</initializer></methodparam>
                <methodparam><parameter role="keyword">cancellable</parameter><initializer><literal>None</literal></initializer></methodparam>
            </methodsynopsis></programlisting>
            
            <variablelist>
                <varlistentry>
                    <term><parameter>offset</parameter>&nbsp;:</term>
                    <listitem><simpara>the offset that is added to the position determined by the <literal>type</literal> parameter.
                    </simpara></listitem>
                </varlistentry>
                <varlistentry>
                    <term><parameter>type</parameter>&nbsp;:</term>
                    <listitem><simpara>0=current position, 1=start of the file, 2=end of the file.</simpara></listitem>
                </varlistentry>
                <varlistentry>
                    <term><parameter>cancellable</parameter>&nbsp;:</term>
                    <listitem><simpara>a <link linkend="class-giocancellable"><classname>gio.Cancellable</classname></link>
                    or <literal>None</literal>.</simpara></listitem>
                </varlistentry>
                <varlistentry>
                    <term><emphasis>Returns</emphasis>&nbsp;:</term>
                    <listitem><simpara><literal>True</literal> on successful seek,
                    <literal>False</literal> otherwise.
                    </simpara></listitem>
                </varlistentry>
            </variablelist>
    
            <para>
                Seeks in the stream by the given <literal>offset</literal>, modified by <literal>type</literal>.
            </para>
            <para>
                If <literal>cancellable</literal> is not <literal>None</literal>, then the
                operation can be cancelled by triggering the cancellable object from another thread.
            </para>
        </refsect2>
        <refsect2 id="method-gioseekable--can_truncate">
            <title>gio.Seekable.can_truncate</title>

            <programlisting><methodsynopsis language="python">
                <methodname>can_truncate</methodname>
            </methodsynopsis></programlisting>
            
            <variablelist>
                <varlistentry>
                    <term><emphasis>Returns</emphasis>&nbsp;:</term>
                    <listitem><simpara><literal>True</literal> if this
                    <classname>gio.Seekable</classname> can be truncated with
                    the <methodname>truncate</methodname>() method, <literal>False</literal>
                    if not. </simpara></listitem>
                </varlistentry>
            </variablelist>
    
            <para>
                The <methodname>can_truncate</methodname>() method checks if the
                <link linkend="method-gioseekable--truncate"><methodname>truncate</methodname>()</link>
                can be used on this <classname>gio.Seekable</classname>.
            </para>
        </refsect2>
        <refsect2 id="method-gioseekable--truncate">
            <title>gio.Seekable.truncate</title>

            <programlisting><methodsynopsis language="python">
                <methodname>truncate</methodname>
                <methodparam><parameter role="keyword">offset</parameter></methodparam>
                <methodparam><parameter role="keyword">cancellable</parameter><initializer><literal>None</literal></initializer></methodparam>
            </methodsynopsis></programlisting>
            
            <variablelist>
                <varlistentry>
                    <term><parameter>offset</parameter>&nbsp;:</term>
                    <listitem><simpara>the offset at which the stream should be truncated
                    </simpara></listitem>
                </varlistentry>
                <varlistentry>
                    <term><parameter>cancellable</parameter>&nbsp;:</term>
                    <listitem><simpara>a <link linkend="class-giocancellable"><classname>gio.Cancellable</classname></link>
                    or <literal>None</literal>.</simpara></listitem>
                </varlistentry>
                <varlistentry>
                    <term><emphasis>Returns</emphasis>&nbsp;:</term>
                    <listitem><simpara><literal>True</literal> if successful,
                    <literal>False</literal> otherwise.
                    </simpara></listitem>
                </varlistentry>
            </variablelist>
    
            <para>
                Truncates a stream with a given <literal>offset</literal>.
            </para>
            <para>
                If <literal>cancellable</literal> is not <literal>None</literal>, then the
                operation can be cancelled by triggering the cancellable object from another thread.
            </para>
            <para>
                If an operation was partially finished when the operation was cancelled the
                partial result will be returned, without an error.
            </para>
        </refsect2>
    </refsect1>
</refentry>