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 );
}
}
#endif
- else if( p_stream != NULL )
- {
- libvlc_priv (p_obj->p_libvlc)->psz_configfile = psz_filename;
- }
-
return p_stream;
}
}
+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.
*****************************************************************************
/* 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" );
- vlc_mutex_unlock( &priv->config_lock );
- return -1;
- }
-
- config_CreateDir( p_this, psz_configdir );
- free( psz_configdir );
+ msg_Err( p_this, "no configuration directory" );
+ vlc_mutex_unlock( &priv->config_lock );
+ return -1;
}
file = config_OpenConfigFile( p_this, "rt" );
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;
if( b_exit )
{
- free( priv->psz_configfile );
module_EndBank( p_libvlc, false );
return i_ret;
}
if( b_exit )
{
- free( priv->psz_configfile );
module_EndBank( p_libvlc, true );
return i_ret;
}
"that they are valid.\n" );
PauseConsole();
#endif
- free( priv->psz_configfile );
module_EndBank( p_libvlc, true );
return VLC_EGENERIC;
}
module_unneed( p_libvlc, priv->p_memcpy_module );
}
module_EndBank( p_libvlc, true );
- free( priv->psz_configfile );
return VLC_EGENERIC;
}
playlist_Activate( p_playlist );
/* 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 );