Package ch.bailu.gtk.gio
Class FileEnumerator
java.lang.Object
ch.bailu.gtk.type.Type
ch.bailu.gtk.type.Pointer
ch.bailu.gtk.gobject.Object
ch.bailu.gtk.gio.FileEnumerator
- All Implemented Interfaces:
PointerInterface
#GFileEnumerator allows you to operate on a set of #GFiles,
returning a #GFileInfo structure for each file enumerated (e.g.
g_file_enumerate_children() will return a #GFileEnumerator for each
of the children within a directory).
To get the next file's information from a #GFileEnumerator, use
g_file_enumerator_next_file() or its asynchronous version,
g_file_enumerator_next_files_async(). Note that the asynchronous
version will return a list of #GFileInfos, whereas the
synchronous will only return the next file in the enumerator.
The ordering of returned files is unspecified for non-Unix
platforms; for more information, see g_dir_read_name(). On Unix,
when operating on local files, returned files will be sorted by
inode number. Effectively you can assume that the ordering of
returned files will be stable between successive calls (and
applications) assuming the directory is unchanged.
If your application needs a specific ordering, such as by name or
modification time, you will have to implement that in your
application code.
To close a #GFileEnumerator, use g_file_enumerator_close(), or
its asynchronous version, g_file_enumerator_close_async(). Once
a #GFileEnumerator is closed, no further actions may be performed
on it, and it should be freed with g_object_unref().
returning a #GFileInfo structure for each file enumerated (e.g.
g_file_enumerate_children() will return a #GFileEnumerator for each
of the children within a directory).
To get the next file's information from a #GFileEnumerator, use
g_file_enumerator_next_file() or its asynchronous version,
g_file_enumerator_next_files_async(). Note that the asynchronous
version will return a list of #GFileInfos, whereas the
synchronous will only return the next file in the enumerator.
The ordering of returned files is unspecified for non-Unix
platforms; for more information, see g_dir_read_name(). On Unix,
when operating on local files, returned files will be sorted by
inode number. Effectively you can assume that the ordering of
returned files will be stable between successive calls (and
applications) assuming the directory is unchanged.
If your application needs a specific ordering, such as by name or
modification time, you will have to implement that in your
application code.
To close a #GFileEnumerator, use g_file_enumerator_close(), or
its asynchronous version, g_file_enumerator_close_async(). Once
a #GFileEnumerator is closed, no further actions may be performed
on it, and it should be freed with g_object_unref().
-
Nested Class Summary
Nested classes/interfaces inherited from class ch.bailu.gtk.gobject.Object
Object.OnBindingTransformFunc, Object.OnDestroyNotify, Object.OnDuplicateFunc, Object.OnNotify, Object.OnToggleNotify, Object.OnWeakNotify
-
Field Summary
Fields inherited from class ch.bailu.gtk.gobject.Object
SIGNAL_ON_NOTIFY
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
close
(Cancellable cancellable) Releases all resources used by this enumerator, making the
enumerator return %G_IO_ERROR_CLOSED on all calls.void
closeAsync
(int io_priority, Cancellable cancellable, FileEnumerator.OnAsyncReadyCallback callback, Pointer user_data) Asynchronously closes the file enumerator.boolean
closeFinish
(AsyncResult result) Finishes closing a file enumerator, started from g_file_enumerator_close_async().Return a new #GFile which refers to the file named by @info in the source
directory of @enumerator.static ClassHandler
Get the #GFile container which is being enumerated.static int
static long
static TypeSystem.TypeSize
static long
static TypeSystem.TypeSize
boolean
Checks if the file enumerator has pending operations.boolean
isClosed()
Checks if the file enumerator has been closed.nextFile
(Cancellable cancellable) Returns information for the next file in the enumerated object.void
nextFilesAsync
(int num_files, int io_priority, Cancellable cancellable, FileEnumerator.OnAsyncReadyCallback callback, Pointer user_data) Request information for a number of files from the enumerator asynchronously.nextFilesFinish
(AsyncResult result) Finishes the asynchronous operation started with g_file_enumerator_next_files_async().void
setPending
(boolean pending) Sets the file enumerator as having pending operations.Methods inherited from class ch.bailu.gtk.gobject.Object
addToggleRef, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, compatControl, connect, connect, disconnect, disconnect, dupData, dupData, dupQdata, forceFloating, freezeNotify, get, get, getData, getData, getProperty, getProperty, getQdata, interfaceFindProperty, interfaceInstallProperty, isFloating, notify, notify, notifyByPspec, onNotify, ref, refSink, removeToggleRef, replaceData, replaceData, replaceQdata, runDispose, set, set, setData, setData, setDataFull, setDataFull, setProperty, setProperty, setQdata, setQdataFull, stealData, stealData, stealQdata, takeRef, thawNotify, unref, watchClosure, weakRef, weakUnref
Methods inherited from class ch.bailu.gtk.type.Pointer
asCPointer, cast, connectSignal, disconnectSignals, disconnectSignals, equals, hashCode, throwIfNull, throwNullPointerException, toString, unregisterCallbacks, unregisterCallbacks
Methods inherited from class ch.bailu.gtk.type.Type
asCPointer, asCPointer, asCPointerNotNull, asJnaPointer, asJnaPointer, asPointer, asPointer, cast, cast, throwIfNull
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface ch.bailu.gtk.type.PointerInterface
asCPointerNotNull, asJnaPointer, asPointer, isNotNull, isNull
-
Constructor Details
-
FileEnumerator
-
-
Method Details
-
getClassHandler
-
close
Releases all resources used by this enumerator, making the
enumerator return %G_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 #GCancellable object, %NULL to ignore.- Returns:
- #TRUE on success or #FALSE on error.
- Throws:
AllocationError
-
closeAsync
public void closeAsync(int io_priority, @Nullable Cancellable cancellable, FileEnumerator.OnAsyncReadyCallback callback, @Nullable Pointer user_data) Asynchronously closes the file enumerator.
If @cancellable is not %NULL, then the operation can be cancelled by
triggering the cancellable object from another thread. If the operation
was cancelled, the error %G_IO_ERROR_CANCELLED will be returned in
g_file_enumerator_close_finish().- Parameters:
io_priority
- the [I/O priority][io-priority] of the requestcancellable
- optional #GCancellable object, %NULL to ignore.callback
- a #GAsyncReadyCallback to call when the request is satisfieduser_data
- the data to pass to callback function
-
closeFinish
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 report %G_IO_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 %G_IO_ERROR_PENDING, and
return %FALSE. If @cancellable was not %NULL, then the operation may have been
cancelled by triggering the cancellable object from another thread. If the operation
was cancelled, the error %G_IO_ERROR_CANCELLED will be set, and %FALSE will be
returned.- Parameters:
result
- a #GAsyncResult.- Returns:
- %TRUE if the close operation has finished successfully.
- Throws:
AllocationError
-
getChild
Return a new #GFile 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 #GFileEnumerator.
This is a convenience method that's equivalent to:<!-- language="C" --> gchar *name = g_file_info_get_name (info); GFile *child = g_file_get_child (g_file_enumerator_get_container (enumr), name);
- Parameters:
info
- a #GFileInfo gotten from g_file_enumerator_next_file() or the async equivalents.- Returns:
- a #GFile for the #GFileInfo passed it.
-
getContainer
Get the #GFile container which is being enumerated.- Returns:
- the #GFile which is being enumerated.
-
hasPending
public boolean hasPending()Checks if the file enumerator has pending operations.- Returns:
- %TRUE if the @enumerator has pending operations.
-
isClosed
public boolean isClosed()Checks if the file enumerator has been closed.- Returns:
- %TRUE if the @enumerator is closed.
-
nextFile
Returns information for the next file in the enumerated object.
Will block until the information is available. The #GFileInfo
returned from this function will contain attributes that match the
attribute string that was passed when the #GFileEnumerator was created.
See the documentation of #GFileEnumerator for information about the
order of returned files.
On error, returns %NULL and sets @error to the error. If the
enumerator is at the end, %NULL will be returned and @error will
be unset.- Parameters:
cancellable
- optional #GCancellable object, %NULL to ignore.- Returns:
- A #GFileInfo or %NULL on error or end of enumerator. Free the returned object with g_object_unref() when no longer needed.
- Throws:
AllocationError
-
nextFilesAsync
public void nextFilesAsync(int num_files, int io_priority, @Nullable Cancellable cancellable, FileEnumerator.OnAsyncReadyCallback callback, @Nullable Pointer user_data) Request 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.
See the documentation of #GFileEnumerator for information about the
order of returned files.
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 %G_IO_ERROR_CANCELLED.
During an async request no other sync and async calls are allowed, and will
result in %G_IO_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 %G_PRIORITY_DEFAULT.- Parameters:
num_files
- the number of file info objects to requestio_priority
- the [I/O priority][io-priority] of the requestcancellable
- optional #GCancellable object, %NULL to ignore.callback
- a #GAsyncReadyCallback to call when the request is satisfieduser_data
- the data to pass to callback function
-
nextFilesFinish
Finishes the asynchronous operation started with g_file_enumerator_next_files_async().- Parameters:
result
- a #GAsyncResult.- Returns:
- a #GList of #GFileInfos. You must free the list with g_list_free() and unref the infos with g_object_unref() when you're done with them.
- Throws:
AllocationError
-
setPending
public void setPending(boolean pending) Sets the file enumerator as having pending operations.- Parameters:
pending
- a boolean value.
-
getTypeID
public static long getTypeID() -
getParentTypeID
public static long getParentTypeID() -
getTypeSize
-
getParentTypeSize
-
getInstanceSize
public static int getInstanceSize()
-