1.1 --- a/src/gdrom/gdrom.c Mon Jun 19 11:00:42 2006 +0000
1.2 +++ b/src/gdrom/gdrom.c Tue Jun 27 09:34:27 2006 +0000
1.5 - * $Id: gdrom.c,v 1.8 2006-06-19 11:00:42 nkeynes Exp $
1.6 + * $Id: gdrom.c,v 1.9 2006-06-26 10:30:42 nkeynes Exp $
1.8 * GD-Rom access functions.
1.16 #include "gdrom/ide.h"
1.17 #include "gdrom/gdrom.h"
1.18 #include "gdrom/packet.h"
1.20 static void gdrom_image_destroy( gdrom_disc_t );
1.21 static gdrom_error_t gdrom_image_read_sectors( gdrom_disc_t, uint32_t, uint32_t, int, char *, uint32_t * );
1.23 +gdrom_image_class_t gdrom_image_classes[] = { &nrg_image_class, &cdi_image_class, NULL };
1.25 gdrom_disc_t gdrom_disc = NULL;
1.29 gdrom_disc_t gdrom_image_open( const gchar *filename )
1.31 - return nrg_image_open( filename );
1.32 + const gchar *ext = strrchr(filename, '.');
1.33 + gdrom_disc_t disc = NULL;
1.34 + FILE *f = fopen(filename, "ro");
1.36 + gdrom_image_class_t extclz = NULL;
1.39 + ERROR("Unable to open file '%s': %s", filename, strerror(errno));
1.43 + /* try extensions */
1.44 + if( ext != NULL ) {
1.45 + ext++; /* Skip the '.' */
1.46 + for( i=0; gdrom_image_classes[i] != NULL; i++ ) {
1.47 + if( strcasecmp( gdrom_image_classes[i]->extension, ext ) == 0 ) {
1.48 + extclz = gdrom_image_classes[i];
1.49 + if( extclz->is_valid_file(f) ) {
1.50 + disc = extclz->open_image_file(filename, f);
1.51 + if( disc != NULL )
1.59 + /* Okay, fall back to magic */
1.60 + for( i=0; gdrom_image_classes[i] != NULL; i++ ) {
1.61 + if( gdrom_image_classes[i] != extclz &&
1.62 + gdrom_image_classes[i]->is_valid_file(f) ) {
1.63 + disc = gdrom_image_classes[i]->open_image_file(filename, f);
1.64 + if( disc != NULL )