glibmm 2.46.2

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Examples

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | Static Public Member Functions | Related Functions | List of all members
Gio::FileEnumerator Class Reference

Enumerated Files Routines. More...

`#include <giomm/fileenumerator.h>`

Inheritance diagram for Gio::FileEnumerator:
[legend]

## Public Member Functions

| FileEnumerator (FileEnumerator&& src) noexcept
FileEnumerator& | operator= (FileEnumerator&& src) noexcept
virtual | ~FileEnumerator () noexcept
GFileEnumerator* | gobj ()
| Provides access to the underlying C GObject. More...
const GFileEnumerator* | gobj () const
| Provides access to the underlying C GObject. More...
GFileEnumerator* | gobj_copy ()
| Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs. More...
Glib::RefPtr< FileInfo > | next_file (const Glib::RefPtr< Cancellable >& cancellable)
| Returns information for the next file in the enumerated object. More...
Glib::RefPtr< FileInfo > | next_file ()
| A next_file() convenience overload. More...
bool | close (const Glib::RefPtr< Cancellable >& cancellable)
| Releases all resources used by this enumerator, making the enumerator return IO_ERROR_CLOSED on all calls. More...
bool | close ()
| A close() convenience overload. More...
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. More...
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. More...
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(). More...
void | close_async (int io_priority, const Glib::RefPtr< Cancellable >& cancellable, const SlotAsyncReady& slot)
| Asynchronously closes the file enumerator. More...
void | close_async (int io_priority, const SlotAsyncReady& slot)
| Asynchronously closes the file enumerator. More...
bool | close_finish (const Glib::RefPtr< AsyncResult >& result)
| Finishes closing a file enumerator, started from g_file_enumerator_close_async(). More...
bool | is_closed () const
| Checks if the file enumerator has been closed. More...
bool | has_pending () const
| Checks if the file enumerator has pending operations. More...
void | set_pending (bool pending=true)
| Sets the file enumerator as having pending operations. More...
Glib::RefPtr< File > | get_container ()
| Get the File container which is being enumerated. More...
Glib::RefPtr< const File > | get_container () const
| Get the File container which is being enumerated. More...
Glib::RefPtr< File > | get_child (const Glib::RefPtr< FileInfo >& info)
| Return a new File which refers to the file named by info in the source directory of enumerator. More...
Glib::RefPtr< const File > | get_child (const Glib::RefPtr< FileInfo >& info) const
| Return a new File which refers to the file named by info in the source directory of enumerator. More...
Public Member Functions inherited from Glib::Object
| Object (const Object&)=delete
Object& | operator= (const Object&)=delete
| Object (Object&& src) noexcept
Object& | operator= (Object&& src) noexcept
void* | get_data (const QueryQuark& key)
void | set_data (const Quark& key, void* data)
void | set_data (const Quark& key, void* data, DestroyNotify notify)
void | remove_data (const QueryQuark& quark)
void* | steal_data (const QueryQuark& quark)
Public Member Functions inherited from Glib::ObjectBase
| ObjectBase (const ObjectBase&)=delete
ObjectBase& | operator= (const ObjectBase&)=delete
void | set_property_value (const Glib::ustring& property_name, const Glib::ValueBase& value)
| You probably want to use a specific property_*() accessor method instead. More...
void | get_property_value (const Glib::ustring& property_name, Glib::ValueBase& value) const
| You probably want to use a specific property_*() accessor method instead. More...
template<class PropertyType >
void | set_property (const Glib::ustring& property_name, const PropertyType& value)
| You probably want to use a specific property_*() accessor method instead. More...
template<class PropertyType >
void | get_property (const Glib::ustring& property_name, PropertyType& value) const
| You probably want to use a specific property_*() accessor method instead. More...
void | connect_property_changed (const Glib::ustring& property_name, const sigc::slot< void >& slot)
| You can use the signal_changed() signal of the property proxy instead, but this is necessary when using the reduced API. More...
sigc::connection | connect_property_changed_with_return (const Glib::ustring& property_name, const sigc::slot< void >& slot)
| You can use the signal_changed() signal of the property proxy instead, but this is necessary when using the reduced API. More...
void | freeze_notify ()
| Increases the freeze count on object. More...
void | thaw_notify ()
| Reverts the effect of a previous call to freeze_notify(). More...
virtual void | reference () const
| Increment the reference count for this object. More...
virtual void | unreference () const
| Decrement the reference count for this object. More...
GObject* | gobj ()
| Provides access to the underlying C GObject. More...
const GObject* | gobj () const
| Provides access to the underlying C GObject. More...
GObject* | gobj_copy () const
| Give a ref-ed copy to someone. Use for direct struct access. More...
Public Member Functions inherited from sigc::trackable
| trackable () noexcept
| trackable (const trackable &src) noexcept
| trackable (trackable &&src)
| ~trackable ()
void | add_destroy_notify_callback (void *data, func_destroy_notify func) const
void | notify_callbacks ()
trackable & | operator= (const trackable &src)
trackable & | operator= (trackable &&src)
void | remove_destroy_notify_callback (void *data) const

