libvlc_media_library_load( libvlc_media_library_t * p_mlib,
libvlc_exception_t * p_e )
{
- const char *psz_datadir =
- libvlc_priv (p_mlib->p_libvlc_instance->p_libvlc_int)->psz_datadir;
+ char *psz_datadir = config_GetUserDataDir();
char * psz_uri;
if( !psz_datadir ) /* XXX: i doubt that this can ever happen */
if( asprintf( &psz_uri, "file/xspf-open://%s" DIR_SEP "ml.xsp",
psz_datadir ) == -1 )
{
+ free( psz_datadir );
libvlc_exception_raise( p_e, "Can't get create the path" );
return;
}
+ free( psz_datadir );
if( p_mlib->p_mlist )
libvlc_media_list_release( p_mlib->p_mlist );
/* Set the config file stuff */
p_libvlc->psz_homedir = config_GetHomeDir();
- priv->psz_datadir = config_GetUserDataDir();
priv->psz_configfile = config_GetCustomConfigFile( p_libvlc );
/* Check for plugins cache options */
module_EndBank( p_libvlc );
FREENULL( p_libvlc->psz_homedir );
- free( priv->psz_datadir );
FREENULL( priv->psz_configfile );
var_DelCallback( p_libvlc, "key-pressed", vlc_key_to_action,
p_libvlc->p_hotkeys );
/* Configuration */
vlc_mutex_t config_lock; ///< config file lock
char * psz_configfile; ///< location of config file
- char *psz_datadir; ///< user data directory
/* There is no real reason to keep a list of items, but not to break
* everything, let's keep it */
int playlist_MLLoad( playlist_t *p_playlist )
{
- const char *psz_datadir = libvlc_priv (p_playlist->p_libvlc)->psz_datadir;
+ char *psz_datadir = config_GetUserDataDir();
char *psz_uri = NULL;
input_item_t *p_input;
struct stat p_stat;
/* checks if media library file is present */
if( utf8_stat( psz_uri , &p_stat ) )
- {
- free( psz_uri );
- return VLC_EGENERIC;
- }
+ 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 = NULL;
goto error;
}
+ free( psz_datadir );
+ psz_datadir = NULL;
const char *const psz_option = "meta-file";
/* that option has to be cleaned in input_item_subitem_added() */
error:
free( psz_uri );
+ free( psz_datadir );
return VLC_ENOMEM;
}
int playlist_MLDump( playlist_t *p_playlist )
{
- char *psz_datadir = libvlc_priv (p_playlist->p_libvlc)->psz_datadir;
+ char *psz_datadir = config_GetUserDataDir();
if( !config_GetInt( p_playlist, "media-library") ) return VLC_SUCCESS;
if( !psz_datadir ) /* XXX: This should never happen */
{
char psz_dirname[ strlen( psz_datadir ) + sizeof( DIR_SEP "ml.xspf")];
strcpy( psz_dirname, psz_datadir );
+ free( psz_datadir );
if( config_CreateDir( (vlc_object_t *)p_playlist, psz_dirname ) )
{
return VLC_EGENERIC;
#else
/* XXX: This saves in the data directory. Shouldn't we try saving
* to psz_homedir/Desktop or something nicer ? */
- if( !val.psz_string && libvlc_priv (p_vout->p_libvlc)->psz_datadir )
+ char *psz_datadir = config_GetUserDataDir();
+ if( !val.psz_string && psz_datadir )
{
- if( asprintf( &val.psz_string, "%s",
- libvlc_priv (p_vout->p_libvlc)->psz_datadir ) == -1 )
+ if( asprintf( &val.psz_string, "%s", psz_datadir ) == -1 )
val.psz_string = NULL;
}
+ free( psz_datadir );
#endif
if( !val.psz_string )