brasero r1098 - in trunk: . src src/plugins/checksum



Author: philippr
Date: Sat Aug 16 12:40:22 2008
New Revision: 1098
URL: http://svn.gnome.org/viewvc/brasero?rev=1098&view=rev

Log:
	Huge fix for multisession import in case there are relocated directories
	NOTE: there is a bug in genisoimage that doesn\'t generate unique RR names
	for relocated directories under rr_moved/
	Fixed memleaks in:
	brasero-io
	burn-plugin
	burn-volume-read
	burn-checksum-files

	* src/brasero-data-session.c
	(brasero_data_session_add_children_files):
	* src/brasero-io.c (brasero_io_get_file_info_thread):
	* src/burn-iso-field.c (brasero_iso9660_get_733_val):
	* src/burn-iso9660.c (brasero_iso9660_seek),
	(brasero_iso9660_read_susp), (brasero_iso9660_read_file_record),
	(brasero_iso9660_read_directory_record),
	(brasero_iso9660_read_directory_records),
	(brasero_iso9660_lookup_directory_record_RR),
	(brasero_iso9660_lookup_directory_record_ISO),
	(brasero_iso9660_lookup_directory_records),
	(brasero_iso9660_get_file):
	* src/burn-plugin.c (brasero_plugin_finalize):
	* src/burn-susp.c (brasero_susp_CE), (brasero_susp_ER),
	(brasero_susp_CL), (brasero_susp_RE), (brasero_susp_PL),
	(brasero_susp_read):
	* src/burn-susp.h:
	* src/burn-volume-read.c (brasero_volume_file_close),
	(brasero_volume_file_open):
	* src/burn-volume-source.c
	(brasero_volume_source_seek_device_handle),
	(brasero_volume_source_seek_fd):
	* src/burn-volume-source.h:
	* src/burn-volume.c (brasero_volume_get_primary_from_file),
	(brasero_volume_get_size), (brasero_volume_get_files),
	(brasero_volume_get_file):
	* src/burn-volume.h:
	* src/plugins/checksum/burn-checksum-files.c
	(brasero_checksum_file_process_former_line),
	(brasero_checksum_files_merge_with_former_session):

Modified:
   trunk/ChangeLog
   trunk/src/brasero-data-session.c
   trunk/src/brasero-io.c
   trunk/src/burn-iso-field.c
   trunk/src/burn-iso9660.c
   trunk/src/burn-plugin.c
   trunk/src/burn-susp.c
   trunk/src/burn-susp.h
   trunk/src/burn-volume-read.c
   trunk/src/burn-volume-source.c
   trunk/src/burn-volume-source.h
   trunk/src/burn-volume.c
   trunk/src/burn-volume.h
   trunk/src/plugins/checksum/burn-checksum-files.c

Modified: trunk/src/brasero-data-session.c
==============================================================================
--- trunk/src/brasero-data-session.c	(original)
+++ trunk/src/brasero-data-session.c	Sat Aug 16 12:40:22 2008
@@ -100,7 +100,10 @@
 								       child,
 								       parent);
 
-		if (!node->is_file)
+		/* There is little chance that a NULL node will be returned and
+		 * logically that shouldn't be the case. But who knows bugs
+		 * happen, let's try not to crash. ;) */
+		if (node && !node->is_file)
 			brasero_data_session_add_children_files (self,
 								 node,
 								 child->specific.dir.children);

Modified: trunk/src/brasero-io.c
==============================================================================
--- trunk/src/brasero-io.c	(original)
+++ trunk/src/brasero-io.c	Sat Aug 16 12:40:22 2008
@@ -862,6 +862,7 @@
 				  error,
 				  job->callback_data);
 
+	g_free (file_uri);
 	return BRASERO_ASYNC_TASK_FINISHED;
 }
 

Modified: trunk/src/burn-iso-field.c
==============================================================================
--- trunk/src/burn-iso-field.c	(original)
+++ trunk/src/burn-iso-field.c	Sat Aug 16 12:40:22 2008
@@ -33,5 +33,5 @@
 
 	ptr = (guint32*) buffer;
 
-	return GINT32_FROM_LE (*ptr);
+	return GUINT32_FROM_LE (*ptr);
 }

Modified: trunk/src/burn-iso9660.c
==============================================================================
--- trunk/src/burn-iso9660.c	(original)
+++ trunk/src/burn-iso9660.c	Sat Aug 16 12:40:22 2008
@@ -58,6 +58,7 @@
 
 	guint is_root:1;
 	guint has_susp:1;
+	guint has_RR:1;
 };
 typedef struct _BraseroIsoCtx BraseroIsoCtx;
 
@@ -128,6 +129,11 @@
 static BraseroVolFile *
 brasero_iso9660_read_directory_records (BraseroIsoCtx *ctx, gint address);
 
+static BraseroVolFile *
+brasero_iso9660_lookup_directory_records (BraseroIsoCtx *ctx,
+					  const gchar *path,
+					  gint address);
+
 gboolean
 brasero_iso9660_is_primary_descriptor (const char *buffer,
 				       GError **error)
@@ -194,13 +200,12 @@
 	 * by its address member. In a set of directory records the first two 
 	 * records are: '.' (id == 0) and '..' (id == 1). So since we've got
 	 * the address of the set load the block. */
-	if (!BRASERO_VOL_SRC_SEEK (ctx->vol, address, SEEK_SET, &(ctx->error)))
+	if (BRASERO_VOL_SRC_SEEK (ctx->vol, address, SEEK_SET, &(ctx->error)) == -1)
 		return BRASERO_ISO_ERROR;
 
 	if (!BRASERO_VOL_SRC_READ (ctx->vol, ctx->buffer, 1, &(ctx->error)))
 		return BRASERO_ISO_ERROR;
 
