From b266a0f33d839555968b29d5177e3220081628bd Mon Sep 17 00:00:00 2001 From: Natalia Portillo Date: Sun, 12 Oct 2025 15:15:24 +0100 Subject: [PATCH] Validate tape status before adding files and partitions --- Aaru.Images/AaruFormat/Tape.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Aaru.Images/AaruFormat/Tape.cs b/Aaru.Images/AaruFormat/Tape.cs index c10b32acb..505198dd1 100644 --- a/Aaru.Images/AaruFormat/Tape.cs +++ b/Aaru.Images/AaruFormat/Tape.cs @@ -12,6 +12,13 @@ public sealed partial class AaruFormat /// public bool AddFile(TapeFile file) { + if(!IsTape) + { + ErrorMessage = "Image is not a tape"; + + return false; + } + Status res = aaruf_set_tape_file(_context, file.Partition, file.File, file.FirstBlock, file.LastBlock); ErrorMessage = StatusToErrorMessage(res); @@ -22,6 +29,13 @@ public sealed partial class AaruFormat /// public bool AddPartition(TapePartition partition) { + if(!IsTape) + { + ErrorMessage = "Image is not a tape"; + + return false; + } + Status res = aaruf_set_tape_partition(_context, partition.Number, partition.FirstBlock, partition.LastBlock); ErrorMessage = StatusToErrorMessage(res);