Search
lxdream.org :: lxdream/src/gdrom/nrg.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/gdrom/nrg.c
changeset 168:203a72138e16
prev142:2f631c3a3946
next342:850502f0e8de
author nkeynes
date Mon Jun 26 10:30:42 2006 +0000 (14 years ago)
permissions -rw-r--r--
last change Implement multi-format CD image support
Fix CDI support up to (more or less) work
file annotate diff log raw
1.1 --- a/src/gdrom/nrg.c Tue May 02 14:09:11 2006 +0000
1.2 +++ b/src/gdrom/nrg.c Mon Jun 26 10:30:42 2006 +0000
1.3 @@ -1,5 +1,5 @@
1.4 /**
1.5 - * $Id: nrg.c,v 1.2 2006-05-02 14:09:11 nkeynes Exp $
1.6 + * $Id: nrg.c,v 1.3 2006-06-26 10:30:42 nkeynes Exp $
1.7 *
1.8 * Nero (NRG) CD file format. File information stolen shamelessly from
1.9 * libcdio.
1.10 @@ -23,6 +23,12 @@
1.11 #include "gdrom/gdrom.h"
1.12 #include "dream.h"
1.13
1.14 +static gboolean nrg_image_is_valid( FILE *f );
1.15 +static gdrom_disc_t nrg_image_open( const gchar *filename, FILE *f );
1.16 +
1.17 +struct gdrom_image_class nrg_image_class = { "Nero", "nrg",
1.18 + nrg_image_is_valid, nrg_image_open };
1.19 +
1.20 #define NERO_V55_ID 0x4e455235
1.21 #define NERO_V50_ID 0x4e45524f
1.22
1.23 @@ -131,9 +137,21 @@
1.24 }
1.25 }
1.26
1.27 -gdrom_disc_t nrg_image_open( const gchar *filename )
1.28 +static gboolean nrg_image_is_valid( FILE *f )
1.29 {
1.30 - FILE *f = fopen( filename, "ro" );
1.31 + union nrg_footer footer;
1.32 +
1.33 + fseek( f, -12, SEEK_END );
1.34 + fread( &footer, sizeof(footer), 1, f );
1.35 + if( ntohl(footer.v50.id) == NERO_V50_ID ) {
1.36 + return TRUE;
1.37 + } else {
1.38 + return FALSE;
1.39 + }
1.40 +}
1.41 +
1.42 +static gdrom_disc_t nrg_image_open( const gchar *filename, FILE *f )
1.43 +{
1.44 union nrg_footer footer;
1.45 struct nrg_chunk chunk;
1.46 struct nrg_daoi *dao;
1.47 @@ -145,11 +163,6 @@
1.48 int cue_track_id = 0, cue_track_count = 0;
1.49 int i;
1.50
1.51 - if( f == NULL ) {
1.52 - ERROR( "Unable to open file '%s': %s", filename, strerror(errno) );
1.53 - return NULL;
1.54 - }
1.55 -
1.56 fseek( f, -12, SEEK_END );
1.57 fread( &footer, sizeof(footer), 1, f );
1.58 if( ntohl(footer.v50.id) == NERO_V50_ID ) {
1.59 @@ -159,14 +172,13 @@
1.60 INFO( "Loading Nero 5.5+ image" );
1.61 fseek( f, ntohl(footer.v55.offset), SEEK_SET );
1.62 } else {
1.63 - ERROR("Unable to understand file '%s' as a Nero image", filename );
1.64 + /* Not a (recognized) Nero image */
1.65 return NULL;
1.66 }
1.67
1.68 disc = gdrom_image_new(f);
1.69 if( disc == NULL ) {
1.70 ERROR("Unable to allocate memory!");
1.71 - fclose(f);
1.72 return NULL;
1.73 }
1.74
.