Don't let output file be one of the input files.
This commit is contained in:
parent
05d59c2149
commit
7936f15f27
1 changed files with 5 additions and 2 deletions
|
@ -31,13 +31,15 @@ def bitwise_or_argparse(args):
|
||||||
log.fatal('Need at least two input files.')
|
log.fatal('Need at least two input files.')
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
handles = [file.open('rb') for file in files]
|
|
||||||
|
|
||||||
output = pathclass.Path(args.output)
|
output = pathclass.Path(args.output)
|
||||||
if output.is_dir:
|
if output.is_dir:
|
||||||
log.fatal('Output path "%s" is a directory.', args.output)
|
log.fatal('Output path "%s" is a directory.', args.output)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
if any(output == file for file in files):
|
||||||
|
log.fatal('Output cannot be one of the inputs.')
|
||||||
|
return 1
|
||||||
|
|
||||||
if not output.exists:
|
if not output.exists:
|
||||||
pass
|
pass
|
||||||
elif args.overwrite:
|
elif args.overwrite:
|
||||||
|
@ -45,6 +47,7 @@ def bitwise_or_argparse(args):
|
||||||
elif not interactive.getpermission(f'Overwrite "{output.absolute_path}"?'):
|
elif not interactive.getpermission(f'Overwrite "{output.absolute_path}"?'):
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
handles = [file.open('rb') for file in files]
|
||||||
output_handle = output.open('wb')
|
output_handle = output.open('wb')
|
||||||
while True:
|
while True:
|
||||||
chunk = 0
|
chunk = 0
|
||||||
|
|
Loading…
Reference in a new issue