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

Hide psz_(cache|config|data)dir

parent 9b6ca602
...@@ -39,9 +39,6 @@ struct libvlc_int_t ...@@ -39,9 +39,6 @@ struct libvlc_int_t
/* Global properties */ /* Global properties */
char * psz_homedir; ///< user's home directory char * psz_homedir; ///< user's home directory
char * psz_configdir; ///< user's configuration directory
char * psz_datadir; ///< user's data directory
char * psz_cachedir; ///< user's cache directory
playlist_t *p_playlist; ///< playlist object playlist_t *p_playlist; ///< playlist object
......
...@@ -86,14 +86,13 @@ static FILE *config_OpenConfigFile( vlc_object_t *p_obj, const char *mode ) ...@@ -86,14 +86,13 @@ static FILE *config_OpenConfigFile( vlc_object_t *p_obj, const char *mode )
FILE *p_readme = utf8_fopen( psz_readme, "wt" ); FILE *p_readme = utf8_fopen( psz_readme, "wt" );
if( p_readme ) if( p_readme )
{ {
fputs( "The VLC media player configuration folder has " fprintf( p_readme, "The VLC media player "
"moved to comply with the XDG Base " "configuration folder has moved to comply\n"
"Directory Specification version 0.6. Your " "with the XDG Base Directory Specification "
"configuration has been copied to the new " "version 0.6. Your\nconfiguration has been "
"location (", p_readme ); "copied to the new location:\n%s\nYou can "
fputs( p_obj->p_libvlc->psz_configdir, p_readme ); "delete this directory and all its contents.",
fputs( "). You can delete this directory and " libvlc_priv(p_obj->p_libvlc)->psz_configdir);
"all its contents.", p_readme );
fclose( p_readme ); fclose( p_readme );
} }
free( psz_readme ); free( psz_readme );
...@@ -402,7 +401,8 @@ static int SaveConfigFile( vlc_object_t *p_this, const char *psz_module_name, ...@@ -402,7 +401,8 @@ static int SaveConfigFile( vlc_object_t *p_this, const char *psz_module_name,
if( libvlc_priv (p_this->p_libvlc)->psz_configfile == NULL ) if( libvlc_priv (p_this->p_libvlc)->psz_configfile == NULL )
{ {
const char *psz_configdir = p_this->p_libvlc->psz_configdir; const char *psz_configdir =
libvlc_priv(p_this->p_libvlc)->psz_configdir;
if( !psz_configdir ) /* XXX: This should never happen */ if( !psz_configdir ) /* XXX: This should never happen */
{ {
msg_Err( p_this, "no configuration directory defined" ); msg_Err( p_this, "no configuration directory defined" );
...@@ -672,7 +672,7 @@ char *config_GetConfigFile( libvlc_int_t *p_libvlc ) ...@@ -672,7 +672,7 @@ char *config_GetConfigFile( libvlc_int_t *p_libvlc )
{ {
char *psz_configfile; char *psz_configfile;
if( asprintf( &psz_configfile, "%s" DIR_SEP CONFIG_FILE, if( asprintf( &psz_configfile, "%s" DIR_SEP CONFIG_FILE,
p_libvlc->psz_configdir ) == -1 ) libvlc_priv (p_libvlc)->psz_configdir ) == -1 )
return NULL; return NULL;
return psz_configfile; return psz_configfile;
} }
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
*****************************************************************************/ *****************************************************************************/
#include "libvlc_internal.h" #include "libvlc_internal.h"
#include <vlc/libvlc.h> #include <vlc/libvlc.h>
#include "libvlc.h"
#include "vlc_arrays.h" #include "vlc_arrays.h"
/* /*
...@@ -88,7 +89,8 @@ void ...@@ -88,7 +89,8 @@ 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 )
{ {
const char *psz_datadir = p_mlib->p_libvlc_instance->p_libvlc_int->psz_datadir; const char *psz_datadir =
libvlc_priv (p_mlib->p_libvlc_instance->p_libvlc_int)->psz_datadir;
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 */
......
...@@ -246,7 +246,7 @@ static void __ArtCacheGetDirPath( vlc_object_t *p_obj, ...@@ -246,7 +246,7 @@ static void __ArtCacheGetDirPath( vlc_object_t *p_obj,
snprintf( psz_dir, PATH_MAX, "%s" DIR_SEP snprintf( psz_dir, PATH_MAX, "%s" DIR_SEP
"art" DIR_SEP "artistalbum" DIR_SEP "%s" DIR_SEP "%s", "art" DIR_SEP "artistalbum" DIR_SEP "%s" DIR_SEP "%s",
p_obj->p_libvlc->psz_cachedir, libvlc_priv (p_obj->p_libvlc)->psz_cachedir,
psz_artist_sanitized, psz_album_sanitized ); psz_artist_sanitized, psz_album_sanitized );
free( psz_album_sanitized ); free( psz_album_sanitized );
free( psz_artist_sanitized ); free( psz_artist_sanitized );
...@@ -256,7 +256,7 @@ static void __ArtCacheGetDirPath( vlc_object_t *p_obj, ...@@ -256,7 +256,7 @@ static void __ArtCacheGetDirPath( vlc_object_t *p_obj,
char * psz_title_sanitized = ArtCacheGetSanitizedFileName( psz_title ); char * psz_title_sanitized = ArtCacheGetSanitizedFileName( psz_title );
snprintf( psz_dir, PATH_MAX, "%s" DIR_SEP snprintf( psz_dir, PATH_MAX, "%s" DIR_SEP
"art" DIR_SEP "title" DIR_SEP "%s", "art" DIR_SEP "title" DIR_SEP "%s",
p_obj->p_libvlc->psz_cachedir, libvlc_priv (p_obj->p_libvlc)->psz_cachedir,
psz_title_sanitized ); psz_title_sanitized );
free( psz_title_sanitized ); free( psz_title_sanitized );
} }
......
...@@ -296,9 +296,9 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc, ...@@ -296,9 +296,9 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
/* Set the config file stuff */ /* Set the config file stuff */
p_libvlc->psz_homedir = config_GetHomeDir(); p_libvlc->psz_homedir = config_GetHomeDir();
p_libvlc->psz_configdir = config_GetConfigDir(); priv->psz_configdir = config_GetConfigDir();
p_libvlc->psz_datadir = config_GetUserDataDir(); priv->psz_datadir = config_GetUserDataDir();
p_libvlc->psz_cachedir = config_GetCacheDir(); priv->psz_cachedir = config_GetCacheDir();
priv->psz_configfile = config_GetCustomConfigFile( p_libvlc ); priv->psz_configfile = config_GetCustomConfigFile( p_libvlc );
/* Check for plugins cache options */ /* Check for plugins cache options */
...@@ -1062,9 +1062,9 @@ int libvlc_InternalDestroy( libvlc_int_t *p_libvlc, bool b_release ) ...@@ -1062,9 +1062,9 @@ int libvlc_InternalDestroy( libvlc_int_t *p_libvlc, bool b_release )
module_EndBank( p_libvlc ); module_EndBank( p_libvlc );
FREENULL( p_libvlc->psz_homedir ); FREENULL( p_libvlc->psz_homedir );
FREENULL( p_libvlc->psz_configdir ); free( priv->psz_configdir );
FREENULL( p_libvlc->psz_datadir ); free( priv->psz_datadir );
FREENULL( p_libvlc->psz_cachedir ); free( priv->psz_cachedir );
FREENULL( priv->psz_configfile ); FREENULL( priv->psz_configfile );
var_DelCallback( p_libvlc, "key-pressed", vlc_key_to_action, var_DelCallback( p_libvlc, "key-pressed", vlc_key_to_action,
p_libvlc->p_hotkeys ); p_libvlc->p_hotkeys );
......
...@@ -211,6 +211,9 @@ typedef struct libvlc_priv_t ...@@ -211,6 +211,9 @@ typedef struct libvlc_priv_t
/* Configuration */ /* Configuration */
vlc_mutex_t config_lock; ///< config file lock vlc_mutex_t config_lock; ///< config file lock
char * psz_configfile; ///< location of config file char * psz_configfile; ///< location of config file
char *psz_configdir; ///< user configuration directory
char *psz_datadir; ///< user data directory
char *psz_cachedir; ///< user cache directory
/* There is no real reason to keep a list of items, but not to break /* There is no real reason to keep a list of items, but not to break
* everything, let's keep it */ * everything, let's keep it */
......
...@@ -106,7 +106,7 @@ void CacheLoad( vlc_object_t *p_this ) ...@@ -106,7 +106,7 @@ void CacheLoad( vlc_object_t *p_this )
int32_t i_file_size, i_marker; int32_t i_file_size, i_marker;
libvlc_global_data_t *p_libvlc_global = vlc_global(); libvlc_global_data_t *p_libvlc_global = vlc_global();
psz_cachedir = p_this->p_libvlc->psz_cachedir; psz_cachedir = libvlc_priv(p_this->p_libvlc)->psz_cachedir;
if( !psz_cachedir ) /* XXX: this should never happen */ if( !psz_cachedir ) /* XXX: this should never happen */
{ {
msg_Err( p_this, "Unable to get cache directory" ); msg_Err( p_this, "Unable to get cache directory" );
...@@ -461,7 +461,7 @@ void CacheSave( vlc_object_t *p_this ) ...@@ -461,7 +461,7 @@ void CacheSave( vlc_object_t *p_this )
uint32_t i_file_size = 0; uint32_t i_file_size = 0;
libvlc_global_data_t *p_libvlc_global = vlc_global(); libvlc_global_data_t *p_libvlc_global = vlc_global();
psz_cachedir = p_this->p_libvlc->psz_cachedir; psz_cachedir = libvlc_priv(p_this->p_libvlc)->psz_cachedir;
if( !psz_cachedir ) /* XXX: this should never happen */ if( !psz_cachedir ) /* XXX: this should never happen */
{ {
msg_Err( p_this, "unable to get cache directory" ); msg_Err( p_this, "unable to get cache directory" );
......
...@@ -108,7 +108,7 @@ static void input_item_subitem_added( const vlc_event_t * p_event, ...@@ -108,7 +108,7 @@ static void input_item_subitem_added( const vlc_event_t * p_event,
int playlist_MLLoad( playlist_t *p_playlist ) int playlist_MLLoad( playlist_t *p_playlist )
{ {
const char *psz_datadir = p_playlist->p_libvlc->psz_datadir; const char *psz_datadir = libvlc_priv (p_playlist->p_libvlc)->psz_datadir;
char *psz_uri = NULL; char *psz_uri = NULL;
input_item_t *p_input; input_item_t *p_input;
...@@ -188,7 +188,7 @@ error: ...@@ -188,7 +188,7 @@ error:
int playlist_MLDump( playlist_t *p_playlist ) int playlist_MLDump( playlist_t *p_playlist )
{ {
char *psz_datadir = p_playlist->p_libvlc->psz_datadir; char *psz_datadir = libvlc_priv (p_playlist->p_libvlc)->psz_datadir;
if( !config_GetInt( p_playlist, "media-library") ) return VLC_SUCCESS; if( !config_GetInt( p_playlist, "media-library") ) return VLC_SUCCESS;
if( !psz_datadir ) /* XXX: This should never happen */ if( !psz_datadir ) /* XXX: This should never happen */
{ {
......
...@@ -637,10 +637,10 @@ int vout_Snapshot( vout_thread_t *p_vout, picture_t *p_pic ) ...@@ -637,10 +637,10 @@ int vout_Snapshot( vout_thread_t *p_vout, picture_t *p_pic )
#else #else
/* XXX: This saves in the data directory. Shouldn't we try saving /* XXX: This saves in the data directory. Shouldn't we try saving
* to psz_homedir/Desktop or something nicer ? */ * to psz_homedir/Desktop or something nicer ? */
if( !val.psz_string && p_vout->p_libvlc->psz_datadir ) if( !val.psz_string && libvlc_priv (p_vout->p_libvlc)->psz_datadir )
{ {
if( asprintf( &val.psz_string, "%s", if( asprintf( &val.psz_string, "%s",
p_vout->p_libvlc->psz_datadir ) == -1 ) libvlc_priv (p_vout->p_libvlc)->psz_datadir ) == -1 )
val.psz_string = NULL; val.psz_string = NULL;
} }
#endif #endif
......
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