root/trunk/src/gio/FileIOStream.d

Revision 938, 7.9 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  = GFileIOStream.html
27  * outPack = gio
28  * outFile = FileIOStream
29  * strct   = GFileIOStream
30  * realStrct=
31  * ctorStrct=
32  * clss    = FileIOStream
33  * interf  =
34  * class Code: Yes
35  * interface Code: No
36  * template for:
37  * extend  =
38  * implements:
39  *  - SeekableIF
40  * prefixes:
41  *  - g_file_io_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.FileIOStream;
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.IOStream;
84
85 /**
86  * Description
87  * GFileIOStream provides io streams that both read and write to the same
88  * file handle.
89  * GFileIOStream implements GSeekable, which allows the io
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 io stream, use
94  * g_seekable_tell().
95  * To find out if a file io stream supports seeking, use g_seekable_can_seek().
96  * To position a file io stream, use g_seekable_seek().
97  * To find out if a file io stream supports truncating, use
98  * g_seekable_can_truncate(). To truncate a file io
99  * stream, use g_seekable_truncate().
100  * The default implementation of all the GFileIOStream operations
101  * and the implementation of GSeekable just call into the same operations
102  * on the output stream.
103  */
104 public class FileIOStream : IOStream, SeekableIF
105 {
106    
107     /** the main Gtk struct */
108     protected GFileIOStream* gFileIOStream;
109    
110    
111     public GFileIOStream* getFileIOStreamStruct()
112     {
113         return gFileIOStream;
114     }
115    
116    
117     /** the main Gtk struct as a void* */
118     protected override void* getStruct()
119     {
120         return cast(void*)gFileIOStream;
121     }
122    
123     /**
124      * Sets our main struct and passes it to the parent class
125      */
126     public this (GFileIOStream* gFileIOStream)
127     {
128         if(gFileIOStream is null)
129         {
130             this = null;
131             return;
132         }
133         //Check if there already is a D object for this gtk struct
134         void* ptr = getDObject(cast(GObject*)gFileIOStream);
135         if( ptr !is null )
136         {
137             this = cast(FileIOStream)ptr;
138             return;
139         }
140         super(cast(GIOStream*)gFileIOStream);
141         this.gFileIOStream = gFileIOStream;
142     }
143    
144     protected override void setStruct(GObject* obj)
145     {
146         super.setStruct(obj);
147         gFileIOStream = cast(GFileIOStream*)obj;
148     }
149    
150     // add the Seekable capabilities
151     mixin SeekableT!(GFileIOStream);
152    
153     /**
154      */
155    
156     /**
157      * Gets the entity tag for the file when it has been written.
158      * This must be called after the stream has been written
159      * and closed, as the etag can change while writing.
160      * Since 2.22
161      * Returns: the entity tag for the stream.
162      */
163     public string getEtag()
164     {
165         // char * g_file_io_stream_get_etag (GFileIOStream *stream);
166         return Str.toString(g_file_io_stream_get_etag(gFileIOStream));
167     }
168    
169     /**
170      * Queries a file io stream for the given attributes.
171      * This function blocks while querying the stream. For the asynchronous
172      * version of this function, see g_file_io_stream_query_info_async().
173      * While the stream is blocked, the stream will set the pending flag
174      * internally, and any other operations on the stream will fail with
175      * G_IO_ERROR_PENDING.
176      * Can fail if the stream was already closed (with error being set to
177      * G_IO_ERROR_CLOSED), the stream has pending operations (with error being
178      * set to G_IO_ERROR_PENDING), or if querying info is not supported for
179      * the stream's interface (with error being set to G_IO_ERROR_NOT_SUPPORTED). I
180      * all cases of failure, NULL will be returned.
181      * If cancellable is not NULL, then the operation can be cancelled by
182      * triggering the cancellable object from another thread. If the operation
183      * was cancelled, the error G_IO_ERROR_CANCELLED will be set, and NULL will
184      * be returned.
185      * Since 2.22
186      * Params:
187      * attributes = a file attribute query string.
188      * cancellable = optional GCancellable object, NULL to ignore. [allow-none]
189      * Returns: a GFileInfo for the stream, or NULL on error. [transfer full]
190      * Throws: GException on failure.
191      */
192     public FileInfo queryInfo(string attributes, Cancellable cancellable)
193     {
194         // GFileInfo * g_file_io_stream_query_info (GFileIOStream *stream,  const char *attributes,  GCancellable *cancellable,  GError **error);
195         GError* err = null;
196        
197         auto p = g_file_io_stream_query_info(gFileIOStream, Str.toStringz(attributes), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err);
198        
199         if (err !is null)
200         {
201             throw new GException( new ErrorG(err) );
202         }
203        
204         if(p is null)
205         {
206             return null;
207         }
208         return new FileInfo(cast(GFileInfo*) p);
209     }
210    
211     /**
212      * Asynchronously queries the stream for a GFileInfo. When completed,
213      * callback will be called with a GAsyncResult which can be used to
214      * finish the operation with g_file_io_stream_query_info_finish().
215      * For the synchronous version of this function, see
216      * g_file_io_stream_query_info().
217      * Since 2.22
218      * Params:
219      * attributes = a file attribute query string.
220      * ioPriority = the I/O priority
221      * of the request.
222      * cancellable = optional GCancellable object, NULL to ignore. [allow-none]
223      * callback = callback to call when the request is satisfied. [scope async]
224      * userData = the data to pass to callback function. [closure]
225      */
226     public void queryInfoAsync(string attributes, int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)
227     {
228         // void g_file_io_stream_query_info_async (GFileIOStream *stream,  const char *attributes,  int io_priority,  GCancellable *cancellable,  GAsyncReadyCallback callback,  gpointer user_data);
229         g_file_io_stream_query_info_async(gFileIOStream, Str.toStringz(attributes), ioPriority, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData);
230     }
231    
232     /**
233      * Finalizes the asynchronous query started
234      * by g_file_io_stream_query_info_async().
235      * Since 2.22
236      * Params:
237      * result = a GAsyncResult.
238      * Returns: A GFileInfo for the finished query. [transfer full]
239      * Throws: GException on failure.
240      */
241     public FileInfo queryInfoFinish(AsyncResultIF result)
242     {
243         // GFileInfo * g_file_io_stream_query_info_finish (GFileIOStream *stream,  GAsyncResult *result,  GError **error);
244         GError* err = null;
245        
246         auto p = g_file_io_stream_query_info_finish(gFileIOStream, (result is null) ? null : result.getAsyncResultTStruct(), &err);
247        
248         if (err !is null)
249         {
250             throw new GException( new ErrorG(err) );
251         }
252        
253         if(p is null)
254         {
255             return null;
256         }
257         return new FileInfo(cast(GFileInfo*) p);
258     }
259 }
Note: See TracBrowser for help on using the browser.