## Static Public Member Functions

static GType | get_type ()
| Get the GType for this class, for use with the underlying GObject type system. More...

## 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. More...
Related Functions inherited from Glib::Object
Glib::RefPtr< Glib::Object > | wrap (GObject* object, bool take_copy=false)

## Additional Inherited Members

Public Types inherited from Glib::Object
typedef void(* | DestroyNotify) (gpointer data)
Public Types inherited from sigc::trackable
typedef internal::func_destroy_notify | func_destroy_notify
Protected Member Functions inherited from Glib::Object
| Object ()
| Object (const Glib::ConstructParams& construct_params)
| Object (GObject* castitem)
virtual | ~Object () noexcept
Protected Member Functions inherited from Glib::ObjectBase
| ObjectBase ()
| This default constructor is called implicitly from the constructor of user-derived classes, even if, for instance, Gtk::Button calls a different ObjectBase constructor. More...
| ObjectBase (const char* custom_type_name)
| A derived constructor always overrides this choice. More...
| ObjectBase (const std::type_info& custom_type_info)
| This constructor is a special feature to allow creation of derived types on the fly, without having to use g_object_new() manually. More...
| ObjectBase (ObjectBase&& src) noexcept
ObjectBase& | operator= (ObjectBase&& src) noexcept
virtual | ~ObjectBase () noexcept=0
void | initialize (GObject* castitem)
void | initialize_move (GObject* castitem, Glib::ObjectBase* previous_wrapper)

## 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

Gio::FileEnumerator::FileEnumerator | ( | FileEnumerator&& | src | ) |

noexcept

virtual Gio::FileEnumerator::~FileEnumerator | ( |  | ) |

virtual noexcept

## Member Function Documentation

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 | ( |  | ) |

A close() convenience overload.

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.

Glib::RefPtr<File> Gio::FileEnumerator::get_child | ( | const Glib::RefPtr< FileInfo >& | info | ) |

Return a new File which refers to the file named by info in the source directory of enumerator.

This function is primarily intended to be used inside loops with g_file_enumerator_next_file().

This is a convenience method that's equivalent to:

[C example ellipted]

Since glibmm 2.36:

Parameters

  info | A FileInfo gotten from g_file_enumerator_next_file() or the async equivalents.

Returns
  A File for the FileInfo passed it.

Glib::RefPtr<const File> Gio::FileEnumerator::get_child | ( | const Glib::RefPtr< FileInfo >& | info | ) | const

Return a new File which refers to the file named by info in the source directory of enumerator.

This function is primarily intended to be used inside loops with g_file_enumerator_next_file().

This is a convenience method that's equivalent to:

[C example ellipted]

Since glibmm 2.36:

Parameters

  info | A FileInfo gotten from g_file_enumerator_next_file() or the async equivalents.

Returns
  A File for the FileInfo passed it.

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

Get the File container which is being enumerated.

Since glibmm 2.18:

Returns
  The File which is being enumerated.

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

Get the File container which is being enumerated.

Since glibmm 2.18:

Returns
  The File which is being enumerated.

static GType Gio::FileEnumerator::get_type | ( |  | ) |

static

Get the GType for this class, for use with the underlying GObject type system.

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

inline

Provides access to the underlying C GObject.

const GFileEnumerator* Gio::FileEnumerator::gobj | ( |  | ) | const

inline

Provides access to the underlying C GObject.

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.

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

Checks if the file enumerator has pending operations.

Returns
  `true` if the enumerator has pending operations.

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

Checks if the file enumerator has been closed.

Returns
  `true` if the enumerator is closed.

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

Returns information for the next file in the enumerated object.

Will block until the information is available. The FileInfo returned from this function will contain attributes that match the attribute string that was passed when the FileEnumerator was created.

See the documentation of FileEnumerator for information about the order of returned files.

On error, returns `0` and sets error to the error. If the enumerator is at the end, `0` will be returned and error will be unset.

Parameters

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

Returns
  A FileInfo or `0` on error or end of enumerator. Free the returned object with Glib::object_unref() when no longer needed.

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

A next_file() convenience overload.

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 FileInfos. You must free the list with Glib::list_free() and unref the infos with Glib::object_unref() when you're done with them.

FileEnumerator& Gio::FileEnumerator::operator= | ( | FileEnumerator&& | src | ) |

noexcept

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

Sets the file enumerator as having pending operations.

Parameters

  pending | A boolean value.

## 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.