[vlc-devel] [PATCH] Fixes ##21595: fixed creation of cache directory if it does not exist
Aakash Singh
17aakashsingh1999 at gmail.com
Sun Mar 10 06:39:11 CET 2019
Hey Remi
I dont't think a cache directory which does not exist is of much use. So
whenever some lua extension asks for the cache directory it is made sure
that it already exists. The problem regarding parent directory not
existing, I went through dirs.c for different operating systems and they
all return paths with cache directory being child directory of some
directory created by the system by default. So, there is a high chance
vlc_mkdir() will not fail here. Still if you feel that it can fail, i can
write a recursive implementation to check the path and create directories
as required.
On Sun, Mar 10, 2019 at 12:28 AM Remi Denis-Courmont <remi at remlab.net>
wrote:
> 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
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20190310/f4dd8c6a/attachment.html>
More information about the vlc-devel
mailing list