1.1 --- a/src/gdrom/gdrom.c Mon Jun 26 10:30:42 2006 +0000
1.2 +++ b/src/gdrom/gdrom.c Fri Dec 15 10:18:39 2006 +0000
1.5 - * $Id: gdrom.c,v 1.9 2006-06-26 10:30:42 nkeynes Exp $
1.6 + * $Id: gdrom.c,v 1.10 2006-12-14 12:31:38 nkeynes Exp $
1.8 * GD-Rom access functions.
1.16 #include "gdrom/ide.h"
1.17 #include "gdrom/gdrom.h"
1.19 static void gdrom_image_destroy( gdrom_disc_t );
1.20 static gdrom_error_t gdrom_image_read_sectors( gdrom_disc_t, uint32_t, uint32_t, int, char *, uint32_t * );
1.22 -gdrom_image_class_t gdrom_image_classes[] = { &nrg_image_class, &cdi_image_class, NULL };
1.23 +gdrom_image_class_t gdrom_image_classes[] = { &linux_device_class, &nrg_image_class, &cdi_image_class, NULL };
1.25 gdrom_disc_t gdrom_disc = NULL;
1.29 const gchar *ext = strrchr(filename, '.');
1.30 gdrom_disc_t disc = NULL;
1.31 - FILE *f = fopen(filename, "ro");
1.33 + int fd = open( filename, O_RDONLY | O_NONBLOCK );
1.36 gdrom_image_class_t extclz = NULL;
1.40 ERROR("Unable to open file '%s': %s", filename, strerror(errno));
1.44 + f = fdopen(fd, "ro");
1.47 /* try extensions */
1.49 ext++; /* Skip the '.' */
1.50 for( i=0; gdrom_image_classes[i] != NULL; i++ ) {
1.51 - if( strcasecmp( gdrom_image_classes[i]->extension, ext ) == 0 ) {
1.52 + if( gdrom_image_classes[i]->extension != NULL &&
1.53 + strcasecmp( gdrom_image_classes[i]->extension, ext ) == 0 ) {
1.54 extclz = gdrom_image_classes[i];
1.55 if( extclz->is_valid_file(f) ) {
1.56 disc = extclz->open_image_file(filename, f);
1.60 /* Okay, fall back to magic */
1.61 + gboolean recognized = FALSE;
1.62 for( i=0; gdrom_image_classes[i] != NULL; i++ ) {
1.63 if( gdrom_image_classes[i] != extclz &&
1.64 gdrom_image_classes[i]->is_valid_file(f) ) {
1.65 + recognized = TRUE;
1.66 disc = gdrom_image_classes[i]->open_image_file(filename, f);
1.72 + if( !recognized ) {
1.73 + ERROR( "Unable to open disc %s: Unsupported format", filename );