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

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

Initial release

File size: 6.5 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.FileIOStream;
22
23private import gi.gio;
24public  import gi.giotypes;
25private import gio.AsyncResultIF;
26private import gio.Cancellable;
27private import gio.FileInfo;
28private import gio.IOStream;
29private import gio.SeekableIF;
30private import gio.SeekableT;
31private import glib.ErrorG;
32private import glib.GException;
33private import glib.Str;
34private import gobject.ObjectG;
35
36
37/**
38 * GFileIOStream provides io streams that both read and write to the same
39 * file handle.
40 *
41 * GFileIOStream implements #GSeekable, which allows the io
42 * stream to jump to arbitrary positions in the file and to truncate
43 * the file, provided the filesystem of the file supports these
44 * operations.
45 *
46 * To find the position of a file io stream, use
47 * g_seekable_tell().
48 *
49 * To find out if a file io stream supports seeking, use g_seekable_can_seek().
50 * To position a file io stream, use g_seekable_seek().
51 * To find out if a file io stream supports truncating, use
52 * g_seekable_can_truncate(). To truncate a file io
53 * stream, use g_seekable_truncate().
54 *
55 * The default implementation of all the #GFileIOStream operations
56 * and the implementation of #GSeekable just call into the same operations
57 * on the output stream.
58 */
59public class FileIOStream : IOStream, SeekableIF
60{
61        /** the main Gtk struct */
62        protected GFileIOStream* gFileIOStream;
63
64        /** Get the main Gtk struct */
65        public GFileIOStream* getFileIOStreamStruct()
66        {
67                return gFileIOStream;
68        }
69
70        /** the main Gtk struct as a void* */
71        protected override void* getStruct()
72        {
73                return cast(void*)gFileIOStream;
74        }
75
76        protected override void setStruct(GObject* obj)
77        {
78                gFileIOStream = cast(GFileIOStream*)obj;
79                super.setStruct(obj);
80        }
81
82        /**
83         * Sets our main struct and passes it to the parent class.
84         */
85        public this (GFileIOStream* gFileIOStream, bool ownedRef = false)
86        {
87                this.gFileIOStream = gFileIOStream;
88                super(cast(GIOStream*)gFileIOStream, ownedRef);
89        }
90
91        // add the Seekable capabilities
92        mixin SeekableT!(GFileIOStream);
93
94
95        /** */
96        public static GType getType()
97        {
98                return g_file_io_stream_get_type();
99        }
100
101        /**
102         * Gets the entity tag for the file when it has been written.
103         * This must be called after the stream has been written
104         * and closed, as the etag can change while writing.
105         *
106         * Returns: the entity tag for the stream.
107         *
108         * Since: 2.22
109         */
110        public string getEtag()
111        {
112                auto retStr = g_file_io_stream_get_etag(gFileIOStream);
113               
114                scope(exit) Str.freeString(retStr);
115                return Str.toString(retStr);
116        }
117
118        /**
119         * Queries a file io stream for the given @attributes.
120         * This function blocks while querying the stream. For the asynchronous
121         * version of this function, see g_file_io_stream_query_info_async().
122         * While the stream is blocked, the stream will set the pending flag
123         * internally, and any other operations on the stream will fail with
124         * %G_IO_ERROR_PENDING.
125         *
126         * Can fail if the stream was already closed (with @error being set to
127         * %G_IO_ERROR_CLOSED), the stream has pending operations (with @error being
128         * set to %G_IO_ERROR_PENDING), or if querying info is not supported for
129         * the stream's interface (with @error being set to %G_IO_ERROR_NOT_SUPPORTED). I
130         * all cases of failure, %NULL will be returned.
131         *
132         * If @cancellable is not %NULL, then the operation can be cancelled by
133         * triggering the cancellable object from another thread. If the operation
134         * was cancelled, the error %G_IO_ERROR_CANCELLED will be set, and %NULL will
135         * be returned.
136         *
137         * Params:
138         *     attributes = a file attribute query string.
139         *     cancellable = optional #GCancellable object, %NULL to ignore.
140         *
141         * Returns: a #GFileInfo for the @stream, or %NULL on error.
142         *
143         * Since: 2.22
144         *
145         * Throws: GException on failure.
146         */
147        public FileInfo queryInfo(string attributes, Cancellable cancellable)
148        {
149                GError* err = null;
150               
151                auto p = g_file_io_stream_query_info(gFileIOStream, Str.toStringz(attributes), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err);
152               
153                if (err !is null)
154                {
155                        throw new GException( new ErrorG(err) );
156                }
157               
158                if(p is null)
159                {
160                        return null;
161                }
162               
163                return ObjectG.getDObject!(FileInfo)(cast(GFileInfo*) p, true);
164        }
165
166        /**
167         * Asynchronously queries the @stream for a #GFileInfo. When completed,
168         * @callback will be called with a #GAsyncResult which can be used to
169         * finish the operation with g_file_io_stream_query_info_finish().
170         *
171         * For the synchronous version of this function, see
172         * g_file_io_stream_query_info().
173         *
174         * Params:
175         *     attributes = a file attribute query string.
176         *     ioPriority = the [I/O priority][gio-GIOScheduler] of the request
177         *     cancellable = optional #GCancellable object, %NULL to ignore.
178         *     callback = callback to call when the request is satisfied
179         *     userData = the data to pass to callback function
180         *
181         * Since: 2.22
182         */
183        public void queryInfoAsync(string attributes, int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)
184        {
185                g_file_io_stream_query_info_async(gFileIOStream, Str.toStringz(attributes), ioPriority, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData);
186        }
187
188        /**
189         * Finalizes the asynchronous query started
190         * by g_file_io_stream_query_info_async().
191         *
192         * Params:
193         *     result = a #GAsyncResult.
194         *
195         * Returns: A #GFileInfo for the finished query.
196         *
197         * Since: 2.22
198         *
199         * Throws: GException on failure.
200         */
201        public FileInfo queryInfoFinish(AsyncResultIF result)
202        {
203                GError* err = null;
204               
205                auto p = g_file_io_stream_query_info_finish(gFileIOStream, (result is null) ? null : result.getAsyncResultStruct(), &err);
206               
207                if (err !is null)
208                {
209                        throw new GException( new ErrorG(err) );
210                }
211               
212                if(p is null)
213                {
214                        return null;
215                }
216               
217                return ObjectG.getDObject!(FileInfo)(cast(GFileInfo*) p, true);
218        }
219}
Note: See TracBrowser for help on using the repository browser.