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

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

Initial release

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