root/trunk/src/gio/FileOutputStream.d

Revision 938, 7.8 kB (checked in by Mike Wey, 3 months ago)

Update Gio to 2.28.

Line 
1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19  
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23
24 /*
25  * Conversion parameters:
26  * inFile  = GFileOutputStream.html
27  * outPack = gio
28  * outFile = FileOutputStream
29  * strct   = GFileOutputStream
30  * realStrct=
31  * ctorStrct=
32  * clss    = FileOutputStream
33  * interf  =
34  * class Code: Yes
35  * interface Code: No
36  * template for:
37  * extend  =
38  * implements:
39  *  - SeekableIF
40  * prefixes:
41  *  - g_file_output_stream_
42  * omit structs:
43  * omit prefixes:
44  * omit code:
45  * omit signals:
46  * imports:
47  *  - glib.Str
48  *  - glib.ErrorG
49  *  - glib.GException
50  *  - gio.AsyncResultIF
51  *  - gio.Cancellable
52  *  - gio.FileInfo
53  *  - gio.SeekableT
54  *  - gio.SeekableIF
55  * structWrap:
56  *  - GAsyncResult* -> AsyncResultIF
57  *  - GCancellable* -> Cancellable
58  *  - GFileInfo* -> FileInfo
59  * module aliases:
60  * local aliases:
61  * overrides:
62  */
63
64 module gio.FileOutputStream;
65
66 public  import gtkc.giotypes;
67
68 private import gtkc.gio;
69 private import glib.ConstructionException;
70
71
72 private import glib.Str;
73 private import glib.ErrorG;
74 private import glib.GException;
75 private import gio.AsyncResultIF;
76 private import gio.Cancellable;
77 private import gio.FileInfo;
78 private import gio.SeekableT;
79 private import gio.SeekableIF;
80
81
82
83 private import gio.OutputStream;
84
85 /**
86  * Description
87  * GFileOutputStream provides output streams that write their
88  * content to a file.
89  * GFileOutputStream implements GSeekable, which allows the output
90  * stream to jump to arbitrary positions in the file and to truncate
91  * the file, provided the filesystem of the file supports these
92  * operations.
93  * To find the position of a file output stream, use g_seekable_tell().
94  * To find out if a file output stream supports seeking, use
95  * g_seekable_can_seek().To position a file output stream, use
96  * g_seekable_seek(). To find out if a file output stream supports
97  * truncating, use g_seekable_can_truncate(). To truncate a file output
98  * stream, use g_seekable_truncate().
99  */
100 public class FileOutputStream : OutputStream, SeekableIF
101 {
102    
103     /** the main Gtk struct */
104     protected GFileOutputStream* gFileOutputStream;
105    
106    
107     public GFileOutputStream* getFileOutputStreamStruct()
108     {
109         return gFileOutputStream;
110     }
111    
112    
113     /** the main Gtk struct as a void* */
114     protected override void* getStruct()
115     {
116         return cast(void*)gFileOutputStream;
117     }
118    
119     /**
120      * Sets our main struct and passes it to the parent class
121      */
122     public this (GFileOutputStream* gFileOutputStream)
123     {
124         if(gFileOutputStream is null)
125         {
126             this = null;
127             return;
128         }
129         //Check if there already is a D object for this gtk struct
130         void* ptr = getDObject(cast(GObject*)gFileOutputStream);
131         if( ptr !is null )
132         {
133             this = cast(FileOutputStream)ptr;
134             return;
135         }
136         super(cast(GOutputStream*)gFileOutputStream);
137         this.gFileOutputStream = gFileOutputStream;
138     }
139    
140     protected override void setStruct(GObject* obj)
141     {
142         super.setStruct(obj);
143         gFileOutputStream = cast(GFileOutputStream*)obj;
144     }
145    
146     // add the Seekable capabilities
147     mixin SeekableT!(GFileOutputStream);
148    
149     /**
150      */
151    
152     /**
153      * Queries a file output stream for the given attributes.
154      * This function blocks while querying the stream. For the asynchronous
155      * version of this function, see g_file_output_stream_query_info_async().
156      * While the stream is blocked, the stream will set the pending flag
157      * internally, and any other operations on the stream will fail with
158      * G_IO_ERROR_PENDING.
159      * Can fail if the stream was already closed (with error being set to
160      * G_IO_ERROR_CLOSED), the stream has pending operations (with error being
161      * set to G_IO_ERROR_PENDING), or if querying info is not supported for
162      * the stream's interface (with error being set to G_IO_ERROR_NOT_SUPPORTED). In
163      * all cases of failure, NULL will be returned.
164      * If cancellable is not NULL, then the operation can be cancelled by
165      * triggering the cancellable object from another thread. If the operation
166      * was cancelled, the error G_IO_ERROR_CANCELLED will be set, and NULL will
167      * be returned.
168      * Params:
169      * attributes = a file attribute query string.
170      * cancellable = optional GCancellable object, NULL to ignore.
171      * Returns: a GFileInfo for the stream, or NULL on error. [transfer full]
172      * Throws: GException on failure.
173      */
174     public FileInfo queryInfo(string attributes, Cancellable cancellable)
175     {
176         // GFileInfo * g_file_output_stream_query_info (GFileOutputStream *stream,  const char *attributes,  GCancellable *cancellable,  GError **error);
177         GError* err = null;
178        
179         auto p = g_file_output_stream_query_info(gFileOutputStream, Str.toStringz(attributes), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err);
180        
181         if (err !is null)
182         {
183             throw new GException( new ErrorG(err) );
184         }
185        
186         if(p is null)
187         {
188             return null;
189         }
190         return new FileInfo(cast(GFileInfo*) p);
191     }
192    
193     /**
194      * Asynchronously queries the stream for a GFileInfo. When completed,
195      * callback will be called with a GAsyncResult which can be used to
196      * finish the operation with g_file_output_stream_query_info_finish().
197      * For the synchronous version of this function, see
198      * g_file_output_stream_query_info().
199      * Params:
200      * attributes = a file attribute query string.
201      * ioPriority = the I/O priority
202      * of the request.
203      * cancellable = optional GCancellable object, NULL to ignore.
204      * callback = callback to call when the request is satisfied
205      * userData = the data to pass to callback function
206      */
207     public void queryInfoAsync(string attributes, int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)
208     {
209         // void g_file_output_stream_query_info_async  (GFileOutputStream *stream,  const char *attributes,  int io_priority,  GCancellable *cancellable,  GAsyncReadyCallback callback,  gpointer user_data);
210         g_file_output_stream_query_info_async(gFileOutputStream, Str.toStringz(attributes), ioPriority, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData);
211     }
212    
213     /**
214      * Finalizes the asynchronous query started
215      * by g_file_output_stream_query_info_async().
216      * Params:
217      * result = a GAsyncResult.
218      * Returns: A GFileInfo for the finished query. [transfer full]
219      * Throws: GException on failure.
220      */
221     public FileInfo queryInfoFinish(AsyncResultIF result)
222     {
223         // GFileInfo * g_file_output_stream_query_info_finish  (GFileOutputStream *stream,  GAsyncResult *result,  GError **error);
224         GError* err = null;
225        
226         auto p = g_file_output_stream_query_info_finish(gFileOutputStream, (result is null) ? null : result.getAsyncResultTStruct(), &err);
227        
228         if (err !is null)
229         {
230             throw new GException( new ErrorG(err) );
231         }
232        
233         if(p is null)
234         {
235             return null;
236         }
237         return new FileInfo(cast(GFileInfo*) p);
238     }
239    
240     /**
241      * Gets the entity tag for the file when it has been written.
242      * This must be called after the stream has been written
243      * and closed, as the etag can change while writing.
244      * Returns: the entity tag for the stream.
245      */
246     public string getEtag()
247     {
248         // char * g_file_output_stream_get_etag (GFileOutputStream *stream);
249         return Str.toString(g_file_output_stream_get_etag(gFileOutputStream));
250     }
251 }
Note: See TracBrowser for help on using the browser.