source: appstream-generator/build/girepo/gio/SeekableT.d @ 4841

Last change on this file since 4841 was 4841, checked in by Juanma, 2 years ago

Initial release

File size: 4.8 KB
Line 
1/*
2 * Licensed under the GNU Lesser General Public License Version 3
3 *
4 * This library is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation, either version 3 of the license, or
7 * (at your option) any later version.
8 *
9 * This software is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 * GNU Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this library.  If not, see <http://www.gnu.org/licenses/>.
16 */
17
18// generated automatically - do not change
19
20
21module gio.SeekableT;
22
23public  import gi.gio;
24public  import gi.giotypes;
25public  import gio.Cancellable;
26public  import glib.ErrorG;
27public  import glib.GException;
28
29
30/**
31 * #GSeekable is implemented by streams (implementations of
32 * #GInputStream or #GOutputStream) that support seeking.
33 *
34 * Seekable streams largely fall into two categories: resizable and
35 * fixed-size.
36 *
37 * #GSeekable on fixed-sized streams is approximately the same as POSIX
38 * lseek() on a block device (for example: attmepting to seek past the
39 * end of the device is an error).  Fixed streams typically cannot be
40 * truncated.
41 *
42 * #GSeekable on resizable streams is approximately the same as POSIX
43 * lseek() on a normal file.  Seeking past the end and writing data will
44 * usually cause the stream to resize by introducing zero bytes.
45 */
46public template SeekableT(TStruct)
47{
48        /** Get the main Gtk struct */
49        public GSeekable* getSeekableStruct()
50        {
51                return cast(GSeekable*)getStruct();
52        }
53
54
55        /**
56         * Tests if the stream supports the #GSeekableIface.
57         *
58         * Returns: %TRUE if @seekable can be seeked. %FALSE otherwise.
59         */
60        public bool canSeek()
61        {
62                return g_seekable_can_seek(getSeekableStruct()) != 0;
63        }
64
65        /**
66         * Tests if the stream can be truncated.
67         *
68         * Returns: %TRUE if the stream can be truncated, %FALSE otherwise.
69         */
70        public bool canTruncate()
71        {
72                return g_seekable_can_truncate(getSeekableStruct()) != 0;
73        }
74
75        /**
76         * Seeks in the stream by the given @offset, modified by @type.
77         *
78         * Attempting to seek past the end of the stream will have different
79         * results depending on if the stream is fixed-sized or resizable.  If
80         * the stream is resizable then seeking past the end and then writing
81         * will result in zeros filling the empty space.  Seeking past the end
82         * of a resizable stream and reading will result in EOF.  Seeking past
83         * the end of a fixed-sized stream will fail.
84         *
85         * Any operation that would result in a negative offset will fail.
86         *
87         * If @cancellable is not %NULL, then the operation can be cancelled by
88         * triggering the cancellable object from another thread. If the operation
89         * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned.
90         *
91         * Params:
92         *     offset = a #goffset.
93         *     type = a #GSeekType.
94         *     cancellable = optional #GCancellable object, %NULL to ignore.
95         *
96         * Returns: %TRUE if successful. If an error
97         *     has occurred, this function will return %FALSE and set @error
98         *     appropriately if present.
99         *
100         * Throws: GException on failure.
101         */
102        public bool seek(long offset, GSeekType type, Cancellable cancellable)
103        {
104                GError* err = null;
105               
106                auto p = g_seekable_seek(getSeekableStruct(), offset, type, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err) != 0;
107               
108                if (err !is null)
109                {
110                        throw new GException( new ErrorG(err) );
111                }
112               
113                return p;
114        }
115
116        /**
117         * Tells the current position within the stream.
118         *
119         * Returns: the offset from the beginning of the buffer.
120         */
121        public long tell()
122        {
123                return g_seekable_tell(getSeekableStruct());
124        }
125
126        /**
127         * Truncates a stream with a given #offset.
128         *
129         * If @cancellable is not %NULL, then the operation can be cancelled by
130         * triggering the cancellable object from another thread. If the operation
131         * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. If an
132         * operation was partially finished when the operation was cancelled the
133         * partial result will be returned, without an error.
134         *
135         * Params:
136         *     offset = a #goffset.
137         *     cancellable = optional #GCancellable object, %NULL to ignore.
138         *
139         * Returns: %TRUE if successful. If an error
140         *     has occurred, this function will return %FALSE and set @error
141         *     appropriately if present.
142         *
143         * Throws: GException on failure.
144         */
145        public bool truncate(long offset, Cancellable cancellable)
146        {
147                GError* err = null;
148               
149                auto p = g_seekable_truncate(getSeekableStruct(), offset, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err) != 0;
150               
151                if (err !is null)
152                {
153                        throw new GException( new ErrorG(err) );
154                }
155               
156                return p;
157        }
158}
Note: See TracBrowser for help on using the repository browser.