]> granicus.if.org Git - handbrake/commitdiff
ilibhb: Fix reading from DVDISO files with non-ASCII filenames on Windows
authorjstebbins <jstebbins.hb@gmail.com>
Mon, 13 Oct 2014 01:37:48 +0000 (01:37 +0000)
committerjstebbins <jstebbins.hb@gmail.com>
Mon, 13 Oct 2014 01:37:48 +0000 (01:37 +0000)
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6443 b64f7644-9d1e-0410-96f1-a4d463321fa5

libhb/dvd.c
libhb/dvdnav.c

index 418382317622360fc6b008cfff5960e002ee142b..0e0fccf7a1d371345848494c722653fa846ab231 100644 (file)
@@ -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;
 }
 
index 3c820b7896dcd6476c6b03d66e88b47eeaa5609f..2e7973c0dc55a10e9f8c2a434803ab85a34df149 100644 (file)
@@ -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;
 }