-
 	return BRASERO_ISO_OK;
 }
 
@@ -216,6 +221,72 @@
 	return BRASERO_ISO_OK;
 }
 
+static gboolean
+brasero_iso9660_read_susp (BraseroIsoCtx *ctx,
+			   BraseroSuspCtx *susp_ctx,
+			   gchar *susp,
+			   gint susp_len)
+{
+	gboolean result = TRUE;
+	guint64 current_position = -1;
+
+	memset (susp_ctx, 0, sizeof (BraseroSuspCtx));
+	if (!brasero_susp_read (susp_ctx, susp, susp_len)) {
+		BRASERO_BURN_LOG ("Could not read susp area");
+		return FALSE;
+	}
+
+	while (susp_ctx->CE_address) {
+		gchar CE_block [ISO9660_BLOCK_SIZE];
+		gint64 seek_res;
+		guint32 offset;
+		guint32 len;
+
+		BRASERO_BURN_LOG ("Continuation Area");
+
+		/* we need to move to another block */
+		seek_res = BRASERO_VOL_SRC_SEEK (ctx->vol, susp_ctx->CE_address, SEEK_SET, NULL);
+		if (seek_res == -1) {
+			BRASERO_BURN_LOG ("Could not seek to continuation area");
+			result = FALSE;
+			break;
+		}
+
+		if (current_position == -1)
+			current_position = seek_res;
+
+		if (!BRASERO_VOL_SRC_READ (ctx->vol, CE_block, 1, NULL)) {
+			BRASERO_BURN_LOG ("Could not get continuation area");
+			result = FALSE;
+			break;
+		}
+
+		offset = susp_ctx->CE_offset;
+		len = susp_ctx->CE_len;
+
+		/* reset information about the CE area */
+		memset (&susp_ctx->CE_address, 0, sizeof (susp_ctx->CE_address));
+		memset (&susp_ctx->CE_offset, 0, sizeof (susp_ctx->CE_offset));
+		memset (&susp_ctx->CE_len, 0, sizeof (susp_ctx->CE_len));
+
+		/* read all information contained in the CE area */
+		if (!brasero_susp_read (susp_ctx, CE_block + offset, len)) {
+			BRASERO_BURN_LOG ("Could not read continuation area");
+			result = FALSE;
+			break;
+		}
+	}
+
+	/* reset the reading address properly */
+	if (current_position != -1
+	&&  BRASERO_VOL_SRC_SEEK (ctx->vol, current_position, SEEK_SET, NULL) == -1) {
+		BRASERO_BURN_LOG ("Could not rewind to previous position");
+		result = FALSE;
+	}
+
+	return result;
+}
+
 static gchar *
 brasero_iso9660_get_susp (BraseroIsoCtx *ctx,
 			  BraseroIsoDirRec *record,
@@ -321,61 +392,12 @@
 	return BRASERO_ISO_ERROR;
 }
 
