summaryrefslogtreecommitdiffstats
path: root/libhb
diff options
context:
space:
mode:
authorjstebbins <[email protected]>2014-10-13 01:37:48 +0000
committerjstebbins <[email protected]>2014-10-13 01:37:48 +0000
commitc69f6b2ab71e16260e66534ded705fa8314bb5f5 (patch)
treeb684221c2aede7d63653c1d20d0f08cd8af0d103 /libhb
parent255522e6b2bd014f954bfb0d58ac6f40cf2999e0 (diff)
ilibhb: Fix reading from DVDISO files with non-ASCII filenames on Windows
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6443 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb')
-rw-r--r--libhb/dvd.c16
-rw-r--r--libhb/dvdnav.c25
2 files changed, 33 insertions, 8 deletions
diff --git a/libhb/dvd.c b/libhb/dvd.c
index 418382317..0e0fccf7a 100644
--- a/libhb/dvd.c
+++ b/libhb/dvd.c
@@ -111,12 +111,20 @@ hb_dvd_t * hb_dvdread_init( char * path )
hb_dvd_t * e;
hb_dvdread_t * d;
int region_mask;
+ char * path_ccp;
e = calloc( sizeof( hb_dvd_t ), 1 );
d = &(e->dvdread);
+ /*
+ * Convert UTF-8 path to current code page on Windows
+ * hb_utf8_to_cp() is the same as strdup on non-Windows,
+ * so no #ifdef required here
+ */
+ path_ccp = hb_utf8_to_cp( path );
+
/* Log DVD drive region code */
- if ( hb_dvd_region( path, &region_mask ) == 0 )
+ if ( hb_dvd_region( path_ccp, &region_mask ) == 0 )
{
hb_log( "dvd: Region mask 0x%02x", region_mask );
if ( region_mask == 0xFF )
@@ -126,7 +134,7 @@ hb_dvd_t * hb_dvdread_init( char * path )
}
/* Open device */
- if( !( d->reader = DVDOpen( path ) ) )
+ if( !( d->reader = DVDOpen( path_ccp ) ) )
{
/*
* Not an error, may be a stream - which we'll try in a moment.
@@ -142,7 +150,8 @@ hb_dvd_t * hb_dvdread_init( char * path )
goto fail;
}
- d->path = strdup( path );
+ d->path = strdup( path ); /* hb_dvdread_title_scan assumes UTF-8 path, so not path_ccp here */
+ free( path_ccp );
return e;
@@ -150,6 +159,7 @@ fail:
if( d->vmg ) ifoClose( d->vmg );
if( d->reader ) DVDClose( d->reader );
free( e );
+ free( path_ccp );
return NULL;
}
diff --git a/libhb/dvdnav.c b/libhb/dvdnav.c
index 3c820b789..2e7973c0d 100644
--- a/libhb/dvdnav.c
+++ b/libhb/dvdnav.c
@@ -99,11 +99,12 @@ static char * hb_dvdnav_name( char * path )
**********************************************************************/
static int hb_dvdnav_reset( hb_dvdnav_t * d )
{
+ char * path_ccp = hb_utf8_to_cp( d->path );
if ( d->dvdnav )
dvdnav_close( d->dvdnav );
/* Open device */
- if( dvdnav_open(&d->dvdnav, d->path) != DVDNAV_STATUS_OK )
+ if( dvdnav_open(&d->dvdnav, path_ccp) != DVDNAV_STATUS_OK )
{
/*
* Not an error, may be a stream - which we'll try in a moment.
@@ -131,10 +132,14 @@ static int hb_dvdnav_reset( hb_dvdnav_t * d )
dvdnav_err_to_string(d->dvdnav));
goto fail;
}
+
+ free( path_ccp );
+
return 1;
fail:
if( d->dvdnav ) dvdnav_close( d->dvdnav );
+ free( path_ccp );
return 0;
}
@@ -148,12 +153,20 @@ static hb_dvd_t * hb_dvdnav_init( char * path )
hb_dvd_t * e;
hb_dvdnav_t * d;
int region_mask;
+ char * path_ccp;
e = calloc( sizeof( hb_dvd_t ), 1 );
d = &(e->dvdnav);
+ /*
+ * Convert UTF-8 path to current code page on Windows
+ * hb_utf8_to_cp() is the same as strdup on non-Windows,
+ * so no #ifdef required here
+ */
+ path_ccp = hb_utf8_to_cp( path );
+
/* Log DVD drive region code */
- if ( hb_dvd_region( path, &region_mask ) == 0 )
+ if ( hb_dvd_region( path_ccp, &region_mask ) == 0 )
{
hb_log( "dvd: Region mask 0x%02x", region_mask );
if ( region_mask == 0xFF )
@@ -163,7 +176,7 @@ static hb_dvd_t * hb_dvdnav_init( char * path )
}
/* Open device */
- if( dvdnav_open(&d->dvdnav, path) != DVDNAV_STATUS_OK )
+ if( dvdnav_open(&d->dvdnav, path_ccp) != DVDNAV_STATUS_OK )
{
/*
* Not an error, may be a stream - which we'll try in a moment.
@@ -193,7 +206,7 @@ static hb_dvd_t * hb_dvdnav_init( char * path )
}
/* Open device */
- if( !( d->reader = DVDOpen( path ) ) )
+ if( !( d->reader = DVDOpen( path_ccp ) ) )
{
/*
* Not an error, may be a stream - which we'll try in a moment.
@@ -209,7 +222,8 @@ static hb_dvd_t * hb_dvdnav_init( char * path )
goto fail;
}
- d->path = strdup( path );
+ d->path = strdup( path ); /* hb_dvdnav_title_scan assumes UTF-8 path, so not path_ccp here */
+ free( path_ccp );
return e;
@@ -218,6 +232,7 @@ fail:
if( d->vmg ) ifoClose( d->vmg );
if( d->reader ) DVDClose( d->reader );
free( e );
+ free( path_ccp );
return NULL;
}