Diego Biurrun
2014-11-01 17:11:50 UTC
libdvdcss | branch: master | Diego Biurrun <***@biurrun.de> | Fri Oct 31 19:19:11 2014 +0100| [ecb2a6bf9235c78b366a61c5228b2278cd5fe859] | committer: Diego Biurrun
libdvdcss: Create cache directory before cache directory tag.
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 )
{
libdvdcss: Create cache directory before cache directory tag.
Otherwise creating the tag would fail on first invocation of libdvdcss and
the tag would only be created upon the second invocation.
http://git.videolan.org/gitweb.cgi/libdvdcss.git/?a=commit;h=ecb2a6bf9235c78b366a61c5228b2278cd5fe859
---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 )
{