-static gboolean
-brasero_iso9660_read_record_iso_name (BraseroIsoCtx *ctx,
-				      BraseroIsoDirRec *record,
-				      gchar *iso_name)
-{
-	if (record->id_size > record->record_size - sizeof (BraseroIsoDirRec)) {
-		ctx->error = g_error_new (BRASERO_BURN_ERROR,
-					  BRASERO_BURN_ERROR_GENERAL,
-					  _("file name is too long"));
-		return FALSE;
-	}
-
-	memcpy (iso_name, record->id, record->id_size);
-	iso_name [record->id_size] = '\0';
-
-	return TRUE;
-}
-
-static gboolean
-brasero_iso9660_read_record_rr_name (BraseroIsoCtx *ctx,
-				     BraseroIsoDirRec *record,
-				     gchar *rr_name)
-{
-	gchar *susp;
-	gint susp_len;
-	BraseroSuspCtx susp_ctx;
-
-	if (!ctx->has_susp)
-		return FALSE;
-
-	BRASERO_BURN_LOG ("Directory with susp area");
-
-	susp = brasero_iso9660_get_susp (ctx, record, &susp_len);
-	if (!brasero_susp_read (&susp_ctx, susp, susp_len)) {
-		BRASERO_BURN_LOG ("Could not read susp area");
-		return FALSE;
-	}
-
-	if (susp_ctx.rr_name) {
-		BRASERO_BURN_LOG ("Got a susp (RR) %s", susp_ctx.rr_name);
-		strcpy (rr_name, susp_ctx.rr_name);
-	}
-
-	brasero_susp_ctx_clean (&susp_ctx);
-	return TRUE;
-}
-
 static BraseroVolFile *
 brasero_iso9660_read_file_record (BraseroIsoCtx *ctx,
-				  BraseroIsoDirRec *record)
+				  BraseroIsoDirRec *record,
+				  BraseroSuspCtx *susp_ctx)
 {
-	gchar *susp;
-	gint susp_len;
 	BraseroVolFile *file;
-	BraseroSuspCtx susp_ctx;
 	BraseroVolFileExtent *extent;
 
 	if (record->id_size > record->record_size - sizeof (BraseroIsoDirRec)) {
@@ -392,35 +414,26 @@
 
 	file->specific.file.size_bytes = brasero_iso9660_get_733_val (record->file_size);
 
-	/* NOTE a file can be in multiple places */
+	/* NOTE: a file can be in multiple places */
 	extent = g_new (BraseroVolFileExtent, 1);
 	extent->block = brasero_iso9660_get_733_val (record->address);
 	extent->size = brasero_iso9660_get_733_val (record->file_size);
 	file->specific.file.extents = g_slist_prepend (file->specific.file.extents, extent);
 
 	/* see if we've got a susp area */
-	if (!ctx->has_susp) {
+	if (!susp_ctx) {
 		BRASERO_BURN_LOG ("New file %s", file->name);
 		return file;
 	}
 
 	BRASERO_BURN_LOG ("New file %s with a suspend area", file->name);
 
-	susp = brasero_iso9660_get_susp (ctx, record, &susp_len);
-	if (!brasero_susp_read (&susp_ctx, susp, susp_len)) {
-		BRASERO_BURN_LOG ("Could not read susp area");
-		brasero_volume_file_free (file);
-		return NULL;
+	if (susp_ctx->rr_name) {
+		BRASERO_BURN_LOG ("Got a susp (RR) %s", susp_ctx->rr_name);
+		file->rr_name = susp_ctx->rr_name;
+		susp_ctx->rr_name = NULL;
 	}
 
-	if (susp_ctx.rr_name) {
-		BRASERO_BURN_LOG ("Got a susp (RR) %s", susp_ctx.rr_name);
-
-		file->rr_name = susp_ctx.rr_name;
-		susp_ctx.rr_name = NULL;
-	}
-
-	brasero_susp_ctx_clean (&susp_ctx);
 	return file;
 }
 
@@ -441,39 +454,59 @@
 		return NULL;
 	}
 
-	address = brasero_iso9660_get_733_val (record->address);
+	if (ctx->has_susp && ctx->has_RR) {
+		/* See if we've got a susp area. Do it now to see if it has a CL
+		 * entry. The rest will be checked later after reading contents.
+		 */
+		susp = brasero_iso9660_get_susp (ctx, record, &susp_len);
+		if (!brasero_iso9660_read_susp (ctx, &susp_ctx, susp, susp_len)) {
+			BRASERO_BURN_LOG ("Could not read susp area");
+			return NULL;
+		}
+
+		/* look for a "CL" SUSP entry in case the directory was relocated */
+		if (susp_ctx.CL_address) {
+			BRASERO_BURN_LOG ("Entry has a CL entry");
+			address = susp_ctx.CL_address;
+		}
+		else
+			address = brasero_iso9660_get_733_val (record->address);
+	}
+	else
+		address = brasero_iso9660_get_733_val (record->address);
+
 	directory = brasero_iso9660_read_directory_records (ctx, address);
-	if (!directory)
+	if (!directory) {
+		if (ctx->has_susp && ctx->has_RR)
+			brasero_susp_ctx_clean (&susp_ctx);
+
 		return NULL;
+	}
 
 	directory->name = g_new0 (gchar, record->id_size + 1);
 	memcpy (directory->name, record->id, record->id_size);
 
-	if (!ctx->has_susp) {
+	if (!ctx->has_susp || !ctx->has_RR) {
 		BRASERO_BURN_LOG ("New directory %s", directory->name);
 		return directory;
 	}
 
 	BRASERO_BURN_LOG ("New directory %s with susp area", directory->name);
 
-	/* see if we've got a susp area */
-	susp = brasero_iso9660_get_susp (ctx, record, &susp_len);
-	if (!brasero_susp_read (&susp_ctx, susp, susp_len)) {
-		BRASERO_BURN_LOG ("Could not read susp area");
-
-		brasero_volume_file_free (directory);
-		return NULL;
+	/* if this directory has a "RE" susp entry then drop it; it's not at the
+	 * right place in the Rock Ridge file hierarchy. */
+	if (susp_ctx.has_RE) {
+		BRASERO_BURN_LOG ("Rock Ridge relocated directory. Skipping entry.");
+		directory->relocated = TRUE;
 	}
 
 	if (susp_ctx.rr_name) {
 		BRASERO_BURN_LOG ("Got a susp (RR) %s", susp_ctx.rr_name);
-
 		directory->rr_name = susp_ctx.rr_name;
 		susp_ctx.rr_name = NULL;
 	}
 
 	brasero_susp_ctx_clean (&susp_ctx);
-
 	return directory;
 }
 
@@ -507,12 +540,19 @@
 		gchar *susp;
 
 		susp = brasero_iso9660_get_susp (ctx, record, &susp_len);
-		brasero_susp_read (&susp_ctx, susp, susp_len);
+		brasero_iso9660_read_susp (ctx, &susp_ctx, susp, susp_len);
 
 		ctx->has_susp = susp_ctx.has_SP;
+		ctx->has_RR = susp_ctx.has_RockRidge;
 		ctx->susp_skip = susp_ctx.skip;
 		ctx->is_root = FALSE;
 
+		if (ctx->has_susp)
+			BRASERO_BURN_LOG ("File system supports system use sharing protocol");
+
+		if (ctx->has_RR)
+			BRASERO_BURN_LOG ("File system has Rock Ridge extension");
+
 		brasero_susp_ctx_clean (&susp_ctx);
 	}
 
@@ -557,35 +597,73 @@
 			copy = g_new0 (gchar, record->record_size);
 			memcpy (copy, record, record->record_size);
 			directories = g_slist_prepend (directories, copy);
+			continue;
 		}
-		else {
-			entry = brasero_iso9660_read_file_record (ctx, record);
-			if (!entry)
+
+		if (ctx->has_RR) {
+			BraseroSuspCtx susp_ctx = { NULL, };
+			gint susp_len = 0;
+			gchar *susp;
+
+			/* See if we've got a susp area. Do it now to see if it
+			 * has a CL entry. The rest will be checked later after
+			 * reading contents. Otherwise we wouldn't be able to 
+			 * get deep directories that are flagged as files.
+			 */
+			susp = brasero_iso9660_get_susp (ctx, record, &susp_len);
+			if (!brasero_iso9660_read_susp (ctx, &susp_ctx, susp, susp_len)) {
+				BRASERO_BURN_LOG ("Could not read susp area");
 				goto error;
+			}
+
+			/* look for a "CL" SUSP entry in case the directory was
+			 * relocated. If it has, it's a directory and keep it
+			 * for later. */
+			if (susp_ctx.CL_address) {
+				gpointer copy;
+
+				BRASERO_BURN_LOG ("Entry has a CL entry, keeping for later");
+				copy = g_new0 (gchar, record->record_size);
+				memcpy (copy, record, record->record_size);
+				directories = g_slist_prepend (directories, copy);
+
+				brasero_susp_ctx_clean (&susp_ctx);
+				memset (&susp_ctx, 0, sizeof (BraseroSuspCtx));
+				continue;
+			}
+
+			entry = brasero_iso9660_read_file_record (ctx, record, &susp_ctx);
+			brasero_susp_ctx_clean (&susp_ctx);
+		}
+		else
+			entry = brasero_iso9660_read_file_record (ctx, record, NULL);
+
+		if (!entry)
+			goto error;
+
+		entry->parent = parent;
 
-			entry->parent = parent;
+		/* check that we don't have another file record for the
+		 * same file (usually files > 4G). It always follows
+		 * its sibling */
+		if (parent->specific.dir.children) {
+			BraseroVolFile *last;
 
-			/* check that we don't have another file record for the
-			 * same file (usually files > 4G). It always follows
-			 * its sibling */
-			if (parent->specific.dir.children) {
-				BraseroVolFile *last;
-
-				last = parent->specific.dir.children->data;
-				if (!last->isdir && !strcmp (BRASERO_VOLUME_FILE_NAME (last), BRASERO_VOLUME_FILE_NAME (entry))) {
-					/* add size and addresses */
-					ctx->data_blocks += ISO9660_BYTES_TO_BLOCKS (entry->specific.file.size_bytes);
-					last = brasero_volume_file_merge (last, entry);
-					BRASERO_BURN_LOG ("Multi extent file");
-					continue;
-				}
+			last = parent->specific.dir.children->data;
+			if (!last->isdir && !strcmp (BRASERO_VOLUME_FILE_NAME (last), BRASERO_VOLUME_FILE_NAME (entry))) {
+				/* add size and addresses */
+				ctx->data_blocks += ISO9660_BYTES_TO_BLOCKS (entry->specific.file.size_bytes);
+				last = brasero_volume_file_merge (last, entry);
+				BRASERO_BURN_LOG ("Multi extent file");
+				continue;
 			}
-			parent->specific.dir.children = g_list_prepend (parent->specific.dir.children, entry);
-			ctx->data_blocks += ISO9660_BYTES_TO_BLOCKS (entry->specific.file.size_bytes);
 		}
+
+		parent->specific.dir.children = g_list_prepend (parent->specific.dir.children, entry);
+		ctx->data_blocks += ISO9660_BYTES_TO_BLOCKS (entry->specific.file.size_bytes);
 	}
 
-	/* takes care of the directories: we accumulate them not to change the
+	/* Takes care of the directories: we accumulate them not to change the
 	 * offset of file descriptor FILE */
 	for (iter = directories; iter; iter = iter->next) {
 		record = iter->data;
@@ -594,6 +672,11 @@
 		if (!entry)
 			goto error;
 
+		if (entry->relocated) {
+			brasero_volume_file_free (entry);
+			continue;
+		}
+
 		entry->parent = parent;
 		parent->specific.dir.children = g_list_prepend (parent->specific.dir.children, entry);
 	}
@@ -656,7 +739,101 @@
 }
 
 static BraseroVolFile *
-brasero_iso9660_lookup_directory_record (BraseroIsoCtx *ctx,
+brasero_iso9660_lookup_directory_record_RR (BraseroIsoCtx *ctx,
+					    const gchar *path,
+					    guint len,
+					    BraseroIsoDirRec *record)
+{
+	BraseroVolFile *entry = NULL;
+	BraseroSuspCtx susp_ctx;
+	gchar record_name [256];
+	gint susp_len = 0;
+	gchar *susp;
+
+	/* See if we've got a susp area. Do it now to see if it
+	 * has a CL entry and rr_name. */
+	susp = brasero_iso9660_get_susp (ctx, record, &susp_len);
+	if (!brasero_iso9660_read_susp (ctx, &susp_ctx, susp, susp_len)) {
+		BRASERO_BURN_LOG ("Could not read susp area");
+		return NULL;
+	}
+
+	/* set name */
+	if (!susp_ctx.rr_name) {
+		memcpy (record_name, record->id, record->id_size);
+		record_name [record->id_size] = '\0';
+	}
+	else
+		strcpy (record_name, susp_ctx.rr_name);
+
+	if (!(record->flags & BRASERO_ISO_FILE_DIRECTORY)) {
+		if (len) {
+			/* Look for a "CL" SUSP entry in case it was
+			 * relocated. If it has, it's a directory. */
+			if (susp_ctx.CL_address && !strncmp (record_name, path, len)) {
+				/* move path forward */
+				path += len;
+				path ++;
+
+				entry = brasero_iso9660_lookup_directory_records (ctx,
+										  path,
+										  susp_ctx.CL_address);
+			}
+		}
+		else if (!strcmp (record_name, path))
+			entry = brasero_iso9660_read_file_record (ctx,
+								  record,
+								  &susp_ctx);
+	}
+	else if (len && !strncmp (record_name, path, len)) {
+		gint address;
+
+		/* move path forward */
+		path += len;
+		path ++;
+
+		address = brasero_iso9660_get_733_val (record->address);
+		entry = brasero_iso9660_lookup_directory_records (ctx,
+								  path,
+								  address);
+	}
+
+	brasero_susp_ctx_clean (&susp_ctx);
+	return entry;
+}
+
+static BraseroVolFile *
+brasero_iso9660_lookup_directory_record_ISO (BraseroIsoCtx *ctx,
+					     const gchar *path,
+					     guint len,
+					     BraseroIsoDirRec *record)
+{
+	BraseroVolFile *entry = NULL;
+
+	if (!(record->flags & BRASERO_ISO_FILE_DIRECTORY)) {
+		if (!len && !strncmp (record->id, path, record->id_size))
+			entry = brasero_iso9660_read_file_record (ctx,
+								  record,
+								  NULL);
+	}
+	else if (len && !strncmp (record->id, path, record->id_size)) {
+		gint address;
+
+		/* move path forward */
+		path += len;
+		path ++;
+
+		address = brasero_iso9660_get_733_val (record->address);
+		entry = brasero_iso9660_lookup_directory_records (ctx,
+								  path,
+								  address);
+	}
+
+	return entry;
+}
+
+static BraseroVolFile *
+brasero_iso9660_lookup_directory_records (BraseroIsoCtx *ctx,
 					 const gchar *path,
 					 gint address)
 {
@@ -679,20 +856,28 @@
 	if (result != BRASERO_ISO_OK)
 		return NULL;
 
-	/* look for "SP" SUSP if it's root directory */
+	/* Look for "SP" SUSP if it's root directory. Also look for "ER" which
+	 * should tell us whether Rock Ridge could be used. */
 	if (ctx->is_root) {
 		BraseroSuspCtx susp_ctx;
 		gint susp_len;
 		gchar *susp;
 
 		susp = brasero_iso9660_get_susp (ctx, record, &susp_len);
-		brasero_susp_read (&susp_ctx, susp, susp_len);
+		brasero_iso9660_read_susp (ctx, &susp_ctx, susp, susp_len);
 
 		ctx->has_susp = susp_ctx.has_SP;
+		ctx->has_RR = susp_ctx.has_RockRidge;
 		ctx->susp_skip = susp_ctx.skip;
 		ctx->is_root = FALSE;
 
 		brasero_susp_ctx_clean (&susp_ctx);
+
+		if (ctx->has_susp)
+			BRASERO_BURN_LOG ("File system supports system use sharing protocol");
+
+		if (ctx->has_RR)
+			BRASERO_BURN_LOG ("File system has Rock Ridge extension");
 	}
 
 	max_record_size = brasero_iso9660_get_733_val (record->file_size);
@@ -715,7 +900,7 @@
 
 	while (1) {
 		BraseroIsoResult result;
-		gchar record_name [256];
+		BraseroVolFile *entry;
 
 		result = brasero_iso9660_next_record (ctx, &record);
 		if (result == BRASERO_ISO_END) {
@@ -742,52 +927,29 @@
 			break;
 		}
 
-		if (!brasero_iso9660_read_record_rr_name (ctx, record, record_name)
-		&&  !brasero_iso9660_read_record_iso_name (ctx, record, record_name))
-			continue;
-
-		/* if it's a directory, keep the record for later (we don't 
-		 * want to change the reading offset for the moment) */
-		if (!len && !(record->flags & BRASERO_ISO_FILE_DIRECTORY)) {
-			BraseroVolFile *entry;
-
-			/* see if we are looking for a file */
-			if (len)
-				continue;
-
-			/* see if that the record we're looking for */
-			if (strcmp (record_name, path))
-				continue;
-
-			/* carry on with the search in case there are other extents */
-			entry = brasero_iso9660_read_file_record (ctx, record);
-			if (!entry)
-				return NULL;
-
-			if (file) {
-				/* add size and addresses */
-				file = brasero_volume_file_merge (file, entry);
-				BRASERO_BURN_LOG ("Multi extent file");
-			}
-			else
-				file = entry;
+		if (ctx->has_RR)
+			entry = brasero_iso9660_lookup_directory_record_RR (ctx,
+									    path,
+									    len,
+									    record);
+		else
+			entry = brasero_iso9660_lookup_directory_record_ISO (ctx,
+									     path,
+									     len,
+									     record);
 
+		if (!entry)
 			continue;
-		}
 
-		if (len && !strncmp (record_name, path, len)) {
-			gint address;
-
-			/* move path forward */
-			path += len;
-			path ++;
-
-			address = brasero_iso9660_get_733_val (record->address);
-			file = brasero_iso9660_lookup_directory_record (ctx,
-									path,
-									address);
-			break;
+		if (file) {
+			/* add size and addresses */
+			file = brasero_volume_file_merge (file, entry);
+			BRASERO_BURN_LOG ("Multi extent file");
 		}
+		else
+			file = entry;
+
+		/* carry on in case that's a multi extent file */
 	}
 
 	return file;
@@ -813,7 +975,7 @@
 
 	/* now that we have root block address, skip first "/" and go. */
 	path ++;
-	entry = brasero_iso9660_lookup_directory_record (&ctx, path, address);
+	entry = brasero_iso9660_lookup_directory_records (&ctx, path, address);
 
 	/* clean context */
 	if (ctx.spare_record)

Modified: trunk/src/burn-plugin.c
==============================================================================
--- trunk/src/burn-plugin.c	(original)
+++ trunk/src/burn-plugin.c	Sat Aug 16 12:40:22 2008
@@ -1072,7 +1072,12 @@
 		priv->notify_priority = 0;
 		g_object_unref (client);
 	}
-		
+
+	if (priv->error) {
+		g_free (priv->error);
+		priv->error = NULL;
+	}
+
 	G_OBJECT_CLASS (parent_class)->finalize (object);
 }
 

Modified: trunk/src/burn-susp.c
==============================================================================
--- trunk/src/burn-susp.c	(original)
+++ trunk/src/burn-susp.c	Sat Aug 16 12:40:22 2008
@@ -44,6 +44,24 @@
 };
 typedef struct _BraseroSuspSP BraseroSuspSP;
 
+struct _BraseroSuspER {
+	BraseroSusp susp	[1];
+	gchar id_len;
+	gchar desc_len;
+	gchar src_len;
+	gchar extension_version;
+	gchar id [0];
+};
+typedef struct _BraseroSuspER BraseroSuspER;
+
+struct _BraseroSuspCE {
+	BraseroSusp susp	[1];
+	guchar block		[8];
+	guchar offset		[8];
+	guchar len		[8];
+};
+typedef struct _BraseroSuspCE BraseroSuspCE;
+
 struct _BraseroRockNM {
 	BraseroSusp susp	[1];
 	gchar flags;
@@ -95,6 +113,44 @@
 }
 
 static gboolean
+brasero_susp_CE (BraseroSusp *susp,
+		 BraseroSuspCtx *ctx)
+{
+	BraseroSuspCE *ce;
+
+	ce = (BraseroSuspCE *) susp;
+
+	ctx->CE_address = brasero_iso9660_get_733_val (ce->block);
+	ctx->CE_offset = brasero_iso9660_get_733_val (ce->offset);
+	ctx->CE_len = brasero_iso9660_get_733_val (ce->len);
+
+	return TRUE;
+}
+
+static gboolean
+brasero_susp_ER (BraseroSusp *susp,
+		 BraseroSuspCtx *ctx)
+{
+	BraseroSuspER *er;
+
+	er = (BraseroSuspER *) susp;
+
+	/* Make sure the extention is Rock Ridge */
+	if (susp->version != 1)
+		return FALSE;
+
+	if (er->id_len != 10)
+		return TRUE;
+
+	if (!strncmp (er->id, "IEEE_P1282", 10))
+		ctx->has_RockRidge = TRUE;
+	else if (!strncmp (er->id, "RRIP_1991A", 10))
+		ctx->has_RockRidge = TRUE;
+
+	return TRUE;
+}
+
+static gboolean
 brasero_susp_NM (BraseroSusp *susp,
 		 BraseroSuspCtx *ctx)
 {
@@ -139,13 +195,11 @@
 		 BraseroSuspCtx *ctx)
 {
 	BraseroRockCL *cl;
-	gint address;
 
 	/* Child Link */
 	cl = (BraseroRockCL *) susp;
-	address = brasero_iso9660_get_733_val (cl->location);
-	ctx->rr_children = g_slist_prepend (ctx->rr_children,
-					    GINT_TO_POINTER (address));
+	ctx->CL_address = brasero_iso9660_get_733_val (cl->location);
+
 	return TRUE;
 }
 
@@ -158,6 +212,7 @@
 	if (susp->len != 4 || susp->version != 1)
 		return FALSE;
 
+	ctx->has_RE = TRUE;
 	return TRUE;
 }
 
