@@ -718,8 +718,8 @@ def _seek_to_extent(self, extent):
718
718
self ._cdfp .seek (extent * self .logical_block_size )
719
719
720
720
@lru_cache (maxsize = 256 )
721
- def _find_iso_record (self , iso_path ):
722
- # type: (bytes) -> dr.DirectoryRecord
721
+ def _find_iso_record (self , iso_path , encoding = 'utf-8' ):
722
+ # type: (bytes, str ) -> dr.DirectoryRecord
723
723
"""
724
724
An internal method to find a directory record on the ISO given an ISO
725
725
path. If the entry is found, it returns the directory record object
@@ -731,7 +731,7 @@ def _find_iso_record(self, iso_path):
731
731
Returns:
732
732
The directory record entry representing the entry on the ISO.
733
733
"""
734
- return _find_dr_record_by_name (self .pvd , iso_path , 'utf-8' )
734
+ return _find_dr_record_by_name (self .pvd , iso_path , encoding )
735
735
736
736
@lru_cache (maxsize = 256 )
737
737
def _find_rr_record (self , rr_path ):
@@ -3487,8 +3487,8 @@ def _rm_joliet_dir(self, joliet_path):
3487
3487
3488
3488
return num_bytes_to_remove
3489
3489
3490
- def _get_iso_entry (self , iso_path ):
3491
- # type: (bytes) -> dr.DirectoryRecord
3490
+ def _get_iso_entry (self , iso_path , encoding = 'utf-8' ):
3491
+ # type: (bytes, str ) -> dr.DirectoryRecord
3492
3492
"""
3493
3493
Internal method to get the directory record for an ISO path.
3494
3494
@@ -3500,7 +3500,7 @@ def _get_iso_entry(self, iso_path):
3500
3500
if self ._needs_reshuffle :
3501
3501
self ._reshuffle_extents ()
3502
3502
3503
- return self ._find_iso_record (iso_path )
3503
+ return self ._find_iso_record (iso_path , encoding )
3504
3504
3505
3505
def _get_rr_entry (self , rr_path ):
3506
3506
# type: (bytes) -> dr.DirectoryRecord
@@ -5475,6 +5475,8 @@ def list_children(self, **kwargs):
5475
5475
if key in ('joliet_path' , 'rr_path' , 'iso_path' , 'udf_path' ):
5476
5476
if value is not None :
5477
5477
num_paths += 1
5478
+ elif key in ('encoding' ):
5479
+ continue
5478
5480
else :
5479
5481
raise pycdlibexception .PyCdlibInvalidInput ("Invalid keyword, must be one of 'iso_path', 'rr_path', 'joliet_path', or 'udf_path'" )
5480
5482
@@ -5497,7 +5499,7 @@ def list_children(self, **kwargs):
5497
5499
rec = self ._get_rr_entry (utils .normpath (kwargs ['rr_path' ]))
5498
5500
use_rr = True
5499
5501
else :
5500
- rec = self ._get_iso_entry (utils .normpath (kwargs ['iso_path' ]))
5502
+ rec = self ._get_iso_entry (utils .normpath (kwargs ['iso_path' ]), kwargs [ 'encoding' ] )
5501
5503
5502
5504
for c in _yield_children (rec , use_rr ):
5503
5505
yield c
@@ -5642,8 +5644,8 @@ def rm_isohybrid(self):
5642
5644
5643
5645
self .isohybrid_mbr = None
5644
5646
5645
- def full_path_from_dirrecord (self , rec , rockridge = False ):
5646
- # type: (Union[dr.DirectoryRecord, udfmod.UDFFileEntry], bool) -> str
5647
+ def full_path_from_dirrecord (self , rec , user_encoding , rockridge = False ):
5648
+ # type: (Union[dr.DirectoryRecord, udfmod.UDFFileEntry], str, bool) -> str
5647
5649
"""
5648
5650
Get the absolute path of a directory record.
5649
5651
@@ -5662,6 +5664,8 @@ def full_path_from_dirrecord(self, rec, rockridge=False):
5662
5664
if self .joliet_vd is not None and id (rec .vd ) == id (self .joliet_vd ):
5663
5665
encoding = 'utf-16_be'
5664
5666
5667
+ if user_encoding :
5668
+ encoding = user_encoding
5665
5669
# A root entry has no Rock Ridge entry, even on a Rock Ridge ISO.
5666
5670
# Always return / here.
5667
5671
if rec .is_root :
@@ -5701,6 +5705,8 @@ def full_path_from_dirrecord(self, rec, rockridge=False):
5701
5705
encoding = rec .file_ident .encoding
5702
5706
else :
5703
5707
encoding = 'utf-8'
5708
+ if user_encoding :
5709
+ encoding = user_encoding
5704
5710
udf_rec = rec # type: Optional[udfmod.UDFFileEntry]
5705
5711
while udf_rec is not None :
5706
5712
ident = udf_rec .file_identifier ()
@@ -5913,13 +5919,13 @@ def walk(self, **kwargs):
5913
5919
while dirs :
5914
5920
dir_record = dirs .popleft ()
5915
5921
5916
- relpath = self .full_path_from_dirrecord (dir_record ,
5922
+ relpath = self .full_path_from_dirrecord (dir_record , user_encoding ,
5917
5923
rockridge = path_type == 'rr_path' )
5918
5924
dirlist = []
5919
5925
filelist = []
5920
5926
dirdict = {}
5921
5927
5922
- for child in reversed (list (self .list_children (** {path_type : relpath }))):
5928
+ for child in reversed (list (self .list_children (** {path_type : relpath , 'encoding' : kwargs [ 'encoding' ] }))):
5923
5929
if child is None or child .is_dot () or child .is_dotdot ():
5924
5930
continue
5925
5931
0 commit comments