[discident-glib] Move the enumeration processing to a separate function



commit e088d70784f11e8cbff3fd296009e9bb3879ed95
Author: Bastien Nocera <hadess hadess net>
Date:   Thu Mar 18 17:53:55 2010 +0000

    Move the enumeration processing to a separate function

 discident-glib/discident-glib.c |   28 ++++++++++++++++------------
 1 files changed, 16 insertions(+), 12 deletions(-)
---
diff --git a/discident-glib/discident-glib.c b/discident-glib/discident-glib.c
index bf9386b..604d7fa 100644
--- a/discident-glib/discident-glib.c
+++ b/discident-glib/discident-glib.c
@@ -111,6 +111,20 @@ is_dvd (GFile *directory, GError **error)
 	return TRUE;
 }
 
+static GList *
+discident_add_info_to_list (GList *list,
+			    GFileInfo *info)
+{
+	ts_file *item;
+
+	item = g_new0 (ts_file, 1);
+	item->filename = g_strdup (g_file_info_get_attribute_byte_string (info, G_FILE_ATTRIBUTE_STANDARD_NAME));
+	item->size = g_file_info_get_attribute_uint64 (info, G_FILE_ATTRIBUTE_STANDARD_SIZE);
+	g_object_unref (info);
+
+	return g_list_prepend (list, item);
+}
+
 char *
 discident_get_gtin_file (GFile *directory, GError **error)
 {
@@ -140,12 +154,7 @@ discident_get_gtin_file (GFile *directory, GError **error)
 	/* Gather all the filenames and their sizes */
 	items = NULL;
 	while ((info = g_file_enumerator_next_file (e, NULL, &err)) != NULL) {
-		ts_file *item;
-		item = g_new0 (ts_file, 1);
-		item->filename = g_strdup (g_file_info_get_attribute_byte_string (info, G_FILE_ATTRIBUTE_STANDARD_NAME));
-		item->size = g_file_info_get_attribute_uint64 (info, G_FILE_ATTRIBUTE_STANDARD_SIZE);
-		g_object_unref (info);
-		items = g_list_prepend (items, item);
+		items = discident_add_info_to_list (items, info);
 	}
 
 	if (err != NULL) {
@@ -223,12 +232,7 @@ on_videodir_enumerate_next_files (GObject      *source_object,
 
 	for (l = file_infos; l != NULL; l = l->next) {
 		GFileInfo *info = l->data;
-		ts_file *item;
-		item = g_new0 (ts_file, 1);
-		item->filename = g_strdup (g_file_info_get_attribute_byte_string (info, G_FILE_ATTRIBUTE_STANDARD_NAME));
-		item->size = g_file_info_get_attribute_uint64 (info, G_FILE_ATTRIBUTE_STANDARD_SIZE);
-		g_object_unref (info);
-		list = g_list_prepend (list, item);
+		list = discident_add_info_to_list (list, info);
 	}
 	g_list_free (file_infos);
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]