Re: [libdvdcss-devel] [PATCH 2/4] libdvdcss: Create cache directory before cache directory tag.

Jean-Baptiste Kempf <[email protected]>
Newsgroups gmane.comp.video.videolan.libdvdcss,gmane.comp.video.videolan.libdvdcss.devel
Message-ID <[email protected]>
LGTM. I hope it's enough tested

On 01 Nov, Diego Biurrun wrote :
> Otherwise creating the tag would fail on first invocation of libdvdcss and
> the tag would only be created upon the second invocation.
> ---
>  src/libdvdcss.c | 22 ++++++++++------------
>  1 file changed, 10 insertions(+), 12 deletions(-)
> 
> diff --git a/src/libdvdcss.c b/src/libdvdcss.c
> index af7857e..31df8d7 100644
> --- a/src/libdvdcss.c
> +++ b/src/libdvdcss.c
> @@ -370,6 +370,13 @@ LIBDVDCSS_EXPORT dvdcss_t dvdcss_open ( const char *psz_target )
>          char psz_tagfile[PATH_MAX + 1 + 12 + 1];
>          int i_fd;
>  
> +        i_ret = mkdir( psz_cache, 0755 );
> +        if( i_ret < 0 && errno != EEXIST )
> +        {
> +            print_error( dvdcss, "failed creating cache directory" );
> +            goto nocache;
> +        }
> +
>          sprintf( psz_tagfile, "%s/CACHEDIR.TAG", psz_cache );
>          i_fd = open( psz_tagfile, O_RDWR|O_CREAT, 0644 );
>          if( i_fd >= 0 )
> @@ -483,18 +490,9 @@ LIBDVDCSS_EXPORT dvdcss_t dvdcss_open ( const char *psz_target )
>               psz_key[0] = 0;
>          }
>  
> -        /* We have a disc name or ID, we can create the cache dir */
> -        i = sprintf( dvdcss->psz_cachefile, "%s", psz_cache );
> -        i_ret = mkdir( dvdcss->psz_cachefile, 0755 );
> -        if( i_ret < 0 && errno != EEXIST )
> -        {
> -            print_error( dvdcss, "failed creating cache directory" );
> -            dvdcss->psz_cachefile[0] = '\0';
> -            goto nocache;
> -        }
> -
> -        i += sprintf( dvdcss->psz_cachefile + i, "/%s-%s%s", psz_title,
> -                      psz_serial, psz_key );
> +        /* We have a disc name or ID, we can create the cache subdirectory. */
> +        i = sprintf( dvdcss->psz_cachefile, "%s/%s-%s%s",
> +                     psz_cache, psz_title, psz_serial, psz_key );
>          i_ret = mkdir( dvdcss->psz_cachefile, 0755 );
>          if( i_ret < 0 && errno != EEXIST )
>          {
> -- 
> 1.9.1
> 
> _______________________________________________
> libdvdcss-devel mailing list
> [email protected]
> https://mailman.videolan.org/listinfo/libdvdcss-devel

-- 
With my kindest regards,

-- 
Jean-Baptiste Kempf
http://www.jbkempf.com/ - +33 672 704 734
Sent from my Electronic Device
_______________________________________________
libdvdcss-devel mailing list
[email protected]
https://mailman.videolan.org/listinfo/libdvdcss-devel
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.