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