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