Prevent overwriting files when using create-device

This commit is contained in:
rlaphoenix 2023-07-07 20:10:08 +01:00
parent 728a3e7575
commit bfaae20e81
1 changed files with 4 additions and 0 deletions

View File

@ -238,6 +238,10 @@ def create_device(
out_dir = output or Path.cwd() out_dir = output or Path.cwd()
out_path = out_dir / f"{name}_{device.system_id}_l{device.security_level}.wvd" out_path = out_dir / f"{name}_{device.system_id}_l{device.security_level}.wvd"
if out_path.exists():
log.error(f"A file already exists at the path '{out_path}', cannot overwrite.")
return
out_path.parent.mkdir(parents=True, exist_ok=True) out_path.parent.mkdir(parents=True, exist_ok=True)
out_path.write_bytes(wvd_bin) out_path.write_bytes(wvd_bin)