Commit f42e1999 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont Committed by Derk-Jan Hartman

playlist_MLLoad: format library URI correctly

(cherry picked from commit c4dcc7a5)
Signed-off-by: default avatarDerk-Jan Hartman <hartman@videolan.org>
parent 059bfafb
...@@ -130,34 +130,39 @@ int playlist_MLLoad( playlist_t *p_playlist ) ...@@ -130,34 +130,39 @@ int playlist_MLLoad( playlist_t *p_playlist )
return VLC_EGENERIC; return VLC_EGENERIC;
} }
if( asprintf( &psz_uri, "%s" DIR_SEP "ml.xspf", psz_datadir ) == -1 ) if( asprintf( &psz_uri, "%s" DIR_SEP "ml.xspf", psz_datadir ) != -1 )
{ { /* loosy check for media library file */
psz_uri = NULL; struct stat st;
goto error; 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()! */ psz_uri = make_URI( psz_datadir );
if( asprintf( &psz_uri, "file/xspf-open://%s" DIR_SEP "ml.xspf", free( psz_datadir );
psz_datadir ) == -1 ) psz_datadir = psz_uri;
{ if( psz_datadir == NULL )
return VLC_EGENERIC;
if( asprintf( &psz_uri, "%s/ml.xspf", psz_datadir ) == -1 )
psz_uri = NULL; psz_uri = NULL;
goto error;
}
free( psz_datadir ); free( psz_datadir );
psz_datadir = NULL; 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() */ /* that option has to be cleaned in input_item_subitem_added() */
/* vlc_gc_decref() in the same function */ /* vlc_gc_decref() in the same function */
p_input = input_item_NewExt( p_playlist, psz_uri, _("Media Library"), 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 ) if( p_input == NULL )
goto error; return VLC_EGENERIC;
PL_LOCK; PL_LOCK;
if( p_playlist->p_ml_onelevel->p_input ) if( p_playlist->p_ml_onelevel->p_input )
...@@ -189,13 +194,7 @@ int playlist_MLLoad( playlist_t *p_playlist ) ...@@ -189,13 +194,7 @@ int playlist_MLLoad( playlist_t *p_playlist )
input_item_subitem_added, p_playlist ); input_item_subitem_added, p_playlist );
vlc_gc_decref( p_input ); vlc_gc_decref( p_input );
free( psz_uri );
return VLC_SUCCESS; return VLC_SUCCESS;
error:
free( psz_uri );
free( psz_datadir );
return VLC_ENOMEM;
} }
int playlist_MLDump( playlist_t *p_playlist ) 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