]> git.sesse.net Git - vlc/commitdiff
Use config_GetCacheDir internally
authorRémi Denis-Courmont <rem@videolan.org>
Tue, 6 May 2008 19:56:57 +0000 (22:56 +0300)
committerRémi Denis-Courmont <rem@videolan.org>
Tue, 6 May 2008 20:15:51 +0000 (23:15 +0300)
src/input/meta.c
src/libvlc-common.c
src/libvlc.h
src/modules/cache.c

index 7abd04fd9f6c0e57bce060a678a7a9ce41f25e05..0447fadf6f97dc5b08634ec8c43b32ef1ecbce12 100644 (file)
@@ -239,15 +239,15 @@ static void __ArtCacheGetDirPath( vlc_object_t *p_obj,
                                   const char *psz_title,
                                   const char *psz_artist, const char *psz_album )
 {
+   char *psz_cachedir = config_GetCacheDir();
+
     if( !EMPTY_STR(psz_artist) && !EMPTY_STR(psz_album) )
     {
         char * psz_album_sanitized = ArtCacheGetSanitizedFileName( psz_album );
         char * psz_artist_sanitized = ArtCacheGetSanitizedFileName( psz_artist );
-
         snprintf( psz_dir, PATH_MAX, "%s" DIR_SEP
                   "art" DIR_SEP "artistalbum" DIR_SEP "%s" DIR_SEP "%s",
-                      libvlc_priv (p_obj->p_libvlc)->psz_cachedir,
-                      psz_artist_sanitized, psz_album_sanitized );
+                  psz_cachedir, psz_artist_sanitized, psz_album_sanitized );
         free( psz_album_sanitized );
         free( psz_artist_sanitized );
     }
@@ -256,10 +256,10 @@ static void __ArtCacheGetDirPath( vlc_object_t *p_obj,
         char * psz_title_sanitized = ArtCacheGetSanitizedFileName( psz_title );
         snprintf( psz_dir, PATH_MAX, "%s" DIR_SEP
                   "art" DIR_SEP "title" DIR_SEP "%s",
-                  libvlc_priv (p_obj->p_libvlc)->psz_cachedir,
-                  psz_title_sanitized );
+                  psz_cachedir, psz_title_sanitized );
         free( psz_title_sanitized );
     }
+    free( psz_cachedir );
 }
 
 
index d7bea3b9ce05ee316b85a1ef8efd2f4ba76ea695..7e082314cceb528749a2cc0298d06ab49909800d 100644 (file)
@@ -298,7 +298,6 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
     p_libvlc->psz_homedir    = config_GetHomeDir();
     priv->psz_configdir  = config_GetUserConfDir();
     priv->psz_datadir    = config_GetUserDataDir();
-    priv->psz_cachedir   = config_GetCacheDir();
     priv->psz_configfile = config_GetCustomConfigFile( p_libvlc );
 
     /* Check for plugins cache options */
@@ -1064,7 +1063,6 @@ int libvlc_InternalDestroy( libvlc_int_t *p_libvlc, bool b_release )
     FREENULL( p_libvlc->psz_homedir );
     free( priv->psz_configdir );
     free( priv->psz_datadir );
-    free( priv->psz_cachedir );
     FREENULL( priv->psz_configfile );
     var_DelCallback( p_libvlc, "key-pressed", vlc_key_to_action,
                      p_libvlc->p_hotkeys );
index a6ba7be74365b2982e196372593e0ace3b4657c5..f2466d52a4d187ac864d9707de3d6288858da337 100644 (file)
@@ -213,7 +213,6 @@ typedef struct libvlc_priv_t
     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
      * everything, let's keep it */
index 67987d360ca5dc8256d4695d9188a4899e5a1b3d..e15e890ff14476a085624995d535a9f022e42605 100644 (file)
@@ -96,7 +96,7 @@ static char * CacheName        ( void );
  *****************************************************************************/
 void CacheLoad( vlc_object_t *p_this )
 {
-    char *psz_filename, *psz_cachedir;
+    char *psz_filename, *psz_cachedir = config_GetCacheDir();
     FILE *file;
     int i, j, i_size, i_read;
     char p_cachestring[sizeof("cache " COPYRIGHT_MESSAGE)];
@@ -106,7 +106,6 @@ void CacheLoad( vlc_object_t *p_this )
     int32_t i_file_size, i_marker;
     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 */
     {
         msg_Err( p_this, "Unable to get cache directory" );
@@ -115,9 +114,9 @@ void CacheLoad( vlc_object_t *p_this )
 
     i_size = asprintf( &psz_filename, "%s"DIR_SEP"%s",
                        psz_cachedir, CacheName() );
+    free( psz_cachedir );
     if( i_size <= 0 )
     {
-        msg_Err( p_this, "out of memory" );
         return;
     }
 
@@ -454,14 +453,13 @@ void CacheSave( vlc_object_t *p_this )
         "# For information about cache directory tags, see:\r\n"
         "#   http://www.brynosaurus.com/cachedir/\r\n";
 
-    char *psz_cachedir;
+    char *psz_cachedir = config_GetCacheDir();
     FILE *file;
     int i, j, i_cache;
     module_cache_t **pp_cache;
     uint32_t i_file_size = 0;
     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 */
     {
         msg_Err( p_this, "unable to get cache directory" );
@@ -483,6 +481,7 @@ void CacheSave( vlc_object_t *p_this )
 
     snprintf( psz_filename, sizeof( psz_filename ),
               "%s"DIR_SEP"%s", psz_cachedir, CacheName() );
+    free( psz_cachedir );
     msg_Dbg( p_this, "writing plugins cache %s", psz_filename );
 
     file = utf8_fopen( psz_filename, "wb" );