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

No need to keep the config file around all the time

parent 0c88710e
......@@ -65,13 +65,12 @@ static char *config_GetConfigFile( void )
static FILE *config_OpenConfigFile( vlc_object_t *p_obj, const char *mode )
{
char *psz_filename = libvlc_priv (p_obj->p_libvlc)->psz_configfile;
char *psz_filename;
FILE *p_stream;
psz_filename = config_GetCustomConfigFile( p_obj->p_libvlc );
if( !psz_filename )
{
psz_filename = config_GetConfigFile();
}
msg_Dbg( p_obj, "opening config file (%s)", psz_filename );
......@@ -121,11 +120,6 @@ static FILE *config_OpenConfigFile( vlc_object_t *p_obj, const char *mode )
}
}
#endif
else if( p_stream != NULL )
{
libvlc_priv (p_obj->p_libvlc)->psz_configfile = psz_filename;
}
return p_stream;
}
......@@ -391,6 +385,17 @@ config_Write (FILE *file, const char *type, const char *desc,
}
static int config_PrepareDir (vlc_object_t *obj)
{
char *psz_configdir = config_GetUserConfDir ();
if (psz_configdir == NULL) /* XXX: This should never happen */
return -1;
int ret = config_CreateDir (obj, psz_configdir);
free (psz_configdir);
return ret;
}
/*****************************************************************************
* config_SaveConfigFile: Save a module's config options.
*****************************************************************************
......@@ -425,20 +430,13 @@ static int SaveConfigFile( vlc_object_t *p_this, const char *psz_module_name,
/* Acquire config file lock */
vlc_mutex_lock( &priv->config_lock );
if( libvlc_priv (p_this->p_libvlc)->psz_configfile == NULL )
if( config_PrepareDir( p_this ) )
{
char *psz_configdir = config_GetUserConfDir();
if( !psz_configdir ) /* XXX: This should never happen */
{
msg_Err( p_this, "no configuration directory defined" );
msg_Err( p_this, "no configuration directory" );
vlc_mutex_unlock( &priv->config_lock );
return -1;
}
config_CreateDir( p_this, psz_configdir );
free( psz_configdir );
}
file = config_OpenConfigFile( p_this, "rt" );
if( file != NULL )
{
......
......@@ -358,9 +358,6 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
i_ret = VLC_EEXITSUCCESS;
}
/* Set the config file stuff */
priv->psz_configfile = config_GetCustomConfigFile( p_libvlc );
/* Check for plugins cache options */
bool b_cache_delete = config_GetInt( p_libvlc, "reset-plugins-cache" ) > 0;
......@@ -431,7 +428,6 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
if( b_exit )
{
free( priv->psz_configfile );
module_EndBank( p_libvlc, false );
return i_ret;
}
......@@ -543,7 +539,6 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
if( b_exit )
{
free( priv->psz_configfile );
module_EndBank( p_libvlc, true );
return i_ret;
}
......@@ -571,7 +566,6 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
"that they are valid.\n" );
PauseConsole();
#endif
free( priv->psz_configfile );
module_EndBank( p_libvlc, true );
return VLC_EGENERIC;
}
......@@ -831,7 +825,6 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
module_unneed( p_libvlc, priv->p_memcpy_module );
}
module_EndBank( p_libvlc, true );
free( priv->psz_configfile );
return VLC_EGENERIC;
}
playlist_Activate( p_playlist );
......@@ -1107,7 +1100,6 @@ void libvlc_InternalCleanup( libvlc_int_t *p_libvlc )
/* Free module bank. It is refcounted, so we call this each time */
module_EndBank( p_libvlc, true );
FREENULL( priv->psz_configfile );
var_DelCallback( p_libvlc, "key-pressed", vlc_key_to_action,
(void *)p_libvlc->p_hotkeys );
free( (void *)p_libvlc->p_hotkeys );
......
......@@ -203,7 +203,6 @@ typedef struct libvlc_priv_t
/* Configuration */
vlc_mutex_t config_lock; ///< config file lock
char * psz_configfile; ///< location of config file
int i_last_input_id ; ///< Last id of input item
......
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