gio.FileEnumerator
Prev | PyGio Class Reference | Next

## gio.FileEnumerator

gio.FileEnumerator — Enumerated Files Routines.

## Synopsis

    class gio.FileEnumerator(gobject.GObject):
        def close(cancellable=None)
        def close_async(callback, io_priority=glib.PRIORITY_DEFAULT, cancellable=None, user_data=None)
        def close_finish(result)
        def get_container()
        def has_pending()
        def is_closed()
        def next_file(cancellable=None)
        def next_files_async(num_files, callback, io_priority=glib.PRIORITY_DEFAULT, cancellable=None, user_data=None)
        def next_files_finish(result)
        def set_pending(pending)

## Ancestry

    +-- gobject.GObject
      +-- gio.FileEnumerator

## gio.FileEnumerator Properties

"container" | Write - Construct only | The container that is being enumerated.

## Description

The `gio.FileEnumerator` allows you to operate on a set of `gio.File`s returning a `gio.FileInfo` structure for each file enumerated (e.g. `gio.File.enumerate_children`() will return a The `gio.FileEnumerator` for each of the children within a directory).

To get the next file's information from a The `gio.FileEnumerator` use `gio.FileEnumerator.next_file`() or its asynchronous version, `gio.FileEnumerator.next_files_async`(). Note that the asynchronous version will return a list of `gio.FileInfo`s, whereas the synchronous will only return the next file in the enumerator.

To close a `gio.FileEnumerator` use `close`, or its asynchronous version, `close_async`. Once a `gio.FileEnumerator` is closed, no further actions may be performed on it.

## Methods

### gio.FileEnumerator.close

        def close(cancellable=None)

`cancellable` : | Optional `gio.Cancellable` object, `None` to ignore.
Returns : | `True` on success or `False` on error.

The `close`() method releases all resources used by this enumerator, making the Gio Error Constants 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.

### gio.FileEnumerator.close_async

        def close_async(callback, io_priority=glib.PRIORITY_DEFAULT, cancellable=None, user_data=None)

`callback` : | A GAsyncReadyCallback to call when the request is satisfied.
`io_priority` : | The Glib Priority Constants of the request.
`cancellable` : | Optional `gio.Cancellable` object, `None` to ignore.
`user_data` : | The data to pass to callback function.

The `close_async`() method asynchronously closes the file enumerator.

If cancellable is not `None`, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error gio.ERROR_CANCELLED will be returned in `gio.FileEnumerator.close_finish`().

### gio.FileEnumerator.close_finish

        def close_finish(result)

`result` : | a GAsyncResult.
Returns : | `True` if the close operation has finished successfully.

The `close_finish`() method finishes closing a file enumerator, started from `gio.FileEnumerator.close_async`().

If the file enumerator was already closed when `gio.FileEnumerator.close_async`() was called, then this function will report gio.ERROR_CLOSED in error, and return `False`. If the file enumerator had pending operation when the close operation was started, then this function will report gio.ERROR_PENDING, and return `False`. If cancellable was not `None`, then the operation may have been cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error gio.ERROR_CANCELLED will be set, and `False` will be returned.

### gio.FileEnumerator.get_container

        def get_container()

Returns : | the `gio.File` which is being enumerated.

The `get_container`() method gets the `gio.File` container which is being enumerated.

### gio.FileEnumerator.has_pending

        def has_pending()

Returns : | `True` if the enumerator has pending operations.

The `has_pending`() method checks if the file enumerator has pending operations.

### gio.FileEnumerator.is_closed

        def is_closed()

Returns : | `True` if the enumerator is closed.

The `is_closed`() method checks if the file enumerator has been closed.

### gio.FileEnumerator.next_file

        def next_file(cancellable=None)

`cancellable` : | Optional `gio.Cancellable` object, `None` to ignore.
Returns : | A `gio.FileInfo` or `None` on error or end of enumerator.

The `next_file`() method returns information for the next file in the enumerated object. Will block until the information is available. The `gio.FileInfo` returned from this function will contain attributes that match the attribute string that was passed when the GFileEnumerator was created.

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

### gio.FileEnumerator.next_files_async

        def next_files_async(num_files, callback, io_priority=glib.PRIORITY_DEFAULT, cancellable=None, user_data=None)

`num_files` : | The number of file info objects to request.
`callback` : | A GAsyncReadyCallback to call when the request is satisfied.
`io_priority` : | The Glib Priority Constants of the request.
`cancellable` : | Optional `gio.Cancellable` object, `None` to ignore.
`user_data` : | The data to pass to callback function.

The `next_files_async`() method requests information for a number of files from the enumerator asynchronously. When all i/o for the operation is finished the callback will be called with the requested information.

The callback can 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 gio.ERROR_CANCELLED.

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

Any outstanding i/o request with higher priority (lower numerical value) will be executed before an outstanding request with lower priority. Default priority is glib.PRIORITY_DEFAULT.

### gio.FileEnumerator.next_files_finish

        def next_files_finish(result)

`result` : | a GAsyncResult.
Returns : | A list of `gio.FileInfo`s.

The `next_files_finish`() method finishes the asynchronous operation started with `gio.FileEnumerator.next_files_async`().

### gio.FileEnumerator.set_pending

        def set_pending(pending)

`pending` : | A boolean value.

The `push_current`() method sets the file enumerator as having pending operations.

Prev | Up | Next
gio.FileAttributeInfo | Home | gio.FileIcon