brasero r817 - in trunk: . src src/plugins/cdrtools src/plugins/checksum src/plugins/dvdcss



Author: philippr
Date: Sun May 18 18:11:52 2008
New Revision: 817
URL: http://svn.gnome.org/viewvc/brasero?rev=817&view=rev

Log:
	Final fix #504838 â don\'t eject disc between after burning, when you want to check the md5sum

	* src/Makefile.am:
	* src/brasero-data-session.c (brasero_data_session_add_last):
	* src/burn-iso9660.c (brasero_iso9660_seek),
	(brasero_iso9660_next_block), (brasero_iso9660_ctx_init),
	(brasero_iso9660_get_contents), (brasero_iso9660_get_file):
	* src/burn-iso9660.h:
	* src/burn-medium.c (brasero_medium_track_volume_size):
	* src/burn-volume-source.c
	(brasero_volume_source_seek_device_handle),
	(brasero_volume_source_seek_fd), (brasero_volume_source_read_fd),
	(brasero_volume_source_read_device_handle),
	(brasero_volume_source_close), (brasero_volume_source_open_file),
	(brasero_volume_source_open_fd),
	(brasero_volume_source_open_device_handle):
	* src/burn-volume-source.h:
	* src/burn-volume.c (brasero_volume_get_primary_from_file),
	(brasero_volume_is_valid_fd), (brasero_volume_get_size),
	(brasero_volume_get_files), (brasero_volume_get_file):
	* src/burn-volume.h:
	* src/plugins/cdrtools/burn-cdrecord.c
	(brasero_cdrecord_export_caps):
	* src/plugins/checksum/burn-checksum-files.c
	(brasero_checksum_files_merge_with_former_session):
	* src/plugins/dvdcss/burn-dvdcss.c
	(brasero_dvdcss_write_image_thread):
	* src/scsi-cam.c:
	* src/scsi-device.h:
	* src/scsi-sg.c:


Added:
   trunk/src/burn-volume-source.c
   trunk/src/burn-volume-source.h
Modified:
   trunk/ChangeLog
   trunk/src/Makefile.am
   trunk/src/brasero-data-session.c
   trunk/src/burn-iso9660.c
   trunk/src/burn-iso9660.h
   trunk/src/burn-medium.c
   trunk/src/burn-volume.c
   trunk/src/burn-volume.h
   trunk/src/plugins/cdrtools/burn-cdrecord.c
   trunk/src/plugins/checksum/burn-checksum-files.c
   trunk/src/plugins/dvdcss/burn-dvdcss.c
   trunk/src/scsi-cam.c
   trunk/src/scsi-device.h
   trunk/src/scsi-sg.c

Modified: trunk/src/Makefile.am
==============================================================================
--- trunk/src/Makefile.am	(original)
+++ trunk/src/Makefile.am	Sun May 18 18:11:52 2008
@@ -257,7 +257,9 @@
 	brasero-rename.h         \
 	brasero-rename.c         \
 	brasero-notify.c         \
-	brasero-notify.h
+	brasero-notify.h         \
+	burn-volume-source.c         \
+	burn-volume-source.h
 
 if BUILD_INOTIFY
 brasero_SOURCES += brasero-file-monitor.c brasero-file-monitor.h

Modified: trunk/src/brasero-data-session.c
==============================================================================
--- trunk/src/brasero-data-session.c	(original)
+++ trunk/src/brasero-data-session.c	Sun May 18 18:11:52 2008
@@ -117,6 +117,7 @@
 	BraseroVolFile *volume;
 	BraseroMedium *medium;
 	const gchar *device;
+	BraseroVolSrc *vol;
 	gint64 block;
 	GList *iter;
 
@@ -144,12 +145,14 @@
 	}
 
 	device = brasero_drive_get_device (priv->drive);