@@ -170,7 +225,8 @@
 	if (ctx->rr_parent)
 		return FALSE;
 
-	/* Parent Link */
+	/* That's to store original parent address of this node before it got
+	 * relocated. */
 	pl = (BraseroRockPL *) susp;
 	ctx->rr_parent = brasero_iso9660_get_733_val (pl->location);
 	return TRUE;
@@ -182,8 +238,6 @@
 	BraseroSusp *susp;
 	gint offset;
 
-	memset (ctx, 0, sizeof (BraseroSuspCtx));
-
 	if (max <= 0)
 		return TRUE;
 
@@ -204,7 +258,13 @@
 		result = TRUE;
 		if (!memcmp (susp->signature, "SP", 2))
 			result = brasero_susp_SP (susp, ctx);
-		if (!memcmp (susp->signature, "NM", 2))
+		/* Continuation area */
+		else if (!memcmp (susp->signature, "CE", 2))
+			result = brasero_susp_CE (susp, ctx);
+		/* This is to indicate that we're using Rock Ridge */
+		else if (!memcmp (susp->signature, "ER", 2))
+			result = brasero_susp_ER (susp, ctx);
+		else if (!memcmp (susp->signature, "NM", 2))
 			result = brasero_susp_NM (susp, ctx);
 		else if (!memcmp (susp->signature, "CL", 2))
 			result = brasero_susp_CL (susp, ctx);

