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[] = { &cdrom_device_class,
36 char *gdrom_mode_names[] = { "Mode1", "Mode2", "XA 1", "XA2", "Audio", "GD-Rom" };
37 uint32_t gdrom_sector_size[] = { 2048, 2336, 2048, 2324, 2352, 2336 };
39 gdrom_disc_t gdrom_image_open( const gchar *filename )
41 const gchar *ext = strrchr(filename, '.');
42 gdrom_disc_t disc = NULL;
44 int fd = open( filename, O_RDONLY | O_NONBLOCK );
47 gdrom_image_class_t extclz = NULL;
58 ext++; /* Skip the '.' */
59 for( i=0; gdrom_image_classes[i] != NULL; i++ ) {
60 if( gdrom_image_classes[i]->extension != NULL &&
61 strcasecmp( gdrom_image_classes[i]->extension, ext ) == 0 ) {
62 extclz = gdrom_image_classes[i];
63 if( extclz->is_valid_file(f) ) {
64 disc = extclz->open_image_file(filename, f);
73 /* Okay, fall back to magic */
74 gboolean recognized = FALSE;
75 for( i=0; gdrom_image_classes[i] != NULL; i++ ) {
76 if( gdrom_image_classes[i] != extclz &&
77 gdrom_image_classes[i]->is_valid_file(f) ) {
79 disc = gdrom_image_classes[i]->open_image_file(filename, f);
89 void gdrom_mount_disc( gdrom_disc_t disc )
93 gdrom_image_dump_info( disc );
96 gboolean gdrom_mount_image( const gchar *filename )
98 gdrom_disc_t disc = gdrom_image_open(filename);
100 gdrom_mount_disc( disc );
106 void gdrom_unmount_disc( )
108 if( gdrom_disc != NULL ) {
109 gdrom_disc->close(gdrom_disc);
115 gdrom_disc_t gdrom_get_current_disc()
.