-	volume = brasero_volume_get_files (device,
+	vol = brasero_volume_source_open_file (device, error);
+	volume = brasero_volume_get_files (vol,
 					   block,
 					   NULL,
 					   NULL,
 					   NULL,
 					   error);
+	brasero_volume_source_close (vol);
 	if (*error) {
 		if (volume)
 			brasero_volume_file_free (volume);

Modified: trunk/src/burn-iso9660.c
==============================================================================
--- trunk/src/burn-iso9660.c	(original)
+++ trunk/src/burn-iso9660.c	Sun May 18 18:11:52 2008
@@ -45,7 +45,7 @@
 
 	gchar buffer [ISO9660_BLOCK_SIZE];
 	gint offset;
-	FILE *file;
+	BraseroVolSrc *vol;
 
 	gchar *spare_record;
 
@@ -192,24 +192,14 @@
 	 * 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 (fseek (ctx->file, address * sizeof (ctx->buffer), SEEK_SET) == -1) {
-		BRASERO_BURN_LOG ("fseek () failed at block %lli (%s)", address, strerror (errno));
-		goto error;
-	}
-
-	if (fread (ctx->buffer, 1, sizeof (ctx->buffer), ctx->file) != sizeof (ctx->buffer)) {
-		BRASERO_BURN_LOG ("fread () failed (%s)", strerror (errno));
-		goto error;
-	}
+	if (!BRASERO_VOL_SRC_SEEK (ctx->vol, address, SEEK_SET, &(ctx->error)))
+		return BRASERO_ISO_ERROR;
 
-	return BRASERO_ISO_OK;
+	if (!BRASERO_VOL_SRC_READ (ctx->vol, ctx->buffer, 1, &(ctx->error)))
+		return BRASERO_ISO_ERROR;
 
-error:
 
-	ctx->error = g_error_new (BRASERO_BURN_ERROR,
-				  BRASERO_BURN_ERROR_GENERAL,
-				  strerror (errno));
-	return BRASERO_ISO_ERROR;
+	return BRASERO_ISO_OK;
 }
 
 static BraseroIsoResult
@@ -218,13 +208,8 @@
 	ctx->offset = 0;
 	ctx->num_blocks ++;
 
-	if (fread (ctx->buffer, 1, sizeof (ctx->buffer), ctx->file) != sizeof (ctx->buffer)) {
-		BRASERO_BURN_LOG ("fread () failed (%s)", strerror (errno));
-		ctx->error = g_error_new (BRASERO_BURN_ERROR,
-					  BRASERO_BURN_ERROR_GENERAL,
-					  strerror (errno));
+	if (!BRASERO_VOL_SRC_READ (ctx->vol, ctx->buffer, 1, &(ctx->error)))
 		return BRASERO_ISO_ERROR;
-	}
 
 	return BRASERO_ISO_OK;
 }
@@ -625,17 +610,17 @@
 }
 
 static void
-brasero_iso9660_ctx_init (BraseroIsoCtx *ctx, FILE *file)
+brasero_iso9660_ctx_init (BraseroIsoCtx *ctx, BraseroVolSrc *vol)
 {
 	memset (ctx, 0, sizeof (BraseroIsoCtx));
 
 	ctx->is_root = TRUE;
-	ctx->file = file;
+	ctx->vol = vol;
 	ctx->offset = 0;
 }
 
 BraseroVolFile *
-brasero_iso9660_get_contents (FILE *file,
+brasero_iso9660_get_contents (BraseroVolSrc *vol,
 			      const gchar *block,
 			      gint64 *data_blocks,
 			      GError **error)
@@ -649,7 +634,7 @@
 	primary = (BraseroIsoPrimary *) block;
 	root = primary->root_rec;
 
-	brasero_iso9660_ctx_init (&ctx, file);
+	brasero_iso9660_ctx_init (&ctx, vol);
 
 	address = brasero_iso9660_get_733_val (root->address);
 
@@ -807,7 +792,7 @@
 }
 
 BraseroVolFile *
-brasero_iso9660_get_file (FILE *file,
+brasero_iso9660_get_file (BraseroVolSrc *vol,
 			  const gchar *path,
 			  const gchar *block,
 			  GError **error)
@@ -822,7 +807,7 @@
 	root = primary->root_rec;
 	address = brasero_iso9660_get_733_val (root->address);
 
-	brasero_iso9660_ctx_init (&ctx, file);
+	brasero_iso9660_ctx_init (&ctx, vol);
 
 	/* now that we have root block address, skip first "/" and go. */
 	path ++;

Modified: trunk/src/burn-iso9660.h
==============================================================================
--- trunk/src/burn-iso9660.h	(original)
+++ trunk/src/burn-iso9660.h	Sun May 18 18:11:52 2008
@@ -31,6 +31,7 @@
 #include <glib.h>
 
 #include "burn-volume.h"
+#include "burn-volume-source.h"
 
 #ifndef _BURN_ISO9660_H
 #define _BURN_ISO9660_H
@@ -54,13 +55,13 @@
 			   GError **error);
 
 BraseroVolFile *
