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 * - gio.FileInfo 54 * structWrap: 55 * - GAsyncResult* -> AsyncResultIF 56 * - GCancellable* -> Cancellable 57 * - GFile* -> File 58 * - GFileInfo* -> FileInfo 59 * - GList* -> ListG 60 * module aliases: 61 * local aliases: 62 * overrides: 63 */ 64 65 module gio.FileEnumerator; 66 67 public import gtkc.giotypes; 68 69 private import gtkc.gio; 70 private import glib.ConstructionException; 71 private import gobject.ObjectG; 72 73 74 private import glib.Str; 75 private import glib.ErrorG; 76 private import glib.GException; 77 private import glib.ListG; 78 private import gio.AsyncResultIF; 79 private import gio.Cancellable; 80 private import gio.File; 81 private import gio.FileInfo; 82 83 84 85 private import gobject.ObjectG; 86 87 /** 88 * GFileEnumerator allows you to operate on a set of GFiles, 89 * returning a GFileInfo structure for each file enumerated (e.g. 90 * g_file_enumerate_children() will return a GFileEnumerator for each 91 * of the children within a directory). 92 * 93 * To get the next file's information from a GFileEnumerator, use 94 * g_file_enumerator_next_file() or its asynchronous version, 95 * g_file_enumerator_next_files_async(). Note that the asynchronous 96 * version will return a list of GFileInfos, whereas the 97 * synchronous will only return the next file in the enumerator. 98 * 99 * The ordering of returned files is unspecified for non-Unix 100 * platforms; for more information, see g_dir_read_name(). On Unix, 101 * when operating on local files, returned files will be sorted by 102 * inode number. Effectively you can assume that the ordering of 103 * returned files will be stable between successive calls (and 104 * applications) assuming the directory is unchanged. 105 * 106 * If your application needs a specific ordering, such as by name or 107 * modification time, you will have to implement that in your 108 * application code. 109 * 110 * To close a GFileEnumerator, use g_file_enumerator_close(), or 111 * its asynchronous version, g_file_enumerator_close_async(). Once 112 * a GFileEnumerator is closed, no further actions may be performed 113 * on it, and it should be freed with g_object_unref(). 114 */ 115 public class FileEnumerator : ObjectG 116 { 117 118 /** the main Gtk struct */ 119 protected GFileEnumerator* gFileEnumerator; 120 121 122 public GFileEnumerator* getFileEnumeratorStruct() 123 { 124 return gFileEnumerator; 125 } 126 127 128 /** the main Gtk struct as a void* */ 129 protected override void* getStruct() 130 { 131 return cast(void*)gFileEnumerator; 132 } 133 134 /** 135 * Sets our main struct and passes it to the parent class 136 */ 137 public this (GFileEnumerator* gFileEnumerator) 138 { 139 super(cast(GObject*)gFileEnumerator); 140 this.gFileEnumerator = gFileEnumerator; 141 } 142 143 protected override void setStruct(GObject* obj) 144 { 145 super.setStruct(obj); 146 gFileEnumerator = cast(GFileEnumerator*)obj; 147 } 148 149 /** 150 */ 151 152 /** 153 * Returns information for the next file in the enumerated object. 154 * Will block until the information is available. The GFileInfo 155 * returned from this function will contain attributes that match the 156 * attribute string that was passed when the GFileEnumerator was created. 157 * See the documentation of GFileEnumerator for information about the 158 * order of returned files. 159 * On error, returns NULL and sets error to the error. If the 160 * enumerator is at the end, NULL will be returned and error will 161 * be unset. 162 * Params: 163 * cancellable = optional GCancellable object, NULL to ignore. [allow-none] 164 * 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] 165 * Throws: GException on failure. 166 */ 167 public FileInfo nextFile(Cancellable cancellable) 168 { 169 // GFileInfo * g_file_enumerator_next_file (GFileEnumerator *enumerator, GCancellable *cancellable, GError **error); 170 GError* err = null; 171 172 auto p = g_file_enumerator_next_file(gFileEnumerator, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 173 174 if (err !is null) 175 { 176 throw new GException( new ErrorG(err) ); 177 } 178 179 180 if(p is null) 181 { 182 return null; 183 } 184 185 return ObjectG.getDObject!(FileInfo)(cast(GFileInfo*) p); 186 } 187 188 /** 189 * Releases all resources used by this enumerator, making the 190 * enumerator return G_IO_ERROR_CLOSED on all calls. 191 * This will be automatically called when the last reference 192 * is dropped, but you might want to call this function to make 193 * sure resources are released as early as possible. 194 * Params: 195 * cancellable = optional GCancellable object, NULL to ignore. [allow-none] 196 * Returns: TRUE on success or FALSE on error. 197 * Throws: GException on failure. 198 */ 199 public int close(Cancellable cancellable) 200 { 201 // gboolean g_file_enumerator_close (GFileEnumerator *enumerator, GCancellable *cancellable, GError **error); 202 GError* err = null; 203 204 auto p = g_file_enumerator_close(gFileEnumerator, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 205 206 if (err !is null) 207 { 208 throw new GException( new ErrorG(err) ); 209 } 210 211 return p; 212 } 213 214 /** 215 * Request information for a number of files from the enumerator asynchronously. 216 * When all i/o for the operation is finished the callback will be called with 217 * the requested information. 218 * See the documentation of GFileEnumerator for information about the 219 * order of returned files. 220 * The callback can be called with less than num_files files in case of error 221 * or at the end of the enumerator. In case of a partial error the callback will 222 * be called with any succeeding items and no error, and on the next request the 223 * error will be reported. If a request is cancelled the callback will be called 224 * with G_IO_ERROR_CANCELLED. 225 * During an async request no other sync and async calls are allowed, and will 226 * result in G_IO_ERROR_PENDING errors. 227 * Any outstanding i/o request with higher priority (lower numerical value) will 228 * be executed before an outstanding request with lower priority. Default 229 * priority is G_PRIORITY_DEFAULT. 230 * Params: 231 * numFiles = the number of file info objects to request 232 * ioPriority = the io priority 233 * of the request. 234 * cancellable = optional GCancellable object, NULL to ignore. [allow-none] 235 * callback = a GAsyncReadyCallback to call when the request is satisfied. [scope async] 236 * userData = the data to pass to callback function. [closure] 237 */ 238 public void nextFilesAsync(int numFiles, int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 239 { 240 // void g_file_enumerator_next_files_async (GFileEnumerator *enumerator, int num_files, int io_priority, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); 241 g_file_enumerator_next_files_async(gFileEnumerator, numFiles, ioPriority, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 242 } 243 244 /** 245 * Finishes the asynchronous operation started with g_file_enumerator_next_files_async(). 246 * Params: 247 * result = a GAsyncResult. 248 * 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] 249 * Throws: GException on failure. 250 */ 251 public ListG nextFilesFinish(AsyncResultIF result) 252 { 253 // GList * g_file_enumerator_next_files_finish (GFileEnumerator *enumerator, GAsyncResult *result, GError **error); 254 GError* err = null; 255 256 auto p = g_file_enumerator_next_files_finish(gFileEnumerator, (result is null) ? null : result.getAsyncResultTStruct(), &err); 257 258 if (err !is null) 259 { 260 throw new GException( new ErrorG(err) ); 261 } 262 263 264 if(p is null) 265 { 266 return null; 267 } 268 269 return ObjectG.getDObject!(ListG)(cast(GList*) p); 270 } 271 272 /** 273 * Asynchronously closes the file enumerator. 274 * If cancellable is not NULL, then the operation can be cancelled by 275 * triggering the cancellable object from another thread. If the operation 276 * was cancelled, the error G_IO_ERROR_CANCELLED will be returned in 277 * g_file_enumerator_close_finish(). 278 * Params: 279 * ioPriority = the I/O priority 280 * of the request. 281 * cancellable = optional GCancellable object, NULL to ignore. [allow-none] 282 * callback = a GAsyncReadyCallback to call when the request is satisfied. [scope async] 283 * userData = the data to pass to callback function. [closure] 284 */ 285 public void closeAsync(int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 286 { 287 // void g_file_enumerator_close_async (GFileEnumerator *enumerator, int io_priority, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); 288 g_file_enumerator_close_async(gFileEnumerator, ioPriority, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 289 } 290 291 /** 292 * Finishes closing a file enumerator, started from g_file_enumerator_close_async(). 293 * If the file enumerator was already closed when g_file_enumerator_close_async() 294 * was called, then this function will report G_IO_ERROR_CLOSED in error, and 295 * return FALSE. If the file enumerator had pending operation when the close 296 * operation was started, then this function will report G_IO_ERROR_PENDING, and 297 * return FALSE. If cancellable was not NULL, then the operation may have been 298 * cancelled by triggering the cancellable object from another thread. If the operation 299 * was cancelled, the error G_IO_ERROR_CANCELLED will be set, and FALSE will be 300 * returned. 301 * Params: 302 * result = a GAsyncResult. 303 * Returns: TRUE if the close operation has finished successfully. 304 * Throws: GException on failure. 305 */ 306 public int closeFinish(AsyncResultIF result) 307 { 308 // gboolean g_file_enumerator_close_finish (GFileEnumerator *enumerator, GAsyncResult *result, GError **error); 309 GError* err = null; 310 311 auto p = g_file_enumerator_close_finish(gFileEnumerator, (result is null) ? null : result.getAsyncResultTStruct(), &err); 312 313 if (err !is null) 314 { 315 throw new GException( new ErrorG(err) ); 316 } 317 318 return p; 319 } 320 321 /** 322 * Checks if the file enumerator has been closed. 323 * Returns: TRUE if the enumerator is closed. 324 */ 325 public int isClosed() 326 { 327 // gboolean g_file_enumerator_is_closed (GFileEnumerator *enumerator); 328 return g_file_enumerator_is_closed(gFileEnumerator); 329 } 330 331 /** 332 * Checks if the file enumerator has pending operations. 333 * Returns: TRUE if the enumerator has pending operations. 334 */ 335 public int hasPending() 336 { 337 // gboolean g_file_enumerator_has_pending (GFileEnumerator *enumerator); 338 return g_file_enumerator_has_pending(gFileEnumerator); 339 } 340 341 /** 342 * Sets the file enumerator as having pending operations. 343 * Params: 344 * pending = a boolean value. 345 */ 346 public void setPending(int pending) 347 { 348 // void g_file_enumerator_set_pending (GFileEnumerator *enumerator, gboolean pending); 349 g_file_enumerator_set_pending(gFileEnumerator, pending); 350 } 351 352 /** 353 * Get the GFile container which is being enumerated. 354 * Since 2.18 355 * Returns: the GFile which is being enumerated. [transfer none] 356 */ 357 public File getContainer() 358 { 359 // GFile * g_file_enumerator_get_container (GFileEnumerator *enumerator); 360 auto p = g_file_enumerator_get_container(gFileEnumerator); 361 362 if(p is null) 363 { 364 return null; 365 } 366 367 return ObjectG.getDObject!(File)(cast(GFile*) p); 368 } 369 370 /** 371 * Return a new GFile which refers to the file named by info in the source 372 * directory of enumerator. This function is primarily intended to be used 373 * inside loops with g_file_enumerator_next_file(). 374 * Since 2.36 375 * Params: 376 * info = a GFileInfo gotten from g_file_enumerator_next_file() 377 * or the async equivalents. 378 * Returns: a GFile for the GFileInfo passed it. [transfer full] 379 */ 380 public File getChild(FileInfo info) 381 { 382 // GFile * g_file_enumerator_get_child (GFileEnumerator *enumerator, GFileInfo *info); 383 auto p = g_file_enumerator_get_child(gFileEnumerator, (info is null) ? null : info.getFileInfoStruct()); 384 385 if(p is null) 386 { 387 return null; 388 } 389 390 return ObjectG.getDObject!(File)(cast(GFile*) p); 391 } 392 }