[vlc-devel] commit: vcd module: fix .cue loading. was failing on .cue's for MP3s ( Derk-Jan Hartman )
git version control
git at videolan.org
Mon Jul 28 00:56:27 CEST 2008
vlc | branch: master | Derk-Jan Hartman <hartman at videolan.org> | Mon Jul 28 00:58:03 2008 +0200| [f15e81c767bc2134f18a2490d34860069403e4e8]
vcd module: fix .cue loading. was failing on .cue's for MP3s
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=f15e81c767bc2134f18a2490d34860069403e4e8
---
modules/access/vcd/cdrom.c | 52 ++++++++++++++++++++++++++-----------------
1 files changed, 31 insertions(+), 21 deletions(-)
diff --git a/modules/access/vcd/cdrom.c b/modules/access/vcd/cdrom.c
index 072cccf..b411c44 100644
--- a/modules/access/vcd/cdrom.c
+++ b/modules/access/vcd/cdrom.c
@@ -821,6 +821,7 @@ static int OpenVCDImage( vlc_object_t * p_this, const char *psz_dev,
char *psz_cuefile = NULL;
FILE *cuefile = NULL;
char line[1024];
+ bool b_found = false;
/* Check if we are dealing with a .cue file */
p_pos = strrchr( psz_dev, '.' );
@@ -862,35 +863,44 @@ static int OpenVCDImage( vlc_object_t * p_this, const char *psz_dev,
goto error;
}
- msg_Dbg( p_this,"using vcd image file: %s", psz_vcdfile );
+ msg_Dbg( p_this,"guessing vcd image file: %s", psz_vcdfile );
p_vcddev->i_vcdimage_handle = utf8_open( psz_vcdfile,
O_RDONLY | O_NONBLOCK | O_BINARY, 0666 );
- if( p_vcddev->i_vcdimage_handle == -1 &&
- fscanf( cuefile, "FILE %c", line ) &&
- fgets( line, 1024, cuefile ) )
+ while( fgets( line, 1024, cuefile ) && !b_found )
{
/* We have a cue file, but no valid vcd file yet */
- free( psz_vcdfile );
- p_pos = strchr( line, '"' );
- if( p_pos )
+ char filename[1024];
+ char type[16];
+ int i_temp = sscanf( line, "FILE \"%1023[^\"]\" %15s", filename, type );
+ *p_pos = 0;
+ switch( i_temp )
{
- *p_pos = 0;
-
- /* Take care of path standardization */
- if( *line != '/' && ((p_pos = strrchr( psz_cuefile, '/' ))
- || (p_pos = strrchr( psz_cuefile, '\\' ) )) )
- {
- psz_vcdfile = malloc( strlen(line) +
+ case 2:
+ msg_Dbg( p_this, "the cue file says the data file is %s", type );
+ if( strcasecmp( type, "BINARY" ) )
+ goto error; /* Error if not binary, otherwise treat as case 1 */
+ case 1:
+ if( p_vcddev->i_vcdimage_handle == -1 )
+ {
+ msg_Dbg( p_this, "we could not find the data file, but we found a new path" );
+ free( psz_vcdfile);
+ if( *filename != '/' && ((p_pos = strrchr( psz_cuefile, '/' ))
+ || (p_pos = strrchr( psz_cuefile, '\\' ) )) )
+ {
+ psz_vcdfile = malloc( strlen(filename) +
(p_pos - psz_cuefile + 1) + 1 );
- strncpy( psz_vcdfile, psz_cuefile, (p_pos - psz_cuefile + 1) );
- strcpy( psz_vcdfile + (p_pos - psz_cuefile + 1), line );
- }
- else psz_vcdfile = strdup( line );
- }
- msg_Dbg( p_this,"using vcd image file: %s", psz_vcdfile );
- p_vcddev->i_vcdimage_handle = utf8_open( psz_vcdfile,
+ strncpy( psz_vcdfile, psz_cuefile, (p_pos - psz_cuefile + 1) );
+ strcpy( psz_vcdfile + (p_pos - psz_cuefile + 1), filename );
+ } else psz_vcdfile = strdup( filename );
+ msg_Dbg( p_this,"using vcd image file: %s", psz_vcdfile );
+ p_vcddev->i_vcdimage_handle = utf8_open( psz_vcdfile,
O_RDONLY | O_NONBLOCK | O_BINARY, 0666 );
+ }
+ b_found = true;
+ default:
+ break;
+ }
}
if( p_vcddev->i_vcdimage_handle == -1)
More information about the vlc-devel
mailing list