@@ -410,8 +410,7 @@ def main():
410
410
options .from_emcc = True
411
411
leading = ''
412
412
elif arg .startswith ('--plugin' ):
413
- with open (arg .split ('=' , 1 )[1 ]) as f :
414
- plugin = f .read ()
413
+ plugin = utils .read_file (arg .split ('=' , 1 )[1 ])
415
414
eval (plugin ) # should append itself to plugins
416
415
leading = ''
417
416
elif leading == 'preload' or leading == 'embed' :
@@ -556,17 +555,13 @@ def was_seen(name):
556
555
# differs from the current generated one, otherwise leave the file
557
556
# untouched preserving its old timestamp
558
557
if os .path .isfile (options .jsoutput ):
559
- with open (options .jsoutput ) as f :
560
- old = f .read ()
558
+ old = utils .read_file (options .jsoutput )
561
559
if old != ret :
562
- with open (options .jsoutput , 'w' ) as f :
563
- f .write (ret )
560
+ utils .write_file (options .jsoutput , ret )
564
561
else :
565
- with open (options .jsoutput , 'w' ) as f :
566
- f .write (ret )
562
+ utils .write_file (options .jsoutput , ret )
567
563
if options .separate_metadata :
568
- with open (options .jsoutput + '.metadata' , 'w' ) as f :
569
- json .dump (metadata , f , separators = (',' , ':' ))
564
+ utils .write_file (options .jsoutput + '.metadata' , json .dumps (metadata , separators = (',' , ':' )))
570
565
571
566
return 0
572
567
@@ -617,8 +612,7 @@ def generate_js(data_target, data_files, metadata):
617
612
with open (data_target , 'wb' ) as data :
618
613
for file_ in data_files :
619
614
file_ .data_start = start
620
- with open (file_ .srcpath , 'rb' ) as f :
621
- curr = f .read ()
615
+ curr = utils .read_binary (file_ .srcpath )
622
616
file_ .data_end = start + len (curr )
623
617
if AV_WORKAROUND :
624
618
curr += '\x00 '
0 commit comments