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

Remove config_GetUserDataDir()...

...and fix a memory leak in LUA
parent 09bd8efc
...@@ -216,13 +216,12 @@ VLC_EXPORT( void, __config_ResetAll, ( vlc_object_t * ) ); ...@@ -216,13 +216,12 @@ VLC_EXPORT( void, __config_ResetAll, ( vlc_object_t * ) );
VLC_EXPORT( module_config_t *, config_FindConfig,( vlc_object_t *, const char * ) LIBVLC_USED ); VLC_EXPORT( module_config_t *, config_FindConfig,( vlc_object_t *, const char * ) LIBVLC_USED );
VLC_EXPORT(const char *, config_GetDataDir, ( void ) LIBVLC_USED); VLC_EXPORT(const char *, config_GetDataDir, ( void ) LIBVLC_USED);
VLC_EXPORT(const char *, config_GetConfDir, ( void ) LIBVLC_USED); VLC_EXPORT(const char *, config_GetConfDir, ( void ) LIBVLC_USED);
VLC_EXPORT(char *, config_GetUserDataDir, ( void ) LIBVLC_USED);
typedef enum vlc_userdir { typedef enum vlc_userdir
/* User's home */ {
VLC_HOME_DIR, VLC_HOME_DIR, /* User's home */
/* VLC configuration directory */ VLC_CONFIG_DIR, /* VLC-specific configuration directory */
VLC_CONFIG_DIR, VLC_DATA_DIR, /* VLC-specific data directory */
} vlc_userdir_t; } vlc_userdir_t;
VLC_EXPORT(char *, config_GetUserDir, ( vlc_userdir_t ) LIBVLC_USED); VLC_EXPORT(char *, config_GetUserDir, ( vlc_userdir_t ) LIBVLC_USED);
......
...@@ -225,7 +225,7 @@ bool Win32Factory::init() ...@@ -225,7 +225,7 @@ bool Win32Factory::init()
} }
// Initialize the resource path // Initialize the resource path
char *datadir = config_GetUserDataDir(); char *datadir = config_GetUserDir( VLC_DATA_DIR );
m_resourcePath.push_back( (string)datadir + "\\skins" ); m_resourcePath.push_back( (string)datadir + "\\skins" );
free( datadir ); free( datadir );
m_resourcePath.push_back( (string)config_GetDataDir() + m_resourcePath.push_back( (string)config_GetDataDir() +
......
...@@ -75,7 +75,7 @@ bool X11Factory::init() ...@@ -75,7 +75,7 @@ bool X11Factory::init()
ConnectionNumber( pDisplay ) ); ConnectionNumber( pDisplay ) );
// Initialize the resource path // Initialize the resource path
char *datadir = config_GetUserDataDir(); char *datadir = config_GetUserDataDir( VLC_DATA_DIR );
m_resourcePath.push_back( (string)datadir + "/skins2" ); m_resourcePath.push_back( (string)datadir + "/skins2" );
free( datadir ); free( datadir );
m_resourcePath.push_back( (string)"share/skins2" ); m_resourcePath.push_back( (string)"share/skins2" );
......
...@@ -675,7 +675,7 @@ static int OpenClient (vlc_object_t *obj) ...@@ -675,7 +675,7 @@ static int OpenClient (vlc_object_t *obj)
goto error; goto error;
} }
char *userdir = config_GetUserDataDir (); char *userdir = config_GetDataDir ( VLC_DATA_DIR );
if (userdir != NULL) if (userdir != NULL)
{ {
char path[strlen (userdir) + sizeof ("/ssl/private")]; char path[strlen (userdir) + sizeof ("/ssl/private")];
......
...@@ -120,7 +120,9 @@ static int vlclua_datadir( lua_State *L ) ...@@ -120,7 +120,9 @@ static int vlclua_datadir( lua_State *L )
static int vlclua_userdatadir( lua_State *L ) static int vlclua_userdatadir( lua_State *L )
{ {
lua_pushstring( L, config_GetUserDataDir() ); char *dir = config_GetUserDir( VLC_DATA_DIR );
lua_pushstring( L, dir );
free( dir );
return 1; return 1;
} }
......
...@@ -108,7 +108,7 @@ static int file_compare( const char **a, const char **b ) ...@@ -108,7 +108,7 @@ static int file_compare( const char **a, const char **b )
int vlclua_dir_list( const char *luadirname, char **ppsz_dir_list ) int vlclua_dir_list( const char *luadirname, char **ppsz_dir_list )
{ {
int i = 0; int i = 0;
char *datadir = config_GetUserDataDir(); char *datadir = config_GetUserDir( VLC_DATA_DIR );
if( datadir == NULL ) if( datadir == NULL )
return VLC_ENOMEM; return VLC_ENOMEM;
......
...@@ -248,15 +248,6 @@ static char *config_GetAppDir (const char *xdg_name, const char *xdg_default) ...@@ -248,15 +248,6 @@ static char *config_GetAppDir (const char *xdg_name, const char *xdg_default)
return psz_dir; return psz_dir;
} }
/**
* Get the user's VLC data directory
* (used for stuff like the skins, custom lua modules, ...)
*/
char *config_GetUserDataDir( void )
{
return config_GetAppDir ("DATA", ".local/share");
}
/** /**
* Get the user's VLC cache directory * Get the user's VLC cache directory
* (used for stuff like the modules cache, the album art cache, ...) * (used for stuff like the modules cache, the album art cache, ...)
...@@ -284,6 +275,8 @@ char *config_GetUserDir (vlc_userdir_t type) ...@@ -284,6 +275,8 @@ char *config_GetUserDir (vlc_userdir_t type)
return config_GetHomeDir (); return config_GetHomeDir ();
case VLC_CONFIG_DIR: case VLC_CONFIG_DIR:
return config_GetAppDir ("CONFIG", ".config"); return config_GetAppDir ("CONFIG", ".config");
case VLC_DATA_DIR:
return config_GetAppDir ("DATA", ".local/share");
} }
assert (0); assert (0);
} }
...@@ -108,7 +108,7 @@ void ...@@ -108,7 +108,7 @@ void
libvlc_media_library_load( libvlc_media_library_t * p_mlib, libvlc_media_library_load( libvlc_media_library_t * p_mlib,
libvlc_exception_t * p_e ) libvlc_exception_t * p_e )
{ {
char *psz_datadir = config_GetUserDataDir(); char *psz_datadir = config_GetUserDir( VLC_DATA_DIR );
char * psz_uri; char * psz_uri;
if( !psz_datadir ) /* XXX: i doubt that this can ever happen */ if( !psz_datadir ) /* XXX: i doubt that this can ever happen */
......
...@@ -58,7 +58,6 @@ config_GetUserDir ...@@ -58,7 +58,6 @@ config_GetUserDir
__config_GetInt __config_GetInt
__config_GetPsz __config_GetPsz
__config_GetType __config_GetType
config_GetUserDataDir
__config_PutFloat __config_PutFloat
__config_PutInt __config_PutInt
__config_PutPsz __config_PutPsz
......
...@@ -125,7 +125,7 @@ int playlist_MLLoad( playlist_t *p_playlist ) ...@@ -125,7 +125,7 @@ int playlist_MLLoad( playlist_t *p_playlist )
if( !config_GetInt( p_playlist, "media-library") ) if( !config_GetInt( p_playlist, "media-library") )
return VLC_SUCCESS; return VLC_SUCCESS;
psz_datadir = config_GetUserDataDir(); psz_datadir = config_GetUserDir( VLC_DATA_DIR );
if( !psz_datadir ) /* XXX: This should never happen */ if( !psz_datadir ) /* XXX: This should never happen */
{ {
...@@ -208,7 +208,7 @@ int playlist_MLDump( playlist_t *p_playlist ) ...@@ -208,7 +208,7 @@ int playlist_MLDump( playlist_t *p_playlist )
if( !config_GetInt( p_playlist, "media-library") ) if( !config_GetInt( p_playlist, "media-library") )
return VLC_SUCCESS; return VLC_SUCCESS;
psz_datadir = config_GetUserDataDir(); psz_datadir = config_GetUserDir( VLC_DATA_DIR );
if( !psz_datadir ) /* XXX: This should never happen */ if( !psz_datadir ) /* XXX: This should never happen */
{ {
......
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