Modified: trunk/src/burn-susp.h
==============================================================================
--- trunk/src/burn-susp.h	(original)
+++ trunk/src/burn-susp.h	Sat Aug 16 12:40:22 2008
@@ -33,8 +33,15 @@
 	gchar *rr_name;
 
 	gboolean has_SP;
+	gboolean has_RE;
+	gboolean has_RockRidge;
+
+	gint32 CL_address;
+
+	guint32 CE_address;
+	guint32 CE_offset;
+	guint32 CE_len;
 
-	GSList *rr_children;
 	gint rr_parent;
 
 	guchar skip;

Modified: trunk/src/burn-volume-read.c
==============================================================================
--- trunk/src/burn-volume-read.c	(original)
+++ trunk/src/burn-volume-read.c	Sat Aug 16 12:40:22 2008
@@ -52,6 +52,7 @@
 {
 	g_slist_free (handle->extents_forward);
 	g_slist_free (handle->extents_backward);
+	brasero_volume_source_close (handle->src);
 	g_free (handle);
 }
 
@@ -62,6 +63,7 @@
 	BraseroVolFileHandle *handle;
 	BraseroVolFileExtent *extent;
 	gboolean result;
+	gint res_seek;
 	GSList *node;
 
 	if (file->isdir)
@@ -85,8 +87,8 @@
 	handle->extent_last = BRASERO_SIZE_TO_SECTORS (extent->size, 2048) + extent->block;
 
 	/* start loading first block */
