diff --git a/Aaru.Images/AaruFormat/Tape.cs b/Aaru.Images/AaruFormat/Tape.cs
index 7711260c4..95cc8e4bd 100644
--- a/Aaru.Images/AaruFormat/Tape.cs
+++ b/Aaru.Images/AaruFormat/Tape.cs
@@ -1,4 +1,5 @@
using System;
+using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using Aaru.CommonTypes.Structs;
@@ -54,6 +55,69 @@ public sealed partial class AaruFormat
return true;
}
+ ///
+ public List Files
+ {
+ get
+ {
+ if(!IsTape)
+ {
+ ErrorMessage = "Image is not a tape";
+
+ return null;
+ }
+
+ nuint length = 0;
+ Status res = aaruf_get_all_tape_files(_context, IntPtr.Zero, ref length);
+
+ if(res != Status.Ok && res != Status.BufferTooSmall)
+ {
+ ErrorMessage = StatusToErrorMessage(res);
+
+ return null;
+ }
+
+ IntPtr buffer = Marshal.AllocHGlobal((int)length);
+
+ try
+ {
+ res = aaruf_get_all_tape_files(_context, buffer, ref length);
+
+ if(res != Status.Ok)
+ {
+ ErrorMessage = StatusToErrorMessage(res);
+
+ return null;
+ }
+
+ int structSize = Marshal.SizeOf();
+ int count = (int)length / structSize;
+
+ List files = new(count);
+
+ for(var i = 0; i < count; i++)
+ {
+ var structPtr = IntPtr.Add(buffer, i * structSize);
+ TapeFileEntry entry = Marshal.PtrToStructure(structPtr);
+
+ files.Add(new TapeFile
+ {
+ File = entry.File,
+ Partition = entry.Partition,
+ FirstBlock = entry.FirstBlock,
+ LastBlock = entry.LastBlock
+ });
+ }
+
+ return files;
+ }
+ finally
+ {
+ Marshal.FreeHGlobal(buffer);
+ }
+ }
+ }
+
#endregion
// AARU_EXPORT int32_t AARU_CALL aaruf_set_tape_file(void *context, const uint8_t partition, const uint32_t file,
@@ -69,4 +133,9 @@ public sealed partial class AaruFormat
[UnmanagedCallConv(CallConvs = [typeof(CallConvStdcall)])]
private static partial Status aaruf_set_tape_partition(IntPtr context, byte partition, ulong startingBlock,
ulong endingBlock);
+
+ // AARU_EXPORT int32_t AARU_CALL aaruf_get_all_tape_files(const void *context, uint8_t *buffer, size_t *length)
+ [LibraryImport("libaaruformat", EntryPoint = "aaruf_get_all_tape_files", SetLastError = true)]
+ [UnmanagedCallConv(CallConvs = [typeof(CallConvStdcall)])]
+ private static partial Status aaruf_get_all_tape_files(IntPtr context, IntPtr buffer, ref nuint length);
}
\ No newline at end of file
diff --git a/Aaru.Images/AaruFormat/Unimplemented.cs b/Aaru.Images/AaruFormat/Unimplemented.cs
index 9fbbbaace..ffcf2e9f5 100644
--- a/Aaru.Images/AaruFormat/Unimplemented.cs
+++ b/Aaru.Images/AaruFormat/Unimplemented.cs
@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using Aaru.CommonTypes;
-using TapeFile = Aaru.CommonTypes.Structs.TapeFile;
using TapePartition = Aaru.CommonTypes.Structs.TapePartition;
namespace Aaru.Images;
@@ -18,8 +17,6 @@ public sealed partial class AaruFormat
#region IWritableTapeImage Members
- ///
- public List Files { get; }
///
public List TapePartitions { get; }