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

Use config_GetUserDataDir() internally

parent 0038469d
......@@ -89,8 +89,7 @@ void
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 */
......@@ -102,9 +101,11 @@ libvlc_media_library_load( libvlc_media_library_t * p_mlib,
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 );
......
......@@ -296,7 +296,6 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
/* 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 */
......@@ -1060,7 +1059,6 @@ int libvlc_InternalDestroy( libvlc_int_t *p_libvlc, bool b_release )
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 );
......
......@@ -211,7 +211,6 @@ typedef struct libvlc_priv_t
/* 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 */
......
......@@ -108,7 +108,7 @@ static void input_item_subitem_added( const vlc_event_t * p_event,
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;
......@@ -127,18 +127,18 @@ int playlist_MLLoad( playlist_t *p_playlist )
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() */
......@@ -183,12 +183,13 @@ int playlist_MLLoad( playlist_t *p_playlist )
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 */
{
......@@ -198,6 +199,7 @@ int playlist_MLDump( playlist_t *p_playlist )
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;
......
......@@ -637,12 +637,13 @@ int vout_Snapshot( vout_thread_t *p_vout, picture_t *p_pic )
#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 )
......
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