Enumerated Files Routines. More...
#include <giomm/fileenumerator.h>
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) |
Returns information for the next file in the enumerated object. | |
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 () |
Get the File container which is being enumerated. | |
Glib::RefPtr< const File > | get_container () const |
Get the File container which is being enumerated. | |
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. |
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.
virtual Gio::FileEnumerator::~FileEnumerator | ( | ) | [virtual] |
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.
true
on success or an empty RefPtr on error. 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.
cancellable | Optional Cancellable object, 0 to ignore. |
true
on success or #false
on error. 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.
io_priority | The I/O priority of the request. | |
slot | A callback to call when the request is satisfied. |
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. |
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::RefPtr<const File> Gio::FileEnumerator::get_container | ( | ) | const |
Glib::RefPtr<File> Gio::FileEnumerator::get_container | ( | ) |
const GFileEnumerator* Gio::FileEnumerator::gobj | ( | ) | const [inline] |
Provides access to the underlying C GObject.
Reimplemented from Glib::ObjectBase.
GFileEnumerator* Gio::FileEnumerator::gobj | ( | ) | [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.
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 | ( | ) |
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.
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.
cancellable | Optional Cancellable object, 0 to ignore. |
0
on error or end of enumerator. Free the returned object with Glib::object_unref() when no longer needed. 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. |
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. |
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().
result | A AsyncResult. |
void Gio::FileEnumerator::set_pending | ( | bool | pending = true |
) |
Sets the file enumerator as having pending operations.
pending | A boolean value. |
Glib::RefPtr< Gio::FileEnumerator > wrap | ( | GFileEnumerator * | object, | |
bool | take_copy = false | |||
) | [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. |