enumerate_children_async


Description:

public virtual async FileEnumerator enumerate_children_async (string attributes, FileQueryInfoFlags flags, int io_priority = DEFAULT, Cancellable? cancellable = null) throws Error

Asynchronously gets the requested information about the files in a directory.

The result is a FileEnumerator object that will give out FileInfo objects for all the files in the directory.

For more details, see enumerate_children which is the synchronous version of this call.

When the operation is finished, callback will be called. You can then call enumerate_children_async.end to get the result of the operation.

Example: List all files in a directory, async:

public static int main (string[] args) {
File file = File.new_for_path (".");
MainLoop loop = new MainLoop ();

file.enumerate_children_async.begin ("standard::*", FileQueryInfoFlags.NOFOLLOW_SYMLINKS, Priority.DEFAULT, null, (obj, res) => {
try {
FileEnumerator enumerator = file.enumerate_children_async.end (res);
FileInfo info;
while ((info = enumerator.next_file (null)) != null) {
print ("%s\n", info.get_name ());
print ("\t%s\n", info.get_file_type ().to_string ());
print ("\t%s\n", info.get_is_symlink ().to_string ());
print ("\t%s\n", info.get_is_hidden ().to_string ());
print ("\t%s\n", info.get_is_backup ().to_string ());
print ("\t%"+int64.FORMAT+"\n", info.get_size ());
}
} catch (Error e) {
print ("Error: %s\n", e.message);
}

loop.quit ();
});

loop.run ();
return 0;
}

valac --pkg gio-2.0 GLib.File.enumerate_children_async.vala

Parameters:

this

input File

attributes

an attribute query string

flags

a set of FileQueryInfoFlags

io_priority

the I/O priority of the request

cancellable

optional Cancellable object, null to ignore

callback

a TaskReadyCallback to call when the request is satisfied

user_data

the data to pass to callback function




2022 vala-language.org