-	result = BRASERO_VOL_SRC_SEEK (handle->src, handle->position, SEEK_SET,  NULL);
-	if (!result) {
+	res_seek = BRASERO_VOL_SRC_SEEK (handle->src, handle->position, SEEK_SET,  NULL);
+	if (res_seek == -1) {
 		brasero_volume_file_close (handle);
 		return NULL;
 	}

Modified: trunk/src/burn-volume-source.c
==============================================================================
--- trunk/src/burn-volume-source.c	(original)
+++ trunk/src/burn-volume-source.c	Sat Aug 16 12:40:22 2008
@@ -36,27 +36,33 @@
 
 #include "scsi-mmc1.h"
 
-static gboolean
+static gint64
 brasero_volume_source_seek_device_handle (BraseroVolSrc *src,
 					  guint block,
 					  gint whence,
 					  GError **error)
 {
+	gint64 oldpos;
+
+	oldpos = src->position;
+
 	if (whence == SEEK_CUR)
 		src->position += block;
 	else if (whence == SEEK_SET)
 		src->position = block;
 
-	return TRUE;
+	return oldpos;
 }
 
-static gboolean
+static gint64
 brasero_volume_source_seek_fd (BraseroVolSrc *src,
 			       guint block,
 			       int whence,
 			       GError **error)
 {
-	
+	gint64 oldpos;
+
+	oldpos = ftello (src->data);
 	if (fseeko (src->data, (guint64) (block * ISO9660_BLOCK_SIZE), whence) == -1) {
 		BRASERO_BURN_LOG ("fseeko () failed at block %i (= %lli bytes) (%s)",
 				  block,
@@ -66,10 +72,10 @@
 			     BRASERO_BURN_ERROR,
 			     BRASERO_BURN_ERROR_GENERAL,
 			     strerror (errno));
-		return FALSE;
+		return -1;
 	}
 
-	return TRUE;
+	return oldpos / ISO9660_BLOCK_SIZE;
 }
 
 static gboolean

Modified: trunk/src/burn-volume-source.h
==============================================================================
--- trunk/src/burn-volume-source.h	(original)
+++ trunk/src/burn-volume-source.h	Sat Aug 16 12:40:22 2008
@@ -37,7 +37,7 @@
 						 gchar *buffer,
 						 guint size,
 						 GError **error);
