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

Use config_GetCacheDir internally

parent d9d67e17
...@@ -239,15 +239,15 @@ static void __ArtCacheGetDirPath( vlc_object_t *p_obj, ...@@ -239,15 +239,15 @@ static void __ArtCacheGetDirPath( vlc_object_t *p_obj,
const char *psz_title, const char *psz_title,
const char *psz_artist, const char *psz_album ) const char *psz_artist, const char *psz_album )
{ {
char *psz_cachedir = config_GetCacheDir();
if( !EMPTY_STR(psz_artist) && !EMPTY_STR(psz_album) ) if( !EMPTY_STR(psz_artist) && !EMPTY_STR(psz_album) )
{ {
char * psz_album_sanitized = ArtCacheGetSanitizedFileName( psz_album ); char * psz_album_sanitized = ArtCacheGetSanitizedFileName( psz_album );
char * psz_artist_sanitized = ArtCacheGetSanitizedFileName( psz_artist ); char * psz_artist_sanitized = ArtCacheGetSanitizedFileName( psz_artist );
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",
libvlc_priv (p_obj->p_libvlc)->psz_cachedir, 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,10 +256,10 @@ static void __ArtCacheGetDirPath( vlc_object_t *p_obj, ...@@ -256,10 +256,10 @@ 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",
libvlc_priv (p_obj->p_libvlc)->psz_cachedir, psz_cachedir, psz_title_sanitized );
psz_title_sanitized );
free( psz_title_sanitized ); free( psz_title_sanitized );
} }
free( psz_cachedir );
} }
......
...@@ -298,7 +298,6 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc, ...@@ -298,7 +298,6 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
p_libvlc->psz_homedir = config_GetHomeDir(); p_libvlc->psz_homedir = config_GetHomeDir();
priv->psz_configdir = config_GetUserConfDir(); priv->psz_configdir = config_GetUserConfDir();
priv->psz_datadir = config_GetUserDataDir(); priv->psz_datadir = config_GetUserDataDir();
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 */
...@@ -1064,7 +1063,6 @@ int libvlc_InternalDestroy( libvlc_int_t *p_libvlc, bool b_release ) ...@@ -1064,7 +1063,6 @@ int libvlc_InternalDestroy( libvlc_int_t *p_libvlc, bool b_release )
FREENULL( p_libvlc->psz_homedir ); FREENULL( p_libvlc->psz_homedir );
free( priv->psz_configdir ); free( priv->psz_configdir );
free( priv->psz_datadir ); free( priv->psz_datadir );
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 );
......
...@@ -213,7 +213,6 @@ typedef struct libvlc_priv_t ...@@ -213,7 +213,6 @@ typedef struct libvlc_priv_t
char * psz_configfile; ///< location of config file char * psz_configfile; ///< location of config file
char *psz_configdir; ///< user configuration directory char *psz_configdir; ///< user configuration directory
char *psz_datadir; ///< user data 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 */
......
...@@ -96,7 +96,7 @@ static char * CacheName ( void ); ...@@ -96,7 +96,7 @@ static char * CacheName ( void );
*****************************************************************************/ *****************************************************************************/
void CacheLoad( vlc_object_t *p_this ) void CacheLoad( vlc_object_t *p_this )
{ {
char *psz_filename, *psz_cachedir; char *psz_filename, *psz_cachedir = config_GetCacheDir();
FILE *file; FILE *file;
int i, j, i_size, i_read; int i, j, i_size, i_read;
char p_cachestring[sizeof("cache " COPYRIGHT_MESSAGE)]; char p_cachestring[sizeof("cache " COPYRIGHT_MESSAGE)];
...@@ -106,7 +106,6 @@ void CacheLoad( vlc_object_t *p_this ) ...@@ -106,7 +106,6 @@ 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 = 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" );
...@@ -115,9 +114,9 @@ void CacheLoad( vlc_object_t *p_this ) ...@@ -115,9 +114,9 @@ void CacheLoad( vlc_object_t *p_this )
i_size = asprintf( &psz_filename, "%s"DIR_SEP"%s", i_size = asprintf( &psz_filename, "%s"DIR_SEP"%s",
psz_cachedir, CacheName() ); psz_cachedir, CacheName() );
free( psz_cachedir );
if( i_size <= 0 ) if( i_size <= 0 )
{ {
msg_Err( p_this, "out of memory" );
return; return;
} }
...@@ -454,14 +453,13 @@ void CacheSave( vlc_object_t *p_this ) ...@@ -454,14 +453,13 @@ void CacheSave( vlc_object_t *p_this )
"# For information about cache directory tags, see:\r\n" "# For information about cache directory tags, see:\r\n"
"# http://www.brynosaurus.com/cachedir/\r\n"; "# http://www.brynosaurus.com/cachedir/\r\n";
char *psz_cachedir; char *psz_cachedir = config_GetCacheDir();
FILE *file; FILE *file;
int i, j, i_cache; int i, j, i_cache;
module_cache_t **pp_cache; module_cache_t **pp_cache;
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 = 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" );
...@@ -483,6 +481,7 @@ void CacheSave( vlc_object_t *p_this ) ...@@ -483,6 +481,7 @@ void CacheSave( vlc_object_t *p_this )
snprintf( psz_filename, sizeof( psz_filename ), snprintf( psz_filename, sizeof( psz_filename ),
"%s"DIR_SEP"%s", psz_cachedir, CacheName() ); "%s"DIR_SEP"%s", psz_cachedir, CacheName() );
free( psz_cachedir );
msg_Dbg( p_this, "writing plugins cache %s", psz_filename ); msg_Dbg( p_this, "writing plugins cache %s", psz_filename );
file = utf8_fopen( psz_filename, "wb" ); file = utf8_fopen( psz_filename, "wb" );
......
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