gio.FileEnumerator — Enumerated Files Routines.
class gio.FileEnumerator(gobject.GObject): |
|
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.
def close(cancellable
=None)
| 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.
def close_async(callback
, io_priority
=glib.PRIORITY_DEFAULT, cancellable
=None, user_data
=None)
| A GAsyncReadyCallback to call when the request is satisfied. |
| The Glib Priority Constants of the request. |
| Optional
gio.Cancellable
object, None to ignore.
|
| 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
().
def close_finish(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.
def get_container()
Returns : | the gio.File
which is being enumerated. |
The get_container
() method gets the
gio.File
container which is being enumerated.
def has_pending()
Returns : | True if the enumerator has pending operations. |
The has_pending
() method checks if the file enumerator has pending operations.
def is_closed()
Returns : | True if the enumerator is closed. |
The is_closed
() method checks if the file enumerator has been closed.
def next_file(cancellable
=None)
| 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.
def next_files_async(num_files
, callback
, io_priority
=glib.PRIORITY_DEFAULT, cancellable
=None, user_data
=None)
| The number of file info objects to request. |
| A GAsyncReadyCallback to call when the request is satisfied. |
| The Glib Priority Constants of the request. |
| Optional
gio.Cancellable
object, None to ignore.
|
| 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.
def next_files_finish(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
().