[vlc-devel] [PATCH] Fixes ##21595: fixed creation of cache directory if it does not exist

Remi Denis-Courmont remi at remlab.net
Sat Mar 9 19:58:34 CET 2019


Le 2019-03-09 16:01, Aakash Singh a écrit :
> https://trac.videolan.org/vlc/ticket/21595 provides the description of
> the issue.
> 
> The cache folder is created if it doesn't already exist. If it exists
> then vlc_mkdir() simply returns -1.

First, it's questionable if the function should create the directory, or 
if that's the caller's responsibility. But in any case, this patch won't 
work if the parent directory does not exist.




> 
> ---
>  modules/lua/libs/configuration.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/modules/lua/libs/configuration.c
> b/modules/lua/libs/configuration.c
> index 27de94c30d..1c55d6c7d8 100644
> --- a/modules/lua/libs/configuration.c
> +++ b/modules/lua/libs/configuration.c
> @@ -32,6 +32,7 @@
>  #endif
> 
>  #include <vlc_common.h>
> +#include <vlc_fs.h>
> 
>  #include "../vlc.h"
>  #include "../libs.h"
> @@ -136,6 +137,8 @@ static int vlclua_configdir( lua_State *L )
>  static int vlclua_cachedir( lua_State *L )
>  {
>      char *dir = config_GetUserDir( VLC_CACHE_DIR );
> +    /* create a cache folder if it doesn't already exist */
> +    vlc_mkdir( dir, 0700 );
>      lua_pushstring( L, dir );
>      free( dir );
>      return 1;
> --
> 2.19.1
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel

-- 
Rémi Denis-Courmont


More information about the vlc-devel mailing list