3 * $Id: gdrom.c,v 1.16 2007-10-21 05:20:00 nkeynes Exp $
5 * GD-Rom access functions.
7 * Copyright (c) 2005 Nathan Keynes.
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
23 #include "gdrom/ide.h"
24 #include "gdrom/gdrom.h"
25 #include "gdrom/packet.h"
28 extern gdrom_disc_t gdrom_disc;
30 gdrom_image_class_t gdrom_image_classes[] = { &linux_device_class, &nrg_image_class, &cdi_image_class, NULL };
32 char *gdrom_mode_names[] = { "Mode1", "Mode2", "XA 1", "XA2", "Audio", "GD-Rom" };
33 uint32_t gdrom_sector_size[] = { 2048, 2336, 2048, 2324, 2352, 2336 };
35 gdrom_disc_t gdrom_image_open( const gchar *filename )
37 const gchar *ext = strrchr(filename, '.');
38 gdrom_disc_t disc = NULL;
40 int fd = open( filename, O_RDONLY | O_NONBLOCK );
43 gdrom_image_class_t extclz = NULL;
54 ext++; /* Skip the '.' */
55 for( i=0; gdrom_image_classes[i] != NULL; i++ ) {
56 if( gdrom_image_classes[i]->extension != NULL &&
57 strcasecmp( gdrom_image_classes[i]->extension, ext ) == 0 ) {
58 extclz = gdrom_image_classes[i];
59 if( extclz->is_valid_file(f) ) {
60 disc = extclz->open_image_file(filename, f);
69 /* Okay, fall back to magic */
70 gboolean recognized = FALSE;
71 for( i=0; gdrom_image_classes[i] != NULL; i++ ) {
72 if( gdrom_image_classes[i] != extclz &&
73 gdrom_image_classes[i]->is_valid_file(f) ) {
75 disc = gdrom_image_classes[i]->open_image_file(filename, f);
85 void gdrom_mount_disc( gdrom_disc_t disc )
89 gdrom_image_dump_info( disc );
92 gboolean gdrom_mount_image( const gchar *filename )
94 gdrom_disc_t disc = gdrom_image_open(filename);
96 gdrom_mount_disc( disc );
102 void gdrom_unmount_disc( )
104 if( gdrom_disc != NULL ) {
105 gdrom_disc->close(gdrom_disc);
.