-typedef gboolean (*BraseroVolSrcSeekFunc)	(BraseroVolSrc *src,
+typedef gint64	 (*BraseroVolSrcSeekFunc)	(BraseroVolSrc *src,
 						 guint block,
 						 gint whence,
 						 GError **error);

Modified: trunk/src/burn-volume.c
==============================================================================
--- trunk/src/burn-volume.c	(original)
+++ trunk/src/burn-volume.c	Sat Aug 16 12:40:22 2008
@@ -100,7 +100,7 @@
 	BraseroVolDesc *desc;
 
 	/* skip the first 16 blocks */
-	if (!BRASERO_VOL_SRC_SEEK (vol, SYSTEM_AREA_SECTORS, SEEK_CUR, error))
+	if (BRASERO_VOL_SRC_SEEK (vol, SYSTEM_AREA_SECTORS, SEEK_CUR, error) == -1)
 		return FALSE;
 
 	if (!BRASERO_VOL_SRC_READ (vol, primary_vol, 1, error))
@@ -142,7 +142,7 @@
 	gboolean result;
 	gchar buffer [ISO9660_BLOCK_SIZE];
 
-	if (!BRASERO_VOL_SRC_SEEK (vol, block, SEEK_SET, error))
+	if (BRASERO_VOL_SRC_SEEK (vol, block, SEEK_SET, error) == -1)
 		return FALSE;
 
 	result = brasero_volume_get_primary_from_file (vol, buffer, error);
@@ -165,7 +165,7 @@
 {
 	gchar buffer [ISO9660_BLOCK_SIZE];
 
-	if (!BRASERO_VOL_SRC_SEEK (vol, block, SEEK_SET, error))
+	if (BRASERO_VOL_SRC_SEEK (vol, block, SEEK_SET, error) == -1)
 		return FALSE;
 
 	if (!brasero_volume_get_primary_from_file (vol, buffer, error))
@@ -193,7 +193,7 @@
 {
 	gchar buffer [ISO9660_BLOCK_SIZE];
 
-	if (!BRASERO_VOL_SRC_SEEK (vol, volume_start_block, SEEK_SET, error))
+	if (BRASERO_VOL_SRC_SEEK (vol, volume_start_block, SEEK_SET, error) == -1)
 		return NULL;
 
 	if (!brasero_volume_get_primary_from_file (vol, buffer, error))

Modified: trunk/src/burn-volume.h
==============================================================================
--- trunk/src/burn-volume.h	(original)
+++ trunk/src/burn-volume.h	Sat Aug 16 12:40:22 2008
@@ -62,15 +62,14 @@
 
 	struct {
 		GList *children;
-
-		/* FIXME: rr_children isn't needed here apparently it could be 
-		 * replaced by extents. */
-		GList *rr_children;
 	} dir;
 
 	} specific;
 
 	guint isdir:1;
+
+	/* mainly used internally */
+	guint relocated:1;
 };
 
 gboolean

Modified: trunk/src/plugins/checksum/burn-checksum-files.c
==============================================================================
--- trunk/src/plugins/checksum/burn-checksum-files.c	(original)
+++ trunk/src/plugins/checksum/burn-checksum-files.c	Sat Aug 16 12:40:22 2008
@@ -290,18 +290,15 @@
 	guint i;
 	gchar *path;
 	GSList *grafts;
-	gchar *checksum;
 	guint written_bytes;
 	BraseroChecksumFilesPrivate *priv;
 
 	priv = BRASERO_CHECKSUM_FILES_PRIVATE (self);
 
-	/* first read the checksum string */
+	/* first skip the checksum string */
 	i = 0;
 	while (!isspace (line [i])) i ++;
 
-	checksum = g_strndup (line, i);
-
 	/* skip white spaces */
 	while (isspace (line [i])) i ++;
 
@@ -315,15 +312,21 @@
 		/* NOTE: graft->path + 1 is because in the checksum files on the 
 		 * disc there is not first "/" so if we want to compare ... */
 		graft = grafts->data;
-		if (!strcmp (graft->path + 1, path))
+		if (!strcmp (graft->path + 1, path)) {
+			g_free (path);
 			return BRASERO_BURN_OK;
+		}
 
 		len = strlen (graft->path + 1);
 		if (!strncmp (graft->path + 1, path, len)
-		&&   path [len] == G_DIR_SEPARATOR)
+		&&   path [len] == G_DIR_SEPARATOR) {
+			g_free (path);
 			return BRASERO_BURN_OK;
+		}
 	}
 
