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