@@ -345,6 +345,9 @@ def extract_volume_iso(args: argparse.Namespace):
345
345
"""Extract an ISO volume"""
346
346
source_volume = args .src
347
347
loglevel : str = args .log
348
+ dopunycode : bool = not args .nopunycode
349
+ dryrun : bool = args .dryrun
350
+ japanese : bool = args .japanese
348
351
349
352
numeric_level = getattr (logging , loglevel .upper (), None )
350
353
if not isinstance (numeric_level , int ):
@@ -363,24 +366,35 @@ def extract_volume_iso(args: argparse.Namespace):
363
366
elif args .extension == 'joliet' :
364
367
path_type = 'joliet_path'
365
368
elif args .extension == 'rr' :
366
- path_type = 'rr_type '
369
+ path_type = 'rr_path '
367
370
else :
368
371
path_type = 'udf_path'
369
372
370
373
arg = {path_type : '/' }
371
374
375
+ if japanese :
376
+ arg ['encoding' ] = 'shift_jis'
377
+
372
378
for dirname , dirlist , filelist in iso .walk (** arg ):
373
379
pwd = output_dir + dirname
374
380
for dir in dirlist :
375
381
joined_path = os .path .join (pwd , dir )
376
- os .makedirs (joined_path , exist_ok = True )
382
+ if not dryrun :
383
+ os .makedirs (joined_path , exist_ok = True )
384
+ else :
385
+ print (joined_path )
386
+
387
+ if dryrun :
388
+ continue
389
+
377
390
for file in filelist :
378
391
filename = file .split (';' )[0 ]
379
392
iso_file_path = os .path .join (dirname , filename )
380
393
with open (os .path .join (pwd , filename ), 'wb' ) as f :
381
394
arg [path_type ] = iso_file_path
382
395
iso .get_file_from_iso_fp (outfp = f , ** arg )
383
-
396
+ if dopunycode :
397
+ punyencode_dir (Path (output_dir ))
384
398
iso .close ()
385
399
386
400
@@ -834,6 +848,15 @@ def generate_parser() -> argparse.ArgumentParser:
834
848
"--log" , metavar = "LEVEL" , help = "set logging level" , default = "INFO"
835
849
)
836
850
parser_iso9660 .add_argument ("--extension" , choices = ['joliet' , 'rr' , 'udf' ], metavar = "EXTENSION" , help = "Use if the iso9660 has an extension" )
851
+ parser_iso9660 .add_argument (
852
+ "--nopunycode" , action = "store_true" , help = "never encode pathnames into punycode"
853
+ )
854
+ parser_iso9660 .add_argument (
855
+ "--dryrun" , action = "store_true" , help = "do not write any files"
856
+ )
857
+ parser_iso9660 .add_argument (
858
+ "--japanese" , action = "store_true" , help = "read MacJapanese HFS"
859
+ )
837
860
parser_iso9660 .add_argument ("src" , metavar = "INPUT" , type = Path , help = "Disk image" )
838
861
parser_iso9660 .add_argument (
839
862
"dir" , metavar = "OUTPUT" , type = Path , help = "Destination folder"
0 commit comments