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  = GFileEnumerator.html
27  * outPack = gio
28  * outFile = FileEnumerator
29  * strct   = GFileEnumerator
30  * realStrct=
31  * ctorStrct=
32  * clss    = FileEnumerator
33  * interf  = 
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- g_file_enumerator_
41  * omit structs:
42  * omit prefixes:
43  * omit code:
44  * omit signals:
45  * imports:
46  * 	- glib.Str
47  * 	- glib.ErrorG
48  * 	- glib.GException
49  * 	- glib.ListG
50  * 	- gio.AsyncResultIF
51  * 	- gio.Cancellable
52  * 	- gio.File
53  * structWrap:
54  * 	- GAsyncResult* -> AsyncResultIF
55  * 	- GCancellable* -> Cancellable
56  * 	- GFile* -> File
57  * 	- GList* -> ListG
58  * module aliases:
59  * local aliases:
60  * overrides:
61  */
62 
63 module gio.FileEnumerator;
64 
65 public  import gtkc.giotypes;
66 
67 private import gtkc.gio;
68 private import glib.ConstructionException;
69 private import gobject.ObjectG;
70 
71 
72 private import glib.Str;
73 private import glib.ErrorG;
74 private import glib.GException;
75 private import glib.ListG;
76 private import gio.AsyncResultIF;
77 private import gio.Cancellable;
78 private import gio.File;
79 
80 
81 
82 private import gobject.ObjectG;
83 
84 /**
85  * Description
86  * GFileEnumerator allows you to operate on a set of GFiles,
87  * returning a GFileInfo structure for each file enumerated (e.g.
88  * g_file_enumerate_children() will return a GFileEnumerator for each
89  * of the children within a directory).
90  * To get the next file's information from a GFileEnumerator, use
91  * g_file_enumerator_next_file() or its asynchronous version,
92  * g_file_enumerator_next_files_async(). Note that the asynchronous
93  * version will return a list of GFileInfos, whereas the
94  * synchronous will only return the next file in the enumerator.
95  * To close a GFileEnumerator, use g_file_enumerator_close(), or
96  * its asynchronous version, g_file_enumerator_close_async(). Once
97  * a GFileEnumerator is closed, no further actions may be performed
98  * on it, and it should be freed with g_object_unref().
99  */
100 public class FileEnumerator : ObjectG
101 {
102 	
103 	/** the main Gtk struct */
104 	protected GFileEnumerator* gFileEnumerator;
105 	
106 	
107 	public GFileEnumerator* getFileEnumeratorStruct()
108 	{
109 		return gFileEnumerator;
110 	}
111 	
112 	
113 	/** the main Gtk struct as a void* */
114 	protected override void* getStruct()
115 	{
116 		return cast(void*)gFileEnumerator;
117 	}
118 	
119 	/**
120 	 * Sets our main struct and passes it to the parent class
121 	 */
122 	public this (GFileEnumerator* gFileEnumerator)
123 	{
124 		super(cast(GObject*)gFileEnumerator);
125 		this.gFileEnumerator = gFileEnumerator;
126 	}
127 	
128 	protected override void setStruct(GObject* obj)
129 	{
130 		super.setStruct(obj);
131 		gFileEnumerator = cast(GFileEnumerator*)obj;
132 	}
133 	
134 	/**
135 	 */
136 	
137 	/**
138 	 * Returns information for the next file in the enumerated object.
139 	 * Will block until the information is available. The GFileInfo
140 	 * returned from this function will contain attributes that match the
141 	 * attribute string that was passed when the GFileEnumerator was created.
142 	 * On error, returns NULL and sets error to the error. If the
143 	 * enumerator is at the end, NULL will be returned and error will
144 	 * be unset.
145 	 * Params:
146 	 * cancellable = optional GCancellable object, NULL to ignore. [allow-none]
147 	 * Returns: A GFileInfo or NULL on error or end of enumerator. Free the returned object with g_object_unref() when no longer needed. [transfer full]
148 	 * Throws: GException on failure.
149 	 */
150 	public GFileInfo* nextFile(Cancellable cancellable)
151 	{
152 		// GFileInfo * g_file_enumerator_next_file (GFileEnumerator *enumerator,  GCancellable *cancellable,  GError **error);
153 		GError* err = null;
154 		
155 		auto p = g_file_enumerator_next_file(gFileEnumerator, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err);
156 		
157 		if (err !is null)
158 		{
159 			throw new GException( new ErrorG(err) );
160 		}
161 		
162 		return p;
163 	}
164 	
165 	/**
166 	 * Releases all resources used by this enumerator, making the
167 	 * enumerator return G_IO_ERROR_CLOSED on all calls.
168 	 * This will be automatically called when the last reference
169 	 * is dropped, but you might want to call this function to make
170 	 * sure resources are released as early as possible.
171 	 * Params:
172 	 * cancellable = optional GCancellable object, NULL to ignore. [allow-none]
173 	 * Returns: TRUE on success or FALSE on error.
174 	 * Throws: GException on failure.
175 	 */
176 	public int close(Cancellable cancellable)
177 	{
178 		// gboolean g_file_enumerator_close (GFileEnumerator *enumerator,  GCancellable *cancellable,  GError **error);
179 		GError* err = null;
180 		
181 		auto p = g_file_enumerator_close(gFileEnumerator, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err);
182 		
183 		if (err !is null)
184 		{
185 			throw new GException( new ErrorG(err) );
186 		}
187 		
188 		return p;
189 	}
190 	
191 	/**
192 	 * Request information for a number of files from the enumerator asynchronously.
193 	 * When all i/o for the operation is finished the callback will be called with
194 	 * the requested information.
195 	 * The callback can be called with less than num_files files in case of error
196 	 * or at the end of the enumerator. In case of a partial error the callback will
197 	 * be called with any succeeding items and no error, and on the next request the
198 	 * error will be reported. If a request is cancelled the callback will be called
199 	 * with G_IO_ERROR_CANCELLED.
200 	 * During an async request no other sync and async calls are allowed, and will
201 	 * result in G_IO_ERROR_PENDING errors.
202 	 * Any outstanding i/o request with higher priority (lower numerical value) will
203 	 * be executed before an outstanding request with lower priority. Default
204 	 * priority is G_PRIORITY_DEFAULT.
205 	 * Params:
206 	 * numFiles = the number of file info objects to request
207 	 * ioPriority = the io priority
208 	 * of the request.
209 	 * cancellable = optional GCancellable object, NULL to ignore. [allow-none]
210 	 * callback = a GAsyncReadyCallback to call when the request is satisfied. [scope async]
211 	 * userData = the data to pass to callback function. [closure]
212 	 */
213 	public void nextFilesAsync(int numFiles, int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)
214 	{
215 		// void g_file_enumerator_next_files_async (GFileEnumerator *enumerator,  int num_files,  int io_priority,  GCancellable *cancellable,  GAsyncReadyCallback callback,  gpointer user_data);
216 		g_file_enumerator_next_files_async(gFileEnumerator, numFiles, ioPriority, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData);
217 	}
218 	
219 	/**
220 	 * Finishes the asynchronous operation started with g_file_enumerator_next_files_async().
221 	 * Params:
222 	 * result = a GAsyncResult.
223 	 * Returns: a GList of GFileInfos. You must free the list with g_list_free() and unref the infos with g_object_unref() when you're done with them. [transfer full][element-type Gio.FileInfo]
224 	 * Throws: GException on failure.
225 	 */
226 	public ListG nextFilesFinish(AsyncResultIF result)
227 	{
228 		// GList * g_file_enumerator_next_files_finish (GFileEnumerator *enumerator,  GAsyncResult *result,  GError **error);
229 		GError* err = null;
230 		
231 		auto p = g_file_enumerator_next_files_finish(gFileEnumerator, (result is null) ? null : result.getAsyncResultTStruct(), &err);
232 		
233 		if (err !is null)
234 		{
235 			throw new GException( new ErrorG(err) );
236 		}
237 		
238 		
239 		if(p is null)
240 		{
241 			return null;
242 		}
243 		
244 		return ObjectG.getDObject!(ListG)(cast(GList*) p);
245 	}
246 	
247 	/**
248 	 * Asynchronously closes the file enumerator.
249 	 * If cancellable is not NULL, then the operation can be cancelled by
250 	 * triggering the cancellable object from another thread. If the operation
251 	 * was cancelled, the error G_IO_ERROR_CANCELLED will be returned in
252 	 * g_file_enumerator_close_finish().
253 	 * Params:
254 	 * ioPriority = the I/O priority
255 	 * of the request.
256 	 * cancellable = optional GCancellable object, NULL to ignore. [allow-none]
257 	 * callback = a GAsyncReadyCallback to call when the request is satisfied. [scope async]
258 	 * userData = the data to pass to callback function. [closure]
259 	 */
260 	public void closeAsync(int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)
261 	{
262 		// void g_file_enumerator_close_async (GFileEnumerator *enumerator,  int io_priority,  GCancellable *cancellable,  GAsyncReadyCallback callback,  gpointer user_data);
263 		g_file_enumerator_close_async(gFileEnumerator, ioPriority, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData);
264 	}
265 	
266 	/**
267 	 * Finishes closing a file enumerator, started from g_file_enumerator_close_async().
268 	 * If the file enumerator was already closed when g_file_enumerator_close_async()
269 	 * was called, then this function will report G_IO_ERROR_CLOSED in error, and
270 	 * return FALSE. If the file enumerator had pending operation when the close
271 	 * operation was started, then this function will report G_IO_ERROR_PENDING, and
272 	 * return FALSE. If cancellable was not NULL, then the operation may have been
273 	 * cancelled by triggering the cancellable object from another thread. If the operation
274 	 * was cancelled, the error G_IO_ERROR_CANCELLED will be set, and FALSE will be
275 	 * returned.
276 	 * Params:
277 	 * result = a GAsyncResult.
278 	 * Returns: TRUE if the close operation has finished successfully.
279 	 * Throws: GException on failure.
280 	 */
281 	public int closeFinish(AsyncResultIF result)
282 	{
283 		// gboolean g_file_enumerator_close_finish (GFileEnumerator *enumerator,  GAsyncResult *result,  GError **error);
284 		GError* err = null;
285 		
286 		auto p = g_file_enumerator_close_finish(gFileEnumerator, (result is null) ? null : result.getAsyncResultTStruct(), &err);
287 		
288 		if (err !is null)
289 		{
290 			throw new GException( new ErrorG(err) );
291 		}
292 		
293 		return p;
294 	}
295 	
296 	/**
297 	 * Checks if the file enumerator has been closed.
298 	 * Returns: TRUE if the enumerator is closed.
299 	 */
300 	public int isClosed()
301 	{
302 		// gboolean g_file_enumerator_is_closed (GFileEnumerator *enumerator);
303 		return g_file_enumerator_is_closed(gFileEnumerator);
304 	}
305 	
306 	/**
307 	 * Checks if the file enumerator has pending operations.
308 	 * Returns: TRUE if the enumerator has pending operations.
309 	 */
310 	public int hasPending()
311 	{
312 		// gboolean g_file_enumerator_has_pending (GFileEnumerator *enumerator);
313 		return g_file_enumerator_has_pending(gFileEnumerator);
314 	}
315 	
316 	/**
317 	 * Sets the file enumerator as having pending operations.
318 	 * Params:
319 	 * pending = a boolean value.
320 	 */
321 	public void setPending(int pending)
322 	{
323 		// void g_file_enumerator_set_pending (GFileEnumerator *enumerator,  gboolean pending);
324 		g_file_enumerator_set_pending(gFileEnumerator, pending);
325 	}
326 	
327 	/**
328 	 * Get the GFile container which is being enumerated.
329 	 * Since 2.18
330 	 * Returns: the GFile which is being enumerated. [transfer full]
331 	 */
332 	public File getContainer()
333 	{
334 		// GFile * g_file_enumerator_get_container (GFileEnumerator *enumerator);
335 		auto p = g_file_enumerator_get_container(gFileEnumerator);
336 		
337 		if(p is null)
338 		{
339 			return null;
340 		}
341 		
342 		return ObjectG.getDObject!(File)(cast(GFile*) p);
343 	}
344 }