summaryrefslogtreecommitdiff
path: root/gio/gfileenumerator.c
diff options
context:
space:
mode:
authorJasper St. Pierre <jstpierre@mecheye.net>2012-12-12 04:49:28 -0500
committerJasper St. Pierre <jstpierre@mecheye.net>2012-12-13 21:38:18 -0500
commit3c87ab97ffd8735bff78c177e163826484776cd2 (patch)
tree149d56dc757725c91da929972daa17d87d803aec /gio/gfileenumerator.c
parent6cce4790b7639656c7701a4ed8495ba50abd7c6e (diff)
downloadglib-3c87ab97ffd8735bff78c177e163826484776cd2.tar.gz
gfileenumerator: Add a g_file_enumerator_get_child method
This is a new convenience method designed to simplify some use cases of GFileEnumerator, by making it easy to get the next file from a file enumerator. https://bugzilla.gnome.org/show_bug.cgi?id=690083
Diffstat (limited to 'gio/gfileenumerator.c')
-rw-r--r--gio/gfileenumerator.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/gio/gfileenumerator.c b/gio/gfileenumerator.c
index d8f622b39..6a8065b2a 100644
--- a/gio/gfileenumerator.c
+++ b/gio/gfileenumerator.c
@@ -589,6 +589,37 @@ g_file_enumerator_get_container (GFileEnumerator *enumerator)
return enumerator->priv->container;
}
+/**
+ * g_file_enumerator_get_child:
+ * @enumerator: a #GFileEnumerator
+ * @info: a #GFileInfo gotten from g_file_enumerator_next_file()
+ * or the async equivalents.
+ *
+ * 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().
+ *
+ * This is a convenience method that's equivalent to:
+ * |[
+ * gchar *name = g_file_info_get_name (info);
+ * GFile *child = g_file_get_child (g_file_enumerator_get_container (enumr),
+ * name);
+ * ]|
+ *
+ * Returns: (transfer full): a #GFile for the #GFileInfo passed it.
+ *
+ * Since: 2.36
+ */
+GFile *
+g_file_enumerator_get_child (GFileEnumerator *enumerator,
+ GFileInfo *info)
+{
+ g_return_val_if_fail (G_IS_FILE_ENUMERATOR (enumerator), NULL);
+
+ return g_file_get_child (enumerator->priv->container,
+ g_file_info_get_name (info));
+}
+
typedef struct {
int num_files;
GList *files;