[discident-glib] Add support for VIDEO_TS dirs in lower-case



commit 189717642aea3dd74c176b1a1a520cac0a17a6cb
Author: Bastien Nocera <hadess hadess net>
Date:   Thu Mar 18 18:04:24 2010 +0000

    Add support for VIDEO_TS dirs in lower-case

 discident-glib/discident-glib.c |   30 ++++++++++++++++++++++++++++--
 1 files changed, 28 insertions(+), 2 deletions(-)
---
diff --git a/discident-glib/discident-glib.c b/discident-glib/discident-glib.c
index 604d7fa..df93843 100644
--- a/discident-glib/discident-glib.c
+++ b/discident-glib/discident-glib.c
@@ -118,7 +118,7 @@ discident_add_info_to_list (GList *list,
 	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->filename = g_ascii_strup (g_file_info_get_attribute_byte_string (info, G_FILE_ATTRIBUTE_STANDARD_NAME), -1);
 	item->size = g_file_info_get_attribute_uint64 (info, G_FILE_ATTRIBUTE_STANDARD_SIZE);
 	g_object_unref (info);
 
@@ -140,7 +140,10 @@ discident_get_gtin_file (GFile *directory, GError **error)
 		return NULL;
 
 	videodir = g_file_get_child (directory, "VIDEO_TS");
-	//FIXME what about video_ts in lower-case?
+	if (g_file_query_exists (videodir, NULL) == FALSE) {
+		g_object_unref (videodir);
+		videodir = g_file_get_child (directory, "video_ts");
+	}
 
 	e = g_file_enumerate_children (videodir,
 				       G_FILE_ATTRIBUTE_STANDARD_NAME","G_FILE_ATTRIBUTE_STANDARD_SIZE,
@@ -258,13 +261,36 @@ on_videodir_enumerate_loaded (GObject      *source_object,
 	GError *error = NULL;
 	GFileEnumerator *enumerator;
 	GCancellable *cancellable;
+	gboolean lower_case;
 
 	cancellable = g_object_get_data (G_OBJECT (simple), "cancellable");
+	lower_case = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (simple), "lower-case"));
 	video_ts_dir = G_FILE (source_object);
 	enumerator = g_file_enumerate_children_finish (video_ts_dir,
 						       res,
 						       &error);
 	if (enumerator == NULL) {
+		if (lower_case == FALSE) {
+			GFile *parent;
+			/* Try in lower-case now */
+			parent = g_file_get_parent (video_ts_dir);
+			/* The video_ts_dir only has one floating reference */
+			video_ts_dir = g_file_get_child (parent, "video_ts");
+			g_object_set_data (G_OBJECT (simple), "lower-case", GINT_TO_POINTER (TRUE));
+			g_object_unref (parent);
+
+			g_file_enumerate_children_async (video_ts_dir,
+							 G_FILE_ATTRIBUTE_STANDARD_NAME","G_FILE_ATTRIBUTE_STANDARD_SIZE,
+							 G_FILE_QUERY_INFO_NONE,
+							 G_PRIORITY_DEFAULT,
+							 cancellable,
+							 on_videodir_enumerate_loaded,
+							 simple);
+			g_object_unref (video_ts_dir);
+			return;
+		}
+
+		/* Error? */
 		g_simple_async_result_set_from_error (simple, error);
 		g_simple_async_result_complete_in_idle (simple);
 		g_object_unref (simple);



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