Commit c4dcc7a5 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

playlist_MLLoad: format library URI correctly

parent 7521a562
......@@ -130,34 +130,39 @@ int playlist_MLLoad( playlist_t *p_playlist )
return VLC_EGENERIC;
}
if( asprintf( &psz_uri, "%s" DIR_SEP "ml.xspf", psz_datadir ) == -1 )
{
psz_uri = NULL;
goto error;
if( asprintf( &psz_uri, "%s" DIR_SEP "ml.xspf", psz_datadir ) != -1 )
{ /* loosy check for media library file */
struct stat st;
int ret = utf8_stat( psz_uri , &st );
free( psz_uri );
if( ret )
{
free( psz_datadir );
return VLC_EGENERIC;
}
}
struct stat p_stat;
/* checks if media library file is present */
if( utf8_stat( psz_uri , &p_stat ) )
goto error;
free( psz_uri );
/* FIXME: WTF? stat() should never be used right before open()! */
if( asprintf( &psz_uri, "file/xspf-open://%s" DIR_SEP "ml.xspf",
psz_datadir ) == -1 )
{
psz_uri = make_URI( psz_datadir );
free( psz_datadir );
psz_datadir = psz_uri;
if( psz_datadir == NULL )
return VLC_EGENERIC;
if( asprintf( &psz_uri, "%s/ml.xspf", psz_datadir ) == -1 )
psz_uri = NULL;
goto error;
}
free( psz_datadir );
psz_datadir = NULL;
if( psz_uri == NULL )
return VLC_ENOMEM;
const char *const psz_option = "meta-file";
const char *const options[] = { "meta-file", "demux=xspf-open" };
/* that option has to be cleaned in input_item_subitem_added() */
/* vlc_gc_decref() in the same function */
p_input = input_item_NewExt( p_playlist, psz_uri, _("Media Library"),
1, &psz_option, VLC_INPUT_OPTION_TRUSTED, -1 );
2, options, VLC_INPUT_OPTION_TRUSTED, -1 );
free( psz_uri );
if( p_input == NULL )
goto error;
return VLC_EGENERIC;
PL_LOCK;
if( p_playlist->p_ml_onelevel->p_input )
......@@ -189,13 +194,7 @@ int playlist_MLLoad( playlist_t *p_playlist )
input_item_subitem_added, p_playlist );
vlc_gc_decref( p_input );
free( psz_uri );
return VLC_SUCCESS;
error:
free( psz_uri );
free( psz_datadir );
return VLC_ENOMEM;
}
int playlist_MLDump( playlist_t *p_playlist )
......
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