From cb29d807637d04c5ae55561883d7a2d756412099 Mon Sep 17 00:00:00 2001 From: Natalia Portillo Date: Sat, 11 Oct 2025 15:58:21 +0100 Subject: [PATCH] Add AaruFormat skeleton. --- Aaru.Images/AaruFormat/AaruFormat.cs | 35 +++++ Aaru.Images/AaruFormat/Properties.cs | 107 ++++++++++++++++ Aaru.Images/AaruFormat/Unimplemented.cs | 163 ++++++++++++++++++++++++ 3 files changed, 305 insertions(+) create mode 100644 Aaru.Images/AaruFormat/AaruFormat.cs create mode 100644 Aaru.Images/AaruFormat/Properties.cs create mode 100644 Aaru.Images/AaruFormat/Unimplemented.cs diff --git a/Aaru.Images/AaruFormat/AaruFormat.cs b/Aaru.Images/AaruFormat/AaruFormat.cs new file mode 100644 index 000000000..0cb6f3d92 --- /dev/null +++ b/Aaru.Images/AaruFormat/AaruFormat.cs @@ -0,0 +1,35 @@ +using Aaru.CommonTypes.Interfaces; +using Aaru.CommonTypes.Structs; + +namespace Aaru.Images; + +/// +/// Implements reading and writing AaruFormat media images +public sealed partial class AaruFormat : IWritableOpticalImage, IVerifiableImage, IWritableTapeImage +{ + readonly ImageInfo _imageInfo; + + public AaruFormat() => _imageInfo = new ImageInfo + { + ReadableSectorTags = [], + ReadableMediaTags = [], + HasPartitions = false, + HasSessions = false, + Version = null, + Application = "Aaru", + ApplicationVersion = null, + Creator = null, + Comments = null, + MediaManufacturer = null, + MediaModel = null, + MediaSerialNumber = null, + MediaBarcode = null, + MediaPartNumber = null, + MediaSequence = 0, + LastMediaSequence = 0, + DriveManufacturer = null, + DriveModel = null, + DriveSerialNumber = null, + DriveFirmwareRevision = null + }; +} \ No newline at end of file diff --git a/Aaru.Images/AaruFormat/Properties.cs b/Aaru.Images/AaruFormat/Properties.cs new file mode 100644 index 000000000..10b863b4c --- /dev/null +++ b/Aaru.Images/AaruFormat/Properties.cs @@ -0,0 +1,107 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using Aaru.CommonTypes; +using Aaru.CommonTypes.AaruMetadata; +using Aaru.CommonTypes.Enums; +using Aaru.CommonTypes.Structs; +using Partition = Aaru.CommonTypes.Partition; +using Track = Aaru.CommonTypes.Structs.Track; + +namespace Aaru.Images; + +public sealed partial class AaruFormat +{ +#region IWritableOpticalImage Members + + /// + public OpticalImageCapabilities OpticalCapabilities => OpticalImageCapabilities.CanStoreAudioTracks | + OpticalImageCapabilities.CanStoreDataTracks | + OpticalImageCapabilities.CanStorePregaps | + OpticalImageCapabilities.CanStoreSubchannelRw | + OpticalImageCapabilities.CanStoreSessions | + OpticalImageCapabilities.CanStoreIsrc | + OpticalImageCapabilities.CanStoreCdText | + OpticalImageCapabilities.CanStoreMcn | + OpticalImageCapabilities.CanStoreRawData | + OpticalImageCapabilities.CanStoreCookedData | + OpticalImageCapabilities.CanStoreMultipleTracks | + OpticalImageCapabilities.CanStoreNotCdSessions | + OpticalImageCapabilities.CanStoreNotCdTracks | + OpticalImageCapabilities.CanStoreIndexes | + OpticalImageCapabilities.CanStoreHiddenTracks; + + /// + + // ReSharper disable once ConvertToAutoProperty + public ImageInfo Info => _imageInfo; + + /// + public string Name => Localization.AaruFormat_Name; + + /// + public Guid Id => new("D98C9259-482C-4F0A-B428-18736DC039A6"); + + /// + public string Format => "Aaru"; + + /// + public string Author => Authors.NataliaPortillo; + + /// + public List Partitions { get; private set; } + + /// + public List Tracks { get; private set; } + + /// + public List Sessions { get; private set; } + + /// + public List DumpHardware { get; private set; } + + /// + public Metadata AaruMetadata { get; private set; } + + /// + public IEnumerable SupportedMediaTags => Enum.GetValues(typeof(MediaTagType)).Cast(); + + /// + public IEnumerable SupportedSectorTags => + Enum.GetValues(typeof(SectorTagType)).Cast(); + + /// + public IEnumerable SupportedMediaTypes => Enum.GetValues(typeof(MediaType)).Cast(); + + /// + public IEnumerable<(string name, Type type, string description, object @default)> SupportedOptions => + [ + ("dictionary", typeof(uint), Localization.Size_in_bytes_of_the_LZMA_dictionary, (uint)(1 << 25)), + ("md5", typeof(bool), Localization.Calculate_and_store_MD5_of_image_user_data, false), + ("sha1", typeof(bool), Localization.Calculate_and_store_SHA1_of_image_user_data, false), + ("sha256", typeof(bool), Localization.Calculate_and_store_SHA256_of_image_user_data, false), + ("spamsum", typeof(bool), Localization.Calculate_and_store_SpamSum_of_image_user_data, false), + ("blake3", typeof(bool), "Calculate and store BLAKE3 of image's user data", false), + ("deduplicate", typeof(bool), + Localization.Store_only_unique_sectors_This_consumes_more_memory_and_is_slower_but_its_enabled_by_default, + true), + ("compress", typeof(bool), Localization.Compress_user_data_blocks_Other_blocks_will_always_be_compressed, + true), + ("table_shift", typeof(int), + "Shift value of how many sectors are stored per primary table entry. -1 for automatic, 0 to use a single table level.", + -1), + ("data_shift", typeof(int), "Shift value of how many sectors are stored per data block.", 12), + ("block_alignment", typeof(uint), "Shift value of alignment of blocks in the image", 9) + ]; + + /// + public IEnumerable KnownExtensions => [".dicf", ".aaru", ".aaruformat", ".aaruf", ".aif"]; + + /// + public bool IsWriting { get; private set; } + + /// + public string ErrorMessage { get; private set; } + +#endregion +} \ No newline at end of file diff --git a/Aaru.Images/AaruFormat/Unimplemented.cs b/Aaru.Images/AaruFormat/Unimplemented.cs new file mode 100644 index 000000000..05b81d332 --- /dev/null +++ b/Aaru.Images/AaruFormat/Unimplemented.cs @@ -0,0 +1,163 @@ +using System; +using System.Collections.Generic; +using Aaru.CommonTypes; +using Aaru.CommonTypes.AaruMetadata; +using Aaru.CommonTypes.Enums; +using Aaru.CommonTypes.Interfaces; +using Aaru.CommonTypes.Structs; +using TapeFile = Aaru.CommonTypes.Structs.TapeFile; +using TapePartition = Aaru.CommonTypes.Structs.TapePartition; +using Track = Aaru.CommonTypes.Structs.Track; + +namespace Aaru.Images; + +public sealed partial class AaruFormat +{ +#region IVerifiableImage Members + + /// + public bool? VerifyMediaImage() => throw new NotImplementedException(); + +#endregion + +#region IWritableOpticalImage Members + + /// + public bool Identify(IFilter imageFilter) => throw new NotImplementedException(); + + /// + public ErrorNumber Open(IFilter imageFilter) => throw new NotImplementedException(); + + /// + public ErrorNumber ReadMediaTag(MediaTagType tag, out byte[] buffer) => throw new NotImplementedException(); + + /// + public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer) => throw new NotImplementedException(); + + /// + public ErrorNumber ReadSectorLong(ulong sectorAddress, out byte[] buffer) => throw new NotImplementedException(); + + /// + public ErrorNumber ReadSectors(ulong sectorAddress, uint length, out byte[] buffer) => + throw new NotImplementedException(); + + /// + public ErrorNumber ReadSectorsLong(ulong sectorAddress, uint length, out byte[] buffer) => + throw new NotImplementedException(); + + /// + public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer) => + throw new NotImplementedException(); + + /// + public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer) => + throw new NotImplementedException(); + + /// + public bool Create(string path, MediaType mediaType, Dictionary options, ulong sectors, + uint sectorSize) => throw new NotImplementedException(); + + /// + public bool Close() => throw new NotImplementedException(); + + /// + public bool SetMetadata(Metadata metadata) => throw new NotImplementedException(); + + /// + public bool SetDumpHardware(List dumpHardware) => throw new NotImplementedException(); + + /// + public bool SetImageInfo(ImageInfo imageInfo) => throw new NotImplementedException(); + + /// + public bool SetGeometry(uint cylinders, uint heads, uint sectorsPerTrack) => throw new NotImplementedException(); + + /// + public bool WriteMediaTag(byte[] data, MediaTagType tag) => throw new NotImplementedException(); + + /// + public bool WriteSector(byte[] data, ulong sectorAddress) => throw new NotImplementedException(); + + /// + public bool WriteSectorLong(byte[] data, ulong sectorAddress) => throw new NotImplementedException(); + + /// + public bool WriteSectors(byte[] data, ulong sectorAddress, uint length) => throw new NotImplementedException(); + + /// + public bool WriteSectorsLong(byte[] data, ulong sectorAddress, uint length) => throw new NotImplementedException(); + + /// + public bool WriteSectorsTag(byte[] data, ulong sectorAddress, uint length, SectorTagType tag) => + throw new NotImplementedException(); + + /// + public bool WriteSectorTag(byte[] data, ulong sectorAddress, SectorTagType tag) => + throw new NotImplementedException(); + + /// + public bool? VerifySector(ulong sectorAddress) => throw new NotImplementedException(); + + /// + public bool? VerifySectors(ulong sectorAddress, uint length, out List failingLbas, + out List unknownLbas) => throw new NotImplementedException(); + + /// + public ErrorNumber ReadSector(ulong sectorAddress, uint track, out byte[] buffer) => + throw new NotImplementedException(); + + /// + public ErrorNumber ReadSectorTag(ulong sectorAddress, uint track, SectorTagType tag, out byte[] buffer) => + throw new NotImplementedException(); + + /// + public ErrorNumber ReadSectors(ulong sectorAddress, uint length, uint track, out byte[] buffer) => + throw new NotImplementedException(); + + /// + public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, uint track, SectorTagType tag, + out byte[] buffer) => throw new NotImplementedException(); + + /// + public ErrorNumber ReadSectorLong(ulong sectorAddress, uint track, out byte[] buffer) => + throw new NotImplementedException(); + + /// + public ErrorNumber ReadSectorsLong(ulong sectorAddress, uint length, uint track, out byte[] buffer) => + throw new NotImplementedException(); + + /// + public List GetSessionTracks(Session session) => throw new NotImplementedException(); + + /// + public List GetSessionTracks(ushort session) => throw new NotImplementedException(); + + /// + public bool? VerifySectors(ulong sectorAddress, uint length, uint track, out List failingLbas, + out List unknownLbas) => throw new NotImplementedException(); + + /// + public bool SetTracks(List tracks) => throw new NotImplementedException(); + +#endregion + +#region IWritableTapeImage Members + + /// + public List Files { get; } + /// + public List TapePartitions { get; } + /// + public bool IsTape { get; } + + /// + public bool AddFile(TapeFile file) => throw new NotImplementedException(); + + /// + public bool AddPartition(TapePartition partition) => throw new NotImplementedException(); + + /// + public bool SetTape() => throw new NotImplementedException(); + +#endregion +} \ No newline at end of file