Re: [PATCH] ISO9660 I18N Joliet label support



On Sat, 8 Jan 2005 06:51:50 +1300, leon breedt <bitserf gmail com> wrote:
> I've attached the patch
Attached is a cleaned up version that doesn't use an unneccessary
stack-allocated iso_primary_descriptor struct, and uses less magic.

Leon
diff -uNr gnome-vfs2-2.9.2/libgnomevfs/gnome-vfs-cdrom.c gnome-vfs2-2.9.2-joliet/libgnomevfs/gnome-vfs-cdrom.c
--- gnome-vfs2-2.9.2/libgnomevfs/gnome-vfs-cdrom.c	2004-08-27 01:36:58.000000000 +1200
+++ gnome-vfs2-2.9.2-joliet/libgnomevfs/gnome-vfs-cdrom.c	2005-01-09 19:22:29.785139480 +1300
@@ -194,6 +194,9 @@
 {
 	struct iso_primary_descriptor iso_buffer;
 	int offset;
+	int i;
+	int vd_alt_offset;
+	gchar *joliet_label;
 
 	memset (&iso_buffer, 0, sizeof (struct iso_primary_descriptor));
 	
@@ -203,8 +206,31 @@
 	offset = 0;
 #endif
 
-	lseek (fd, (off_t) 2048*(offset+16), SEEK_SET);
-	read (fd, &iso_buffer, 2048);
+#define ISO_SECTOR_SIZE   2048
+#define ISO_ROOT_START   (ISO_SECTOR_SIZE * (offset + 16))
+#define ISO_VD_MAX        84
+
+	for (i = 0, vd_alt_offset = ISO_ROOT_START + ISO_SECTOR_SIZE;
+	     i < ISO_VD_MAX;
+	     i++, vd_alt_offset += ISO_SECTOR_SIZE)
+	{
+		lseek (fd, (off_t) vd_alt_offset, SEEK_SET);
+		read (fd, &iso_buffer, ISO_SECTOR_SIZE);
+		if ((unsigned char)iso_buffer.type[0] == ISO_VD_END)
+			break;
+		if (iso_buffer.type[0] != ISO_VD_SUPPLEMENTARY)
+			continue;
+		if (iso_buffer.volume_id[0] == 0)
+			continue;
+		joliet_label = g_convert (iso_buffer.volume_id, 32, "UTF-8",
+		                          "UTF-16BE", NULL, NULL, NULL);
+		if (!joliet_label)
+			continue;
+		return joliet_label;
+	}
+
+	lseek (fd, (off_t) ISO_ROOT_START, SEEK_SET);
+	read (fd, &iso_buffer, ISO_SECTOR_SIZE);
 
 	if (iso_buffer.volume_id[0] == 0) {
 		return g_strdup (_("ISO 9660 Volume"));
diff -uNr gnome-vfs2-2.9.2/libgnomevfs/gnome-vfs-iso9660.h gnome-vfs2-2.9.2-joliet/libgnomevfs/gnome-vfs-iso9660.h
--- gnome-vfs2-2.9.2/libgnomevfs/gnome-vfs-iso9660.h	2003-11-06 04:44:53.000000000 +1300
+++ gnome-vfs2-2.9.2-joliet/libgnomevfs/gnome-vfs-iso9660.h	2005-01-08 06:05:30.000000000 +1300
@@ -38,6 +38,7 @@
 
 /* volume descriptor types */
 #define ISO_VD_PRIMARY 1
+#define ISO_VD_SUPPLEMENTARY 2
 #define ISO_VD_END 255
 
 #define ISO_STANDARD_ID "CD001"


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