FileEnumerator.iterate

This is a version of FileEnumerator.nextFile that's easier to use correctly from C programs. With FileEnumerator.nextFile, the gboolean return value signifies "end of iteration or error", which requires allocation of a temporary GError

In contrast, with this function, a FALSE return from FileEnumerator.iterate *always* means "error". End of iteration is signaled by out_info or out_child being NULL.

Another crucial difference is that the references for out_info and out_child are owned by direnum (they are cached as hidden properties). You must not unref them in your own code. This makes memory management significantly easier for C code in combination with loops.

Finally, this function optionally allows retrieving a GFile as well.

You must specify at least one of out_info or out_child.

The code pattern for correctly using FileEnumerator.iterate from C is:

|[ direnum = g_file_enumerate_children (file, ...); while (TRUE) { GFileInfo *info; if (!g_file_enumerator_iterate (direnum, &info, NULL, cancellable, error)) goto out; if (!info) break; ... do stuff with "info"; do not unref it! ... }

out: g_object_unref (direnum); // Note: frees the last info

Params:
    outInfo = Output location for the next [gio.FileInfo.FileInfo|gio.FileInfo], or `NULL`
    outChild = Output location for the next [GFile|GFile], or `NULL`
    cancellable = a [gio.Cancellable.Cancellable|gio.Cancellable]

Since: 2.44

Throws: GException on failure.
class FileEnumerator
bool
iterate