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