glibmm 2.82.0
|
Enumerated Files Routines. More...
#include <giomm/fileenumerator.h>
Public Member Functions | |
FileEnumerator (FileEnumerator &&src) noexcept | |
FileEnumerator & | operator= (FileEnumerator &&src) noexcept |
~FileEnumerator () noexcept override | |
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) |
Returns information for the next file in the enumerated object. | |
Glib::RefPtr< FileInfo > | next_file () |
A next_file() convenience overload. | |
bool | close (const Glib::RefPtr< Cancellable > &cancellable) |
Releases all resources used by this enumerator, making the enumerator return Gio::Error::CLOSED on all calls. | |
bool | close () |
A close() convenience overload. | |
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. | |
std::vector< 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 () |
Get the File container which is being enumerated. | |
Glib::RefPtr< const File > | get_container () const |
Get the File container which is being enumerated. | |
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. | |
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. | |
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_with_c_callback (const Quark & key, void *data, GDestroyNotify notify) |
void | set_data (const Quark & key, void *data, DestroyNotify notify) |
Prefer set_data_with_c_callback() with a callback with C linkage. | |
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. | |
void | get_property_value (const Glib::ustring & property_name, Glib::ValueBase & value) const |
You probably want to use a specific property_*() accessor method instead. | |
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. | |
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. | |
template<class PropertyType > | |
PropertyType | get_property (const Glib::ustring & property_name) const |
You probably want to use a specific property_*() accessor method instead. | |
sigc::connection | 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. | |
sigc::connection | connect_property_changed (const Glib::ustring & property_name, sigc::slot< void()> &&slot) |
You can use the signal_changed() signal of the property proxy instead. | |
void | freeze_notify () |
Increases the freeze count on object. | |
void | thaw_notify () |
Reverts the effect of a previous call to freeze_notify(). | |
virtual void | reference () const |
Increment the reference count for this object. | |
virtual void | unreference () const |
Decrement the reference count for this object. | |
GObject * | gobj () |
Provides access to the underlying C GObject. | |
const GObject * | gobj () const |
Provides access to the underlying C GObject. | |
GObject * | gobj_copy () const |
Give a ref-ed copy to someone. Use for direct struct access. | |
Static Public Member Functions | |
static GType | get_type () |
Get the GType for this class, for use with the underlying GObject type system. | |
Related Symbols | |
(Note that these are not member symbols.) | |
Glib::RefPtr< Gio::FileEnumerator > | wrap (GFileEnumerator *object, bool take_copy=false) |
A Glib::wrap() method for this object. | |
Related Symbols inherited from Glib::Object | |
Glib::RefPtr< Glib::Object > | wrap (GObject *object, bool take_copy=false) |
Additional Inherited Members | |
Public Types inherited from Glib::Object | |
using | DestroyNotify = void(*)(gpointer data) |
Protected Member Functions inherited from Glib::Object | |
Object () | |
Object (const Glib::ConstructParams &construct_params) | |
Object (GObject *castitem) | |
~Object () noexcept override | |
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. | |
ObjectBase (const char *custom_type_name) | |
A derived constructor always overrides this choice. | |
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. | |
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) |
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.
|
noexcept |
|
overridenoexcept |
bool Gio::FileEnumerator::close | ( | ) |
A close() convenience overload.
bool Gio::FileEnumerator::close | ( | const Glib::RefPtr< Cancellable > & | cancellable | ) |
Releases all resources used by this enumerator, making the enumerator return Gio::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.
cancellable | Optional Cancellable object, nullptr to ignore. |
true
on success or #false
on error.Glib::Error |
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().
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. |
Asynchronously closes the file enumerator.
See close(), which is the synchronous version of this function.
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.
result | A AsyncResult. |
true
if the close operation has finished successfully.Glib::Error |
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().
To use this, G_FILE_ATTRIBUTE_STANDARD_NAME must have been listed in the attributes list used when creating the FileEnumerator.
This is a convenience method that's equivalent to:
[C example ellipted]
info | A FileInfo gotten from g_file_enumerator_next_file() or the async equivalents. |
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().
To use this, G_FILE_ATTRIBUTE_STANDARD_NAME must have been listed in the attributes list used when creating the FileEnumerator.
This is a convenience method that's equivalent to:
[C example ellipted]
info | A FileInfo gotten from g_file_enumerator_next_file() or the async equivalents. |
Glib::RefPtr< File > Gio::FileEnumerator::get_container | ( | ) |
Glib::RefPtr< const File > Gio::FileEnumerator::get_container | ( | ) | const |
Get the GType for this class, for use with the underlying GObject type system.
|
inline |
Provides access to the underlying C GObject.
|
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.
true
if the enumerator has pending operations. bool Gio::FileEnumerator::is_closed | ( | ) | const |
Checks if the file enumerator has been closed.
true
if the enumerator is closed. Glib::RefPtr< FileInfo > Gio::FileEnumerator::next_file | ( | ) |
A next_file() convenience overload.
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 nullptr
and sets error to the error. If the enumerator is at the end, nullptr
will be returned and error will be unset.
cancellable | Optional Cancellable object, nullptr to ignore. |
nullptr
on error or end of enumerator. Free the returned object with Glib::object_unref() when no longer needed.Glib::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.
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.
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. |
std::vector< 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().
result | A AsyncResult. |
Glib::Error |
|
noexcept |
Sets the file enumerator as having pending operations.
pending | A boolean value. |
|
related |
A Glib::wrap() method for this object.
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. |