-brasero_iso9660_get_contents (FILE *file,
+brasero_iso9660_get_contents (BraseroVolSrc *src,
 			      const gchar *block,
 			      gint64 *nb_blocks,
 			      GError **error);
 
 BraseroVolFile *
-brasero_iso9660_get_file (FILE *file,
+brasero_iso9660_get_file (BraseroVolSrc *src,
 			  const gchar *path,
 			  const gchar *block,
 			  GError **error);

Modified: trunk/src/burn-medium.c
==============================================================================
--- trunk/src/burn-medium.c	(original)
+++ trunk/src/burn-medium.c	Sun May 18 18:11:52 2008
@@ -1154,6 +1154,7 @@
 	BraseroMediumPrivate *priv;
 	BraseroBurnResult res;
 	GError *error = NULL;
+	BraseroVolSrc *vol;
 	gint64 nb_blocks;
 
 	if (!track)
@@ -1170,10 +1171,12 @@
 	 * So we check if their first and only volume is valid. 
 	 * That's also used when the track size is reported a 300 Kio
 	 * see below */
-	res = brasero_volume_get_size_fd (brasero_device_handle_get_fd (handle),
-					  track->start,
-					  &nb_blocks,
-					  NULL);
+	vol = brasero_volume_source_open_device_handle (handle, NULL);
+	res = brasero_volume_get_size (vol,
+				       track->start,
+				       &nb_blocks,
+				       NULL);
+	brasero_volume_source_close (vol);
 	if (!res) {
 		BRASERO_BURN_LOG ("Failed to retrieve the volume size: %s",
 				  error && error->message ? 

Added: trunk/src/burn-volume-source.c
==============================================================================
--- (empty file)
+++ trunk/src/burn-volume-source.c	Sun May 18 18:11:52 2008
@@ -0,0 +1,203 @@
+/***************************************************************************
+ *            burn-volume-source.c
+ *
+ *  Sun May 18 09:48:14 2008
+ *  Copyright  2008  Philippe Rouquier
+ *  <bonfire-app wanadoo fr>
+ ****************************************************************************/
+
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Library General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301,  USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#  include <config.h>
+#endif
+
+#include <errno.h>
+#include <stdio.h>
+#include <unistd.h>
+
+#include "burn-debug.h"
+#include "burn-volume-source.h"
+#include "burn-iso9660.h"
+
+#include "scsi-mmc1.h"
+
+static gboolean
+brasero_volume_source_seek_device_handle (BraseroVolSrc *src,
+					  guint block,
+					  gint whence,
+					  GError **error)
+{
+	if (whence == SEEK_CUR)
+		src->position += block;
+	else if (whence == SEEK_SET)
+		src->position = block;
+
+	return TRUE;
+}
+
+static gboolean
+brasero_volume_source_seek_fd (BraseroVolSrc *src,
+			       guint block,
+			       int whence,
+			       GError **error)
+{
+	if (fseek (src->data, block * ISO9660_BLOCK_SIZE, whence) == -1) {
+		BRASERO_BURN_LOG ("fseek () failed at block %lli (%s)", block, strerror (errno));
+		g_set_error (error,
+			     BRASERO_BURN_ERROR,
+			     BRASERO_BURN_ERROR_GENERAL,
+			     strerror (errno));
+		return FALSE;
+	}
+
+	return TRUE;
+}
+
+static gboolean
+brasero_volume_source_read_fd (BraseroVolSrc *src,
+			       gchar *buffer,
+			       guint blocks,
+			       GError **error)
+{
+	guint64 bytes_read;
+
+	bytes_read = fread (buffer, 1, ISO9660_BLOCK_SIZE * blocks, src->data);
+	if (bytes_read != ISO9660_BLOCK_SIZE * blocks) {
+		BRASERO_BURN_LOG ("fread () failed (%s)", strerror (errno));
+		g_set_error (error,
+			     BRASERO_BURN_ERROR,
+			     BRASERO_BURN_ERROR_GENERAL,
+			     strerror (errno));
+		return FALSE;
+	}
+
+	return TRUE;
+}
+
+static gboolean
+brasero_volume_source_read_device_handle (BraseroVolSrc *src,
+					  gchar *buffer,
+					  guint blocks,
+					  GError **error)
+{
+	BraseroScsiResult result;
+	BraseroScsiErrCode code;
+
+	result = brasero_mmc1_read_block (src->data,
+					  TRUE,
+					  BRASERO_SCSI_BLOCK_TYPE_ANY,
+					  BRASERO_SCSI_BLOCK_HEADER_NONE,
+					  BRASERO_SCSI_BLOCK_NO_SUBCHANNEL,
+					  src->position,
+					  blocks,
+					  (unsigned char *) buffer,
+					  blocks * ISO9660_BLOCK_SIZE,
+					  &code);
+
+	if (result == BRASERO_SCSI_OK)
+		return TRUE;
+
+	g_set_error (error,
+		     BRASERO_BURN_ERROR,
+		     BRASERO_BURN_ERROR_GENERAL,
+		     brasero_scsi_strerror (code));
+	return FALSE;
+}
+
+void
+brasero_volume_source_close (BraseroVolSrc *src)
+{
+	if (src->seek == brasero_volume_source_seek_fd)
+		fclose (src->data);
+
+	g_free (src);
+}
+
+BraseroVolSrc *
+brasero_volume_source_open_file (const gchar *path,
+				 GError **error)
+{
+	BraseroVolSrc *src;
+	FILE *file;
+
+	file = fopen (path, "r");
+	if (!file) {
+		BRASERO_BURN_LOG ("open () failed (%s)", strerror (errno));
+		g_set_error (error,
+			     BRASERO_BURN_ERROR,
+			     BRASERO_BURN_ERROR_GENERAL,
+			     strerror (errno));
+		return FALSE;
+	}
+
+	src = g_new0 (BraseroVolSrc, 1);
+	src->data = file;
+	src->seek = brasero_volume_source_seek_fd;
+	src->read = brasero_volume_source_read_fd;
+	return src;
+}
+
+BraseroVolSrc *
+brasero_volume_source_open_fd (int fd,
+			       GError **error)
+{
+	BraseroVolSrc *src;
+	int dup_fd;
+	FILE *file;
+
+	dup_fd = dup (fd);
+	if (dup_fd == -1) {
+		BRASERO_BURN_LOG ("dup () failed (%s)", strerror (errno));
+		g_set_error (error,
+			     BRASERO_BURN_ERROR,
+			     BRASERO_BURN_ERROR_GENERAL,
+			     strerror (errno));
+		return FALSE;
+	}
+
+	file = fdopen (dup_fd, "r");
+	if (!file) {
+		close (dup_fd);
+
+		BRASERO_BURN_LOG ("fdopen () failed (%s)", strerror (errno));
+		g_set_error (error,
+			     BRASERO_BURN_ERROR,
+			     BRASERO_BURN_ERROR_GENERAL,
+			     strerror (errno));
+		return FALSE;
+	}
+
+	src = g_new0 (BraseroVolSrc, 1);
+	src->data = file;
+	src->seek = brasero_volume_source_seek_fd;
+	src->read = brasero_volume_source_read_fd;
+	return src;
+}
+
+BraseroVolSrc *
+brasero_volume_source_open_device_handle (BraseroDeviceHandle *handle,
+					  GError **error)
+{
+	BraseroVolSrc *src;
+
+	src = g_new0 (BraseroVolSrc, 1);
+	src->data = handle;
+	src->seek = brasero_volume_source_seek_device_handle;
+	src->read = brasero_volume_source_read_device_handle;
+	return src;
+}

Added: trunk/src/burn-volume-source.h
==============================================================================
--- (empty file)
+++ trunk/src/burn-volume-source.h	Sun May 18 18:11:52 2008
@@ -0,0 +1,74 @@
+/***************************************************************************
+ *            burn-volume-source.h
+ *
+ *  Sun May 18 10:25:36 2008
+ *  Copyright  2008  Philippe Rouquier
+ *  <bonfire-app wanadoo fr>
+ ****************************************************************************/
+
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Library General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301,  USA
+ */
+
+#ifndef _BURN_VOLUME_SOURCE_H
+#define _BURN_VOLUME_SOURCE_H
+
+#include <glib.h>
+
+#include "scsi-device.h"
+
+G_BEGIN_DECLS
+
+typedef struct _BraseroVolSrc BraseroVolSrc;
+
+typedef gboolean (*BraseroVolSrcReadFunc)	(BraseroVolSrc *src,
+						 gchar *buffer,
+						 guint size,
+						 GError **error);
+typedef gboolean (*BraseroVolSrcSeekFunc)	(BraseroVolSrc *src,
+						 guint block,
+						 gint whence,
+						 GError **error);
+struct _BraseroVolSrc {
+	BraseroVolSrcReadFunc read;
+	BraseroVolSrcSeekFunc seek;
+	guint64 position;
+	gpointer data;
+};
+
+#define BRASERO_VOL_SRC_SEEK(vol_MACRO, block_MACRO, whence_MACRO, error_MACRO)	\
+	vol_MACRO->seek (vol_MACRO, block_MACRO, whence_MACRO, error_MACRO)
+
+#define BRASERO_VOL_SRC_READ(vol_MACRO, buffer_MACRO, num_MACRO, error_MACRO)	\
+	vol_MACRO->read (vol_MACRO, buffer_MACRO, num_MACRO, error_MACRO)
+
+BraseroVolSrc *
+brasero_volume_source_open_device_handle (BraseroDeviceHandle *handle,
+					  GError **error);
+BraseroVolSrc *
+brasero_volume_source_open_file (const gchar *path,
+				 GError **error);
+BraseroVolSrc *
+brasero_volume_source_open_fd (int fd,
+			       GError **error);
+
+void
+brasero_volume_source_close (BraseroVolSrc *src);
+
+G_END_DECLS
+
+#endif /* BURN_VOLUME_SOURCE_H */
+
+ 

Modified: trunk/src/burn-volume.c
==============================================================================
--- trunk/src/burn-volume.c	(original)
+++ trunk/src/burn-volume.c	Sun May 18 18:11:52 2008
@@ -34,6 +34,7 @@
 #include <glib.h>
 #include <glib/gi18n-lib.h>
 
+#include "burn-volume-source.h"
 #include "burn-volume.h"
 #include "burn-iso9660.h"
 #include "burn-basics.h"
@@ -90,42 +91,28 @@
 }
 
 static gboolean
-brasero_volume_get_primary_from_file (FILE *file,
+brasero_volume_get_primary_from_file (BraseroVolSrc *vol,
 				      gchar *primary_vol,
 				      GError **error)
 {
-	BraseroVolDesc *vol;
-	int bytes_read;
+	BraseroVolDesc *desc;
 
 	/* skip the first 16 blocks */
-	if (fseek (file, SYSTEM_AREA_SECTORS * ISO9660_BLOCK_SIZE, SEEK_CUR) == -1) {
-		BRASERO_BURN_LOG ("fseek () failed at block %lli (%s)", SYSTEM_AREA_SECTORS, strerror (errno));
-		g_set_error (error,
-			     BRASERO_BURN_ERROR,
-			     BRASERO_BURN_ERROR_GENERAL,
-			     strerror (errno));
+	if (!BRASERO_VOL_SRC_SEEK (vol, SYSTEM_AREA_SECTORS, SEEK_CUR, error))
 		return FALSE;
-	}
 
-	bytes_read = fread (primary_vol, 1, ISO9660_BLOCK_SIZE, file);
-	if (bytes_read != ISO9660_BLOCK_SIZE) {
-		BRASERO_BURN_LOG ("fread () failed (%s)", strerror (errno));
-		g_set_error (error,
-			     BRASERO_BURN_ERROR,
-			     BRASERO_BURN_ERROR_GENERAL,
-			     strerror (errno));
+	if (!BRASERO_VOL_SRC_READ (vol, primary_vol, 1, error))
 		return FALSE;
-	}
 
 	/* make a few checks to ensure this is an ECMA volume */
-	vol = (BraseroVolDesc *) primary_vol;
-	if (memcmp (vol->id, "CD001", 5)
-	&&  memcmp (vol->id, "BEA01", 5)
-	&&  memcmp (vol->id, "BOOT2", 5)
-	&&  memcmp (vol->id, "CDW02", 5)
-	&&  memcmp (vol->id, "NSR02", 5)	/* usually UDF */
-	&&  memcmp (vol->id, "NSR03", 5)	/* usually UDF */
-	&&  memcmp (vol->id, "TEA01", 5)) {
+	desc = (BraseroVolDesc *) primary_vol;
+	if (memcmp (desc->id, "CD001", 5)
+	&&  memcmp (desc->id, "BEA01", 5)
+	&&  memcmp (desc->id, "BOOT2", 5)
+	&&  memcmp (desc->id, "CDW02", 5)
+	&&  memcmp (desc->id, "NSR02", 5)	/* usually UDF */
+	&&  memcmp (desc->id, "NSR03", 5)	/* usually UDF */
+	&&  memcmp (desc->id, "TEA01", 5)) {
 		g_set_error (error,
 			     BRASERO_BURN_ERROR,
 			     BRASERO_BURN_ERROR_GENERAL,
@@ -136,145 +123,27 @@
 	return TRUE;
 }
 
-static gboolean
-brasero_volume_get_primary (const gchar *path,
-			    gchar *primary_vol,
-			    GError **error)
-{
-	FILE *file;
-	gboolean result;
-
-	file = fopen (path, "r");
-	if (!file) {
-		BRASERO_BURN_LOG ("open () failed (%s)", strerror (errno));
-		g_set_error (error,
-			     BRASERO_BURN_ERROR,
-			     BRASERO_BURN_ERROR_GENERAL,
-			     strerror (errno));
-		return FALSE;
-	}
-
-	result = brasero_volume_get_primary_from_file (file, primary_vol, error);
-	fclose (file);
-
-	return result;
-}
-
 gboolean
-brasero_volume_is_valid (const gchar *path, GError **error)
+brasero_volume_is_valid_fd (BraseroVolSrc *vol, GError **error)
 {
 	gchar buffer [ISO9660_BLOCK_SIZE];
 
-	if (!brasero_volume_get_primary (path, buffer, error))
-		return FALSE;
-
-	return TRUE;	
-}
-
-gboolean
-brasero_volume_is_valid_fd (int fd, GError **error)
-{
-	int dup_fd;
-	FILE *file;
-	gboolean result;
-	gchar buffer [ISO9660_BLOCK_SIZE];
-
-	dup_fd = dup (fd);
-	if (dup_fd == -1) {
-		BRASERO_BURN_LOG ("dup () failed (%s)", strerror (errno));
-		goto error;
-	}
-
-	file = fdopen (dup_fd, "r");
-	if (!file) {
-		close (dup_fd);
-
-		BRASERO_BURN_LOG ("fdopen () failed (%s)", strerror (errno));
-		goto error;
-	}
-
-	result = brasero_volume_get_primary_from_file (file, buffer, error);
-	fclose (file);
-
-	return TRUE;
-
-error:
-	g_set_error (error,
-		     BRASERO_BURN_ERROR,
-		     BRASERO_BURN_ERROR_GENERAL,
-		     strerror (errno));
-	return FALSE;
-}
-
-gboolean
-brasero_volume_is_iso9660 (const gchar *path, GError **error)
-{
-	gchar buffer [ISO9660_BLOCK_SIZE];
-
-	if (!brasero_volume_get_primary (path, buffer, error))
-		return FALSE;
-
-	if (!brasero_iso9660_is_primary_descriptor (buffer, error))
-		return FALSE;
-
-	return TRUE;
-}
-
-gboolean
-brasero_volume_get_label (const gchar *path,
-			  gchar **label,
-			  GError **error)
-{
-	gchar buffer [ISO9660_BLOCK_SIZE];
-
-	if (!brasero_volume_get_primary (path, buffer, error))
-		return FALSE;
-
-	if (!brasero_iso9660_is_primary_descriptor (buffer, error))
-		return FALSE;
-
-	return brasero_iso9660_get_label (buffer, label, error);
+	return brasero_volume_get_primary_from_file (vol, buffer, error);
 }
 
 gboolean
-brasero_volume_get_size_fd (int fd,
-			    gint64 block,
-			    gint64 *nb_blocks,
-			    GError **error)
+brasero_volume_get_size (BraseroVolSrc *vol,
+			 gint64 block,
+			 gint64 *nb_blocks,
+			 GError **error)
 {
-	int dup_fd;
-	FILE *file;
 	gboolean result;
 	gchar buffer [ISO9660_BLOCK_SIZE];
 
-	dup_fd = dup (fd);
-	if (dup_fd == -1) {
-		BRASERO_BURN_LOG ("dup () failed (%s)", strerror (errno));
-		goto error;
-	}
-
-	file = fdopen (dup_fd, "r");
-	if (!file) {
-		/* since we dupped the fd close the one */
-		close (dup_fd);
-
-		BRASERO_BURN_LOG ("fdopen () failed (%s)", strerror (errno));
-		goto error;
-	}
-
-	if (fseek (file, block * ISO9660_BLOCK_SIZE, SEEK_SET) == -1) {
-		fclose (file);
-
-		BRASERO_BURN_LOG ("fseek () failed at block %lli (%s)", block, strerror (errno));
-		g_set_error (error,
-			     BRASERO_BURN_ERROR,
-			     BRASERO_BURN_ERROR_GENERAL,
-			     strerror (errno));
+	if (!BRASERO_VOL_SRC_SEEK (vol, block, SEEK_SET, error))
 		return FALSE;
-	}
 
-	result = brasero_volume_get_primary_from_file (file, buffer, error);
-	fclose (file);
+	result = brasero_volume_get_primary_from_file (vol, buffer, error);
 	if (!result)
 		return FALSE;
 
@@ -282,33 +151,10 @@
 		return FALSE;
 
 	return brasero_iso9660_get_size (buffer, nb_blocks, error);
-
-error:
-	g_set_error (error,
-		     BRASERO_BURN_ERROR,
-		     BRASERO_BURN_ERROR_GENERAL,
-		     strerror (errno));
-	return FALSE;
-}
-
-gboolean
-brasero_volume_get_size (const gchar *path,
-			 gint64 *nb_blocks,
-			 GError **error)
-{
-	gchar buffer [ISO9660_BLOCK_SIZE];
-
-	if (!brasero_volume_get_primary (path, buffer, error))
-		return FALSE;
-
-	if (!brasero_iso9660_is_primary_descriptor (buffer, error))
-		return FALSE;
-
-	return brasero_iso9660_get_size (buffer, nb_blocks, error);
 }
 
 BraseroVolFile *
-brasero_volume_get_files (const gchar *path,
+brasero_volume_get_files (BraseroVolSrc *vol,
 			  gint64 block,
 			  gchar **label,
 			  gint64 *nb_blocks,
@@ -316,99 +162,45 @@
 			  GError **error)
 {
 	gchar buffer [ISO9660_BLOCK_SIZE];
-	BraseroVolFile *volroot;
-	FILE *file;
 
-	file = fopen (path, "r");
-	if (!file) {
-		BRASERO_BURN_LOG ("fopen () failed (%s)", strerror (errno));
-		g_set_error (error,
-			     BRASERO_BURN_ERROR,
-			     BRASERO_BURN_ERROR_GENERAL,
-			     strerror (errno));
-		return NULL;
-	}
-
-	if (fseek (file, block * ISO9660_BLOCK_SIZE, SEEK_SET) == -1) {
-		BRASERO_BURN_LOG ("fseek () failed at block %lli (%s)", block, strerror (errno));
-		g_set_error (error,
-			     BRASERO_BURN_ERROR,
-			     BRASERO_BURN_ERROR_GENERAL,
-			     strerror (errno));
-		return NULL;
-	}
+	if (!BRASERO_VOL_SRC_SEEK (vol, block, SEEK_SET, error))
+		return FALSE;
 
-	if (!brasero_volume_get_primary_from_file (file, buffer, error)) {
-		fclose (file);
+	if (!brasero_volume_get_primary_from_file (vol, buffer, error))
 		return NULL;
-	}
 
-	if (!brasero_iso9660_is_primary_descriptor (buffer, error)) {
-		fclose (file);
+	if (!brasero_iso9660_is_primary_descriptor (buffer, error))
 		return NULL;
-	}
 
 	if (label
-	&& !brasero_iso9660_get_label (buffer, label, error)) {
-		fclose (file);
+	&& !brasero_iso9660_get_label (buffer, label, error))
 		return NULL;
-	}
 
 	if (nb_blocks
-	&& !brasero_iso9660_get_size (buffer, nb_blocks, error)) {
-		fclose (file);
+	&& !brasero_iso9660_get_size (buffer, nb_blocks, error))
 		return NULL;
-	}
 
-	volroot = brasero_iso9660_get_contents (file, buffer, data_blocks, error);
-	fclose (file);
-
-	return volroot;
+	return brasero_iso9660_get_contents (vol, buffer, data_blocks, error);
 }
 
 BraseroVolFile *
-brasero_volume_get_file (const gchar *medium,
+brasero_volume_get_file (BraseroVolSrc *vol,
 			 const gchar *path,
 			 gint64 volume_start_block,
 			 GError **error)
 {
 	gchar buffer [ISO9660_BLOCK_SIZE];
-	BraseroVolFile *volfile;
-	FILE *file;
 
-	file = fopen (medium, "r");
-	if (!file) {
-		BRASERO_BURN_LOG ("fopen () failed (%s)", strerror (errno));
-		g_set_error (error,
-			     BRASERO_BURN_ERROR,
-			     BRASERO_BURN_ERROR_GENERAL,
-			     strerror (errno));
+	if (!BRASERO_VOL_SRC_SEEK (vol, volume_start_block, SEEK_SET, error))
 		return NULL;
-	}
 
-	if (fseek (file, volume_start_block * ISO9660_BLOCK_SIZE, SEEK_SET) == -1) {
-		BRASERO_BURN_LOG ("fseek () failed at block %lli (%s)", volume_start_block, strerror (errno));
-		g_set_error (error,
-			     BRASERO_BURN_ERROR,
-			     BRASERO_BURN_ERROR_GENERAL,
-			     strerror (errno));
+	if (!brasero_volume_get_primary_from_file (vol, buffer, error))
 		return NULL;
-	}
-
-	if (!brasero_volume_get_primary_from_file (file, buffer, error)) {
-		fclose (file);
-		return NULL;
-	}
 
-	if (!brasero_iso9660_is_primary_descriptor (buffer, error)) {
-		fclose (file);
+	if (!brasero_iso9660_is_primary_descriptor (buffer, error))
 		return NULL;
-	}
-
-	volfile = brasero_iso9660_get_file (file, path, buffer, error);
-	fclose (file);
 
-	return volfile;
+	return brasero_iso9660_get_file (vol, path, buffer, error);
 }
 
 gchar *

Modified: trunk/src/burn-volume.h
==============================================================================
--- trunk/src/burn-volume.h	(original)
+++ trunk/src/burn-volume.h	Sun May 18 18:11:52 2008
@@ -29,6 +29,8 @@
 
 G_BEGIN_DECLS
 
+#include "burn-volume-source.h"
+
 struct _BraseroVolDesc {
 	guchar type;
 	gchar id			[5];
@@ -70,32 +72,17 @@
 };
 
 gboolean
-brasero_volume_is_valid (const gchar *path,
+brasero_volume_is_valid (BraseroVolSrc *src,
 			 GError **error);
-gboolean
-brasero_volume_is_valid_fd (int fd, GError **error);
 
 gboolean
-brasero_volume_is_iso9660 (const gchar *path,
-			   GError **error);
-
-gboolean
-brasero_volume_get_size (const gchar *path,
+brasero_volume_get_size (BraseroVolSrc *src,
+			 gint64 block,
 			 gint64 *nb_blocks,
 			 GError **error);
-gboolean
-brasero_volume_get_size_fd (int fd,
-			    gint64 block,
-			    gint64 *nb_blocks,
-			    GError **error);
-
-gboolean
-brasero_volume_get_label (const gchar *path,
-			  gchar **label,
-			  GError **error);
 
 BraseroVolFile *
-brasero_volume_get_files (const gchar *path,
+brasero_volume_get_files (BraseroVolSrc *src,
 			  gint64 block,
 			  gchar **label,
 			  gint64 *nb_blocks,
@@ -103,7 +90,7 @@
 			  GError **error);
 
 BraseroVolFile *
-brasero_volume_get_file (const gchar *medium,
+brasero_volume_get_file (BraseroVolSrc *src,
 			 const gchar *path,
 			 gint64 volume_start_block,
 			 GError **error);

Modified: trunk/src/plugins/cdrtools/burn-cdrecord.c
==============================================================================
--- trunk/src/plugins/cdrtools/burn-cdrecord.c	(original)
+++ trunk/src/plugins/cdrtools/burn-cdrecord.c	Sun May 18 18:11:52 2008
@@ -1229,7 +1229,6 @@
 				  BRASERO_MEDIUM_WRITABLE|
 				  BRASERO_MEDIUM_REWRITABLE|
 				  BRASERO_MEDIUM_BLANK,
-				  BRASERO_BURN_FLAG_DAO|
 				  BRASERO_BURN_FLAG_BURNPROOF|
 				  BRASERO_BURN_FLAG_OVERBURN|
 				  BRASERO_BURN_FLAG_MULTI|
@@ -1237,6 +1236,18 @@
 				  BRASERO_BURN_FLAG_NOGRACE,
 				  BRASERO_BURN_FLAG_NONE);
 
+	brasero_plugin_set_flags (plugin,
+				  BRASERO_MEDIUM_CD|
+				  BRASERO_MEDIUM_WRITABLE|
+				  BRASERO_MEDIUM_REWRITABLE|
+				  BRASERO_MEDIUM_BLANK,
+				  BRASERO_BURN_FLAG_DAO|
+				  BRASERO_BURN_FLAG_BURNPROOF|
+				  BRASERO_BURN_FLAG_OVERBURN|
+				  BRASERO_BURN_FLAG_DUMMY|
+				  BRASERO_BURN_FLAG_NOGRACE,
+				  BRASERO_BURN_FLAG_NONE);
+
 	/* NOTE: APPEND and MERGE are not really exclusive they can co-exist */
 	brasero_plugin_set_flags (plugin,
 				  BRASERO_MEDIUM_CD|

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	Sun May 18 18:11:52 2008
@@ -354,6 +354,7 @@
 	BraseroVolFile *file;
 	BraseroTrack *track;
 	gchar buffer [2048];
+	BraseroVolSrc *vol;
 	gint64 start_block;
 	gchar *device;
 
@@ -370,31 +371,34 @@
 	if (result != BRASERO_BURN_OK)
 		return result;
 
-	brasero_job_get_device (BRASERO_JOB (self), &device);
-
 	/* try every file and make sure they are of the same type */
 	/* FIXME: if not we could make a new checksum ... */
-	file = brasero_volume_get_file (device,
+	brasero_job_get_device (BRASERO_JOB (self), &device);
+	vol = brasero_volume_source_open_file (device, error);
+	file = brasero_volume_get_file (vol,
 					"/"BRASERO_MD5_FILE,
 					start_block,
 					NULL);
+
 	if (!file) {
-		file = brasero_volume_get_file (device,
+		file = brasero_volume_get_file (vol,
 						"/"BRASERO_SHA1_FILE,
 						start_block,
 						NULL);
 		if (!file) {
-			file = brasero_volume_get_file (device,
+			file = brasero_volume_get_file (vol,
 							"/"BRASERO_SHA256_FILE,
 							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,
 						 BRASERO_CHECKSUM_SHA256_FILE);
@@ -405,12 +409,14 @@
 			BRASERO_JOB_LOG (self, "checksum type mismatch (%i against %i)",
 					 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,
 				 BRASERO_CHECKSUM_MD5_FILE);
@@ -419,6 +425,7 @@
 
 	BRASERO_JOB_LOG (self, "Found file %s on %s", file, device);
 	handle = brasero_volume_file_open (device, file);
+	brasero_volume_source_close (vol);
 	g_free (device);
 
 	if (!handle) {

Modified: trunk/src/plugins/dvdcss/burn-dvdcss.c
==============================================================================
--- trunk/src/plugins/dvdcss/burn-dvdcss.c	(original)
+++ trunk/src/plugins/dvdcss/burn-dvdcss.c	Sun May 18 18:11:52 2008
@@ -306,6 +306,7 @@
 	BraseroTrack *track = NULL;
 	guint64 remaining_sectors;
 	FILE *output_fd = NULL;
+	BraseroVolSrc *vol;
 	gint64 volume_size;
 	GQueue *map = NULL;
 
@@ -321,12 +322,15 @@
 	/* get the contents of the DVD */
 	brasero_job_get_current_track (BRASERO_JOB (self), &track);
 	drive = brasero_track_get_drive_source (track);
-	files = brasero_volume_get_files (brasero_drive_get_device (drive),
+
+	vol = brasero_volume_source_open_file (brasero_drive_get_device (drive), &priv->error);
+	files = brasero_volume_get_files (vol,
 					  0,
 					  NULL,
 					  NULL,
 					  NULL,
 					  &priv->error);
+	brasero_volume_source_close (vol);
 	if (!files)
 		goto end;
 

Modified: trunk/src/scsi-cam.c
==============================================================================
--- trunk/src/scsi-cam.c	(original)
+++ trunk/src/scsi-cam.c	Sun May 18 18:11:52 2008
@@ -181,11 +181,3 @@
 	g_free (handle);
 }
 
-int
-brasero_device_handle_get_fd (BraseroDeviceHandle *handle)
-{
-	g_assert (handle != NULL);
-
-	return handle->fd;
-}
-

Modified: trunk/src/scsi-device.h
==============================================================================
--- trunk/src/scsi-device.h	(original)
+++ trunk/src/scsi-device.h	Sun May 18 18:11:52 2008
@@ -39,9 +39,6 @@
 void
 brasero_device_handle_close (BraseroDeviceHandle *handle);
 
-int
-brasero_device_handle_get_fd (BraseroDeviceHandle *handle);
-
 G_END_DECLS
 
 #endif /* _SCSI_DEVICE_H */

Modified: trunk/src/scsi-sg.c
==============================================================================
--- trunk/src/scsi-sg.c	(original)
+++ trunk/src/scsi-sg.c	Sun May 18 18:11:52 2008
@@ -189,9 +189,3 @@
 	g_free (handle);
 }
 
-int
-brasero_device_handle_get_fd (BraseroDeviceHandle *handle)
-{
-	return handle->fd;
-}
-



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