Main Page glibmm Namespaces Book

# Gio::FileEnumerator Class Reference

Enumerated Files Routines. More...

Inheritance diagram for Gio::FileEnumerator:

[legend]

List of all members.

## Public Member Functions

virtual | ~FileEnumerator ()
GFileEnumerator* | gobj ()
| Provides access to the underlying C GObject.
const GFileEnumerator* | gobj () const
| Provides access to the underlying C GObject.
GFileEnumerator* | gobj_copy ()
| Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.
Glib::RefPtr<FileInfo> | next_file (const Glib::RefPtr<Cancellable>& cancellable)
| Return value: A FileInfo or `0` on error or end of enumerator.
Glib::RefPtr<FileInfo> | next_file ()
bool | close (const Glib::RefPtr<Cancellable>& cancellable)
| Releases all resources used by this enumerator, making the enumerator return IO_ERROR_CLOSED on all calls.
bool | close ()
| Releases all resources used by this enumerator, making the enumerator throw a Gio::Error with CLOSED on all calls.
void | next_files_async (const SlotAsyncReady& slot, const Glib::RefPtr<Cancellable>& cancellable, int num_files=1, int io_priority=Glib::PRIORITY_DEFAULT)
| Request information for a number of files from the enumerator asynchronously.
void | next_files_async (const SlotAsyncReady& slot, int num_files=1, int io_priority=Glib::PRIORITY_DEFAULT)
| Request information for a number of files from the enumerator asynchronously.
Glib::ListHandle< Glib::RefPtr <FileInfo >> | next_files_finish (const Glib::RefPtr<AsyncResult>& result)
| Finishes the asynchronous operation started with g_file_enumerator_next_files_async().
void | close_async (int io_priority, const Glib::RefPtr<Cancellable>& cancellable, const SlotAsyncReady& slot)
| Asynchronously closes the file enumerator.
void | close_async (int io_priority, const SlotAsyncReady& slot)
| Asynchronously closes the file enumerator.
bool | close_finish (const Glib::RefPtr<AsyncResult>& result)
| Finishes closing a file enumerator, started from g_file_enumerator_close_async().
bool | is_closed () const
| Checks if the file enumerator has been closed.
bool | has_pending () const
| Checks if the file enumerator has pending operations.
void | set_pending (bool pending=true)
| Sets the file enumerator as having pending operations.
Glib::RefPtr<File> | get_container ()
Glib::RefPtr<const File> | get_container () const

## Related Functions

(Note that these are not member functions.)
Glib::RefPtr<Gio::FileEnumerator> | wrap (GFileEnumerator* object, bool take_copy=false)
| A Glib::wrap() method for this object.

## Detailed Description

Enumerated Files Routines.

FileEnumerator allows you to operate on a set of Gio::Files, returning a Gio::FileInfo instance for each file enumerated (e.g. Gio::File::enumerate_children() will return a FileEnumerator for each of the children within a directory).

To get the next file's information from a Gio::FileEnumerator, use next_file() or its asynchronous version, next_file_async(). Note that the asynchronous version will return a list of Gio::FileInfos, whereas the synchronous version will only return the next file in the enumerator.

To close a Gio::FileEnumerator, use FileEnumerator::close(), or its asynchronous version, close_async(). Once a FileEnumerator is closed, no further actions may be performed on it.

Since glibmm 2.16:

## Constructor & Destructor Documentation

virtual Gio::FileEnumerator::~FileEnumerator | ( |  | ) | `[virtual]`

## Member Function Documentation

GFileEnumerator* Gio::FileEnumerator::gobj | ( |  | ) | `[inline]`

Provides access to the underlying C GObject.

Reimplemented from Glib::ObjectBase.

const GFileEnumerator* Gio::FileEnumerator::gobj | ( |  | ) | const`[inline]`

Provides access to the underlying C GObject.

Reimplemented from Glib::ObjectBase.

GFileEnumerator* Gio::FileEnumerator::gobj_copy | ( |  | ) |

Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.

Glib::RefPtr<FileInfo> Gio::FileEnumerator::next_file | ( | const Glib::RefPtr<Cancellable>& | cancellable | ) |

Return value: A FileInfo or `0` on error or end of enumerator.

Parameters:

  | cancellable | Optional Cancellable object, `0` to ignore.

Returns:
  A FileInfo or `0` on error or end of enumerator.

Glib::RefPtr<FileInfo> Gio::FileEnumerator::next_file | ( |  | ) |

Returns:
  A FileInfo or an empty RefPtr on error or end of enumerator.

bool Gio::FileEnumerator::close | ( | const Glib::RefPtr<Cancellable>& | cancellable | ) |

Releases all resources used by this enumerator, making the enumerator return IO_ERROR_CLOSED on all calls.

This will be automatically called when the last reference is dropped, but you might want to call this function to make sure resources are released as early as possible.

Parameters:

  | cancellable | Optional Cancellable object, `0` to ignore.

Returns:
  #`true` on success or #`false` on error.

bool Gio::FileEnumerator::close | ( |  | ) |

Releases all resources used by this enumerator, making the enumerator throw a Gio::Error with CLOSED on all calls.

This will be automatically called when the last reference is dropped, but you might want to call this method to make sure resources are released as early as possible.

Returns:
  #`true` on success or an empty RefPtr on error.