+	g_free (path);
+
 	/* write the whole line in the new file */
 	written_bytes = fwrite (line, 1, strlen (line), priv->file);
 	if (written_bytes != strlen (line)) {
@@ -377,6 +380,8 @@
 	/* FIXME: if not we could make a new checksum ... */
 	brasero_job_get_device (BRASERO_JOB (self), &device);
 	vol = brasero_volume_source_open_file (device, error);
+	g_free (device);
+
 	file = brasero_volume_get_file (vol,
 					"/"BRASERO_MD5_FILE,
 					start_block,
@@ -393,13 +398,11 @@
 							start_block,
 							NULL);
 			if (!file) {
-				g_free (device);
 				brasero_volume_source_close (vol);
 				BRASERO_JOB_LOG (self, "no checksum file found");
 				return BRASERO_BURN_OK;
 			}
 			else if (priv->checksum_type != BRASERO_CHECKSUM_SHA256_FILE) {
-				g_free (device);
 				brasero_volume_source_close (vol);
 				BRASERO_JOB_LOG (self, "checksum type mismatch (%i against %i)",
 						 priv->checksum_type,
@@ -412,12 +415,10 @@
 					 priv->checksum_type,
 					 BRASERO_CHECKSUM_SHA1_FILE);
 			brasero_volume_source_close (vol);
-			g_free (device);
 			return BRASERO_BURN_OK;
 		}
 	}
 	else if (priv->checksum_type != BRASERO_CHECKSUM_MD5_FILE) {
-		g_free (device);
 		brasero_volume_source_close (vol);
 		BRASERO_JOB_LOG (self, "checksum type mismatch (%i against %i)",
 				 priv->checksum_type,
@@ -425,17 +426,13 @@
 		return BRASERO_BURN_OK;
 	}
 
-	BRASERO_JOB_LOG (self, "Found file %s on %s", file, device);
-	brasero_volume_source_open_device_path (device, error);
-	if (!vol)
-		return BRASERO_BURN_ERR;
-
+	BRASERO_JOB_LOG (self, "Found file %s", file);
 	handle = brasero_volume_file_open (vol, file);
 	brasero_volume_source_close (vol);
-	g_free (device);
 
 	if (!handle) {
 		BRASERO_JOB_LOG (self, "Failed to open file");
+		brasero_volume_file_free (file);
 		return BRASERO_BURN_ERR;
 	}
 
@@ -448,12 +445,17 @@
 	while (result == BRASERO_BURN_RETRY) {
 		if (priv->cancel) {
 			brasero_volume_file_close (handle);
+			brasero_volume_file_free (file);
 			return BRASERO_BURN_CANCEL;
 		}
 
-		result = brasero_checksum_file_process_former_line (self, track, buffer, error);
+		result = brasero_checksum_file_process_former_line (self,
+								    track,
+								    buffer,
+								    error);
 		if (result != BRASERO_BURN_OK) {
 			brasero_volume_file_close (handle);
+			brasero_volume_file_free (file);
 			return result;
 		}
 
@@ -462,6 +464,7 @@
 
 	result = brasero_checksum_file_process_former_line (self, track, buffer, error);
 	brasero_volume_file_close (handle);
+	brasero_volume_file_free (file);
 
 	return result;
 }



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