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

Make config_GetHomeDir return a const string too

parent b152c831
......@@ -37,7 +37,7 @@ struct libvlc_int_t
VLC_COMMON_MEMBERS
/* Global properties */
char * psz_homedir; ///< user's home directory
const char * psz_homedir; ///< user's home directory
global_stats_t *p_stats; ///< Global statistics
......
......@@ -43,7 +43,7 @@ void config_UnsetCallbacks( module_config_t *, size_t );
#define config_LoadConfigFile(a,b) __config_LoadConfigFile(VLC_OBJECT(a),b)
int __config_LoadCmdLine ( vlc_object_t *, int *, const char *[], bool );
char *config_GetHomeDir ( void );
const char *config_GetHomeDir ( void );
char *config_GetCustomConfigFile( libvlc_int_t * );
int __config_LoadConfigFile( vlc_object_t *, const char * );
......
......@@ -92,6 +92,7 @@ const char *config_GetConfDir( void )
static const char *GetDir( bool b_appdata )
{
/* FIXME: a full memory page here - quite a waste... */
static char homedir[PATH_MAX] = "";
#if defined (WIN32)
......@@ -153,43 +154,40 @@ static const char *GetDir( bool b_appdata )
/**
* Get the user's home directory
*/
char *config_GetHomeDir( void )
const char *config_GetHomeDir( void )
{
return strdup (GetDir( false ));
return GetDir (false);
}
static char *config_GetFooDir (const char *xdg_name, const char *xdg_default)
{
char *psz_dir;
#if defined(WIN32) || defined(__APPLE__) || defined(SYS_BEOS)
char *psz_parent = strdup (GetDir (true));
const char *psz_parent = GetDir (true);
if( asprintf( &psz_dir, "%s" DIR_SEP CONFIG_DIR, psz_parent ) == -1 )
psz_dir = NULL;
free (psz_parent);
(void)xdg_name; (void)xdg_default;
#else
char var[sizeof ("XDG__HOME") + strlen (xdg_name)];
/* XDG Base Directory Specification - Version 0.6 */
snprintf (var, sizeof (var), "XDG_%s_HOME", xdg_name);
char *psz_home = getenv( var );
psz_home = psz_home ? FromLocaleDup( psz_home ) : NULL;
const char *psz_home = getenv (var);
psz_home = psz_home ? FromLocale (psz_home) : NULL;
if( psz_home )
{
if( asprintf( &psz_dir, "%s/vlc", psz_home ) == -1 )
psz_dir = NULL;
goto out;
LocaleFree (psz_home);
return psz_dir;
}
/* Try HOME, then fallback to non-XDG dirs */
psz_home = config_GetHomeDir();
if( asprintf( &psz_dir, "%s/%s/vlc", psz_home, xdg_default ) == -1 )
psz_dir = NULL;
out:
free (psz_home);
#endif
return psz_dir;
}
......
......@@ -1065,7 +1065,6 @@ int libvlc_InternalDestroy( libvlc_int_t *p_libvlc, bool b_release )
/* Free module bank. It is refcounted, so we call this each time */
module_EndBank( p_libvlc );
FREENULL( p_libvlc->psz_homedir );
FREENULL( priv->psz_configfile );
var_DelCallback( p_libvlc, "key-pressed", vlc_key_to_action,
p_libvlc->p_hotkeys );
......
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