void Gio::FileEnumerator::next_files_async | ( | const SlotAsyncReady& | slot,
|  | const Glib::RefPtr<Cancellable>& | cancellable,
|  | int | num_files = `1`,
|  | int | io_priority = `Glib::PRIORITY_DEFAULT` |
| ) |  |  |

Request information for a number of files from the enumerator asynchronously.

When all I/O for the operation is finished the callback slot will be called with the requested information.

The callback could be called with less than num_files files in case of error or at the end of the enumerator. In case of a partial error the callback will be called with any succeeding items and no error, and on the next request the error will be reported. If a request is cancelled the callback will be called with ERROR_CANCELLED.

During an async request no other sync and async calls are allowed, and will result in ERROR_PENDING errors.

Any outstanding I/O request with higher priority (lower numerical value) will be executed before an outstanding request with lower priority. The default priority is PRIORITY_DEFAULT.

Parameters:

  | slot | A callback to call when the request is satisfied.
  | cancellable | An cancellable object which can be used to cancel the request.
  | num_files | The number of file info objects to request.
  | io_priority | The I/O priority of the request.

void Gio::FileEnumerator::next_files_async | ( | const SlotAsyncReady& | slot,
|  | int | num_files = `1`,
|  | int | io_priority = `Glib::PRIORITY_DEFAULT` |
| ) |  |  |

Request information for a number of files from the enumerator asynchronously.

When all I/O for the operation is finished the callback slot will be called with the requested information.

The callback could be called with less than num_files files in case of error or at the end of the enumerator. In case of a partial error the callback will be called with any succeeding items and no error, and on the next request the error will be reported. If a request is cancelled the callback will be called with ERROR_CANCELLED.

During an async request no other sync and async calls are allowed, and will result in ERROR_PENDING errors.

Any outstanding I/O request with higher priority (lower numerical value) will be executed before an outstanding request with lower priority. The default priority is PRIORITY_DEFAULT.

Parameters:

  | slot | A callback to call when the request is satisfied.
  | num_files | The number of file info objects to request.
  | io_priority | The I/O priority of the request.

Glib::ListHandle<Glib::RefPtr<FileInfo>> Gio::FileEnumerator::next_files_finish | ( | const Glib::RefPtr<AsyncResult>& | result | ) |

Finishes the asynchronous operation started with g_file_enumerator_next_files_async().

Parameters:

  | result | A AsyncResult.

Returns:
  A List of FileInfo<!---->s. You must free the list with g_list_free and unref the infos with g_object_unref when your done with them.

void Gio::FileEnumerator::close_async | ( | int | io_priority,
|  | const Glib::RefPtr<Cancellable>& | cancellable,
|  | const SlotAsyncReady& | slot |
| ) |  |  |

Asynchronously closes the file enumerator.

See close(), which is the synchronous version of this function.

The operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, a Gio::Error with CANCELLED will be thrown by close_finish().

Parameters:

  | io_priority | The I/O priority of the request.
  | cancellable | A Cancellable object which can be used to cancel the operation.
  | slot | A callback to call when the request is satisfied.

void Gio::FileEnumerator::close_async | ( | int | io_priority,
|  | const SlotAsyncReady& | slot |
| ) |  |  |

Asynchronously closes the file enumerator.

See close(), which is the synchronous version of this function.

Parameters:

  | io_priority | The I/O priority of the request.
  | slot | A callback to call when the request is satisfied.

bool Gio::FileEnumerator::close_finish | ( | const Glib::RefPtr<AsyncResult>& | result | ) |

Finishes closing a file enumerator, started from g_file_enumerator_close_async().

If the file enumerator was already closed when g_file_enumerator_close_async() was called, then this function will throw a Gio::Error with CLOSED, and return `false`. If the file enumerator had pending operation when the close operation was started, then this function will throw a Gio::Error with PENDING, and return `false`. The operation may have been cancelled by triggering the cancellable object from another thread. If the operation was cancelled, a Gio::Error with CANCELLED will be thrown, and `false` will be returned.

Parameters:

  | result | A AsyncResult.

Returns:
  `true` if the close operation has finished successfully.

bool Gio::FileEnumerator::is_closed | ( |  | ) | const

Checks if the file enumerator has been closed.

Returns:
  `true` if the enumerator is closed.

bool Gio::FileEnumerator::has_pending | ( |  | ) | const

Checks if the file enumerator has pending operations.

Returns:
  `true` if the enumerator has pending operations.

void Gio::FileEnumerator::set_pending | ( | bool | pending = `true` | ) |

Sets the file enumerator as having pending operations.

Parameters:

  | pending | A boolean value.

Glib::RefPtr<File> Gio::FileEnumerator::get_container | ( |  | ) |

Glib::RefPtr<const File> Gio::FileEnumerator::get_container | ( |  | ) | const

## Friends And Related Function Documentation

Glib::RefPtr<Gio::FileEnumerator> wrap | ( | GFileEnumerator * | object,
|  | bool | take_copy = `false` |
| ) |  |  | `[related]`

A Glib::wrap() method for this object.

Parameters:

  | object | The C instance.
  | take_copy | False if the result should take ownership of the C instance. True if it should take a new copy or ref.

Returns:
  A C++ instance that wraps this C instance.

The documentation for this class was generated from the following file:

- fileenumerator.h