Commit f15e81c7 authored by Derk-Jan Hartman's avatar Derk-Jan Hartman

vcd module: fix .cue loading. was failing on .cue's for MP3s

parent 496977e3
...@@ -821,6 +821,7 @@ static int OpenVCDImage( vlc_object_t * p_this, const char *psz_dev, ...@@ -821,6 +821,7 @@ static int OpenVCDImage( vlc_object_t * p_this, const char *psz_dev,
char *psz_cuefile = NULL; char *psz_cuefile = NULL;
FILE *cuefile = NULL; FILE *cuefile = NULL;
char line[1024]; char line[1024];
bool b_found = false;
/* Check if we are dealing with a .cue file */ /* Check if we are dealing with a .cue file */
p_pos = strrchr( psz_dev, '.' ); p_pos = strrchr( psz_dev, '.' );
...@@ -862,35 +863,44 @@ static int OpenVCDImage( vlc_object_t * p_this, const char *psz_dev, ...@@ -862,35 +863,44 @@ static int OpenVCDImage( vlc_object_t * p_this, const char *psz_dev,
goto error; 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, p_vcddev->i_vcdimage_handle = utf8_open( psz_vcdfile,
O_RDONLY | O_NONBLOCK | O_BINARY, 0666 ); O_RDONLY | O_NONBLOCK | O_BINARY, 0666 );
if( p_vcddev->i_vcdimage_handle == -1 && while( fgets( line, 1024, cuefile ) && !b_found )
fscanf( cuefile, "FILE %c", line ) &&
fgets( line, 1024, cuefile ) )
{ {
/* We have a cue file, but no valid vcd file yet */ /* We have a cue file, but no valid vcd file yet */
free( psz_vcdfile ); char filename[1024];
p_pos = strchr( line, '"' ); char type[16];
if( p_pos ) int i_temp = sscanf( line, "FILE \"%1023[^\"]\" %15s", filename, type );
*p_pos = 0;
switch( i_temp )
{ {
*p_pos = 0; case 2:
msg_Dbg( p_this, "the cue file says the data file is %s", type );
/* Take care of path standardization */ if( strcasecmp( type, "BINARY" ) )
if( *line != '/' && ((p_pos = strrchr( psz_cuefile, '/' )) goto error; /* Error if not binary, otherwise treat as case 1 */
|| (p_pos = strrchr( psz_cuefile, '\\' ) )) ) case 1:
{ if( p_vcddev->i_vcdimage_handle == -1 )
psz_vcdfile = malloc( strlen(line) + {
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 ); (p_pos - psz_cuefile + 1) + 1 );
strncpy( psz_vcdfile, psz_cuefile, (p_pos - psz_cuefile + 1) ); strncpy( psz_vcdfile, psz_cuefile, (p_pos - psz_cuefile + 1) );
strcpy( psz_vcdfile + (p_pos - psz_cuefile + 1), line ); strcpy( psz_vcdfile + (p_pos - psz_cuefile + 1), filename );
} } else psz_vcdfile = strdup( filename );
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,
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 ); O_RDONLY | O_NONBLOCK | O_BINARY, 0666 );
}
b_found = true;
default:
break;
}
} }
if( p_vcddev->i_vcdimage_handle == -1) if( p_vcddev->i_vcdimage_handle == -1)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment