@@ -718,8 +718,8 @@ def _seek_to_extent(self, extent):
718718 self ._cdfp .seek (extent * self .logical_block_size )
719719
720720 @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
723723 """
724724 An internal method to find a directory record on the ISO given an ISO
725725 path. If the entry is found, it returns the directory record object
@@ -731,7 +731,7 @@ def _find_iso_record(self, iso_path):
731731 Returns:
732732 The directory record entry representing the entry on the ISO.
733733 """
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 )
735735
736736 @lru_cache (maxsize = 256 )
737737 def _find_rr_record (self , rr_path ):
@@ -3487,8 +3487,8 @@ def _rm_joliet_dir(self, joliet_path):
34873487
34883488 return num_bytes_to_remove
34893489
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
34923492 """
34933493 Internal method to get the directory record for an ISO path.
34943494
@@ -3500,7 +3500,7 @@ def _get_iso_entry(self, iso_path):
35003500 if self ._needs_reshuffle :
35013501 self ._reshuffle_extents ()
35023502
3503- return self ._find_iso_record (iso_path )
3503+ return self ._find_iso_record (iso_path , encoding )
35043504
35053505 def _get_rr_entry (self , rr_path ):
35063506 # type: (bytes) -> dr.DirectoryRecord
@@ -5475,6 +5475,8 @@ def list_children(self, **kwargs):
54755475 if key in ('joliet_path' , 'rr_path' , 'iso_path' , 'udf_path' ):
54765476 if value is not None :
54775477 num_paths += 1
5478+ elif key in ('encoding' ):
5479+ continue
54785480 else :
54795481 raise pycdlibexception .PyCdlibInvalidInput ("Invalid keyword, must be one of 'iso_path', 'rr_path', 'joliet_path', or 'udf_path'" )
54805482
@@ -5497,7 +5499,7 @@ def list_children(self, **kwargs):
54975499 rec = self ._get_rr_entry (utils .normpath (kwargs ['rr_path' ]))
54985500 use_rr = True
54995501 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' ] )
55015503
55025504 for c in _yield_children (rec , use_rr ):
55035505 yield c
@@ -5642,8 +5644,8 @@ def rm_isohybrid(self):
56425644
56435645 self .isohybrid_mbr = None
56445646
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
56475649 """
56485650 Get the absolute path of a directory record.
56495651
@@ -5662,6 +5664,8 @@ def full_path_from_dirrecord(self, rec, rockridge=False):
56625664 if self .joliet_vd is not None and id (rec .vd ) == id (self .joliet_vd ):
56635665 encoding = 'utf-16_be'
56645666
5667+ if user_encoding :
5668+ encoding = user_encoding
56655669 # A root entry has no Rock Ridge entry, even on a Rock Ridge ISO.
56665670 # Always return / here.
56675671 if rec .is_root :
@@ -5701,6 +5705,8 @@ def full_path_from_dirrecord(self, rec, rockridge=False):
57015705 encoding = rec .file_ident .encoding
57025706 else :
57035707 encoding = 'utf-8'
5708+ if user_encoding :
5709+ encoding = user_encoding
57045710 udf_rec = rec # type: Optional[udfmod.UDFFileEntry]
57055711 while udf_rec is not None :
57065712 ident = udf_rec .file_identifier ()
@@ -5913,13 +5919,13 @@ def walk(self, **kwargs):
59135919 while dirs :
59145920 dir_record = dirs .popleft ()
59155921
5916- relpath = self .full_path_from_dirrecord (dir_record ,
5922+ relpath = self .full_path_from_dirrecord (dir_record , user_encoding ,
59175923 rockridge = path_type == 'rr_path' )
59185924 dirlist = []
59195925 filelist = []
59205926 dirdict = {}
59215927
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' ] }))):
59235929 if child is None or child .is_dot () or child .is_dotdot ():
59245930 continue
59255931
0 commit comments