[Aaru.Images] Reformat and cleanup.

This commit is contained in:
2023-10-03 23:34:59 +01:00
parent 6ffde343ce
commit 2cfad87955
432 changed files with 12011 additions and 8261 deletions

View File

@@ -42,6 +42,7 @@ namespace Aaru.DiscImages;
/// <summary>Implements reading and writing DR-DOS' DISKCOPY disk images</summary>
public sealed partial class DriDiskCopy : IWritableImage
{
const string MODULE_NAME = "DRI DiskCopy plugin";
/// <summary>Disk image file</summary>
IFilter _driImageFilter;
@@ -71,6 +72,4 @@ public sealed partial class DriDiskCopy : IWritableImage
DriveSerialNumber = null,
DriveFirmwareRevision = null
};
const string MODULE_NAME = "DRI DiskCopy plugin";
}

View File

@@ -37,6 +37,8 @@ namespace Aaru.DiscImages;
[SuppressMessage("ReSharper", "UnusedMember.Local")]
public sealed partial class DriDiskCopy
{
#region Nested type: DriveCode
/// <summary>Drive codes change according to CMOS stored valued</summary>
[SuppressMessage("ReSharper", "InconsistentNaming")]
enum DriveCode : byte
@@ -52,4 +54,6 @@ public sealed partial class DriDiskCopy
/// <summary>3.5" 2.88M</summary>
mf2ed = 9
}
#endregion
}

View File

@@ -40,6 +40,8 @@ namespace Aaru.DiscImages;
public sealed partial class DriDiskCopy
{
#region IWritableImage Members
/// <inheritdoc />
public bool Identify(IFilter imageFilter)
{
@@ -48,7 +50,7 @@ public sealed partial class DriDiskCopy
if((stream.Length - Marshal.SizeOf<Footer>()) % 512 != 0)
return false;
byte[] buffer = new byte[Marshal.SizeOf<Footer>()];
var buffer = new byte[Marshal.SizeOf<Footer>()];
stream.Seek(-buffer.Length, SeekOrigin.End);
stream.EnsureRead(buffer, 0, buffer.Length);
@@ -57,7 +59,7 @@ public sealed partial class DriDiskCopy
string sig = StringHandlers.CToString(tmpFooter.signature);
AaruConsole.DebugWriteLine(MODULE_NAME, "tmp_footer.signature = \"{0}\"", sig);
AaruConsole.DebugWriteLine(MODULE_NAME, "tmp_footer.bpb.five = {0}", tmpFooter.bpb.five);
AaruConsole.DebugWriteLine(MODULE_NAME, "tmp_footer.bpb.five = {0}", tmpFooter.bpb.five);
AaruConsole.DebugWriteLine(MODULE_NAME, "tmp_footer.bpb._driveCode = {0}", tmpFooter.bpb._driveCode);
@@ -66,18 +68,18 @@ public sealed partial class DriDiskCopy
AaruConsole.DebugWriteLine(MODULE_NAME, "tmp_footer.bpb.cylinders = {0}", tmpFooter.bpb.cylinders);
AaruConsole.DebugWriteLine(MODULE_NAME, "tmp_footer.bpb.unknown2 = {0}", tmpFooter.bpb.unknown2);
AaruConsole.DebugWriteLine(MODULE_NAME, "tmp_footer.bpb.bps = {0}", tmpFooter.bpb.bps);
AaruConsole.DebugWriteLine(MODULE_NAME, "tmp_footer.bpb.spc = {0}", tmpFooter.bpb.spc);
AaruConsole.DebugWriteLine(MODULE_NAME, "tmp_footer.bpb.bps = {0}", tmpFooter.bpb.bps);
AaruConsole.DebugWriteLine(MODULE_NAME, "tmp_footer.bpb.spc = {0}", tmpFooter.bpb.spc);
AaruConsole.DebugWriteLine(MODULE_NAME, "tmp_footer.bpb.rsectors = {0}", tmpFooter.bpb.rsectors);
AaruConsole.DebugWriteLine(MODULE_NAME, "tmp_footer.bpb.fats_no = {0}", tmpFooter.bpb.fats_no);
AaruConsole.DebugWriteLine(MODULE_NAME, "tmp_footer.bpb.sectors = {0}", tmpFooter.bpb.sectors);
AaruConsole.DebugWriteLine(MODULE_NAME, "tmp_footer.bpb.fats_no = {0}", tmpFooter.bpb.fats_no);
AaruConsole.DebugWriteLine(MODULE_NAME, "tmp_footer.bpb.sectors = {0}", tmpFooter.bpb.sectors);
AaruConsole.DebugWriteLine(MODULE_NAME, "tmp_footer.bpb.media_descriptor = {0}",
tmpFooter.bpb.media_descriptor);
AaruConsole.DebugWriteLine(MODULE_NAME, "tmp_footer.bpb.spfat = {0}", tmpFooter.bpb.spfat);
AaruConsole.DebugWriteLine(MODULE_NAME, "tmp_footer.bpb.sptrack = {0}", tmpFooter.bpb.sptrack);
AaruConsole.DebugWriteLine(MODULE_NAME, "tmp_footer.bpb.heads = {0}", tmpFooter.bpb.heads);
AaruConsole.DebugWriteLine(MODULE_NAME, "tmp_footer.bpb.spfat = {0}", tmpFooter.bpb.spfat);
AaruConsole.DebugWriteLine(MODULE_NAME, "tmp_footer.bpb.sptrack = {0}", tmpFooter.bpb.sptrack);
AaruConsole.DebugWriteLine(MODULE_NAME, "tmp_footer.bpb.heads = {0}", tmpFooter.bpb.heads);
AaruConsole.DebugWriteLine(MODULE_NAME, "tmp_footer.bpb.hsectors = {0}", tmpFooter.bpb.hsectors);
AaruConsole.DebugWriteLine(MODULE_NAME, "tmp_footer.bpb.drive_no = {0}", tmpFooter.bpb.drive_no);
AaruConsole.DebugWriteLine(MODULE_NAME, "tmp_footer.bpb.unknown3 = {0}", tmpFooter.bpb.unknown3);
@@ -99,6 +101,8 @@ public sealed partial class DriDiskCopy
if(tmpFooter.bpb.sptrack * tmpFooter.bpb.cylinders * tmpFooter.bpb.heads != tmpFooter.bpb.sectors)
return false;
return (tmpFooter.bpb.sectors * tmpFooter.bpb.bps) + Marshal.SizeOf<Footer>() == stream.Length;
return tmpFooter.bpb.sectors * tmpFooter.bpb.bps + Marshal.SizeOf<Footer>() == stream.Length;
}
#endregion
}

View File

@@ -41,23 +41,32 @@ namespace Aaru.DiscImages;
public sealed partial class DriDiskCopy
{
#region IWritableImage Members
/// <inheritdoc />
public ImageInfo Info => _imageInfo;
/// <inheritdoc />
public string Name => Localization.DriDiskCopy_Name;
/// <inheritdoc />
public Guid Id => new("9F0BE551-8BAB-4038-8B5A-691F1BF5FFF3");
/// <inheritdoc />
public string Author => Authors.NataliaPortillo;
/// <inheritdoc />
public string Format => "Digital Research DiskCopy";
/// <inheritdoc />
public List<DumpHardware> DumpHardware => null;
/// <inheritdoc />
public Metadata AaruMetadata => null;
/// <inheritdoc />
public IEnumerable<MediaTagType> SupportedMediaTags => Array.Empty<MediaTagType>();
/// <inheritdoc />
public IEnumerable<SectorTagType> SupportedSectorTags => Array.Empty<SectorTagType>();
@@ -67,22 +76,25 @@ public sealed partial class DriDiskCopy
{
MediaType.ACORN_35_DS_DD, MediaType.ACORN_35_DS_HD, MediaType.Apricot_35, MediaType.ATARI_35_DS_DD,
MediaType.ATARI_35_DS_DD_11, MediaType.ATARI_35_SS_DD, MediaType.ATARI_35_SS_DD_11, MediaType.DMF,
MediaType.DMF_82, MediaType.DOS_35_DS_DD_8, MediaType.DOS_35_DS_DD_9, MediaType.DOS_35_ED, MediaType.DOS_35_HD,
MediaType.DOS_35_SS_DD_8, MediaType.DOS_35_SS_DD_9, MediaType.DOS_525_DS_DD_8, MediaType.DOS_525_DS_DD_9,
MediaType.DOS_525_HD, MediaType.DOS_525_SS_DD_8, MediaType.DOS_525_SS_DD_9, MediaType.FDFORMAT_35_DD,
MediaType.FDFORMAT_35_HD, MediaType.FDFORMAT_525_DD, MediaType.FDFORMAT_525_HD, MediaType.RX50,
MediaType.XDF_35, MediaType.XDF_525, MediaType.MetaFloppy_Mod_I, MediaType.MetaFloppy_Mod_II
MediaType.DMF_82, MediaType.DOS_35_DS_DD_8, MediaType.DOS_35_DS_DD_9, MediaType.DOS_35_ED,
MediaType.DOS_35_HD, MediaType.DOS_35_SS_DD_8, MediaType.DOS_35_SS_DD_9, MediaType.DOS_525_DS_DD_8,
MediaType.DOS_525_DS_DD_9, MediaType.DOS_525_HD, MediaType.DOS_525_SS_DD_8, MediaType.DOS_525_SS_DD_9,
MediaType.FDFORMAT_35_DD, MediaType.FDFORMAT_35_HD, MediaType.FDFORMAT_525_DD, MediaType.FDFORMAT_525_HD,
MediaType.RX50, MediaType.XDF_35, MediaType.XDF_525, MediaType.MetaFloppy_Mod_I, MediaType.MetaFloppy_Mod_II
};
/// <inheritdoc />
public IEnumerable<(string name, Type type, string description, object @default)> SupportedOptions =>
Array.Empty<(string name, Type type, string description, object @default)>();
/// <inheritdoc />
public IEnumerable<string> KnownExtensions => new[]
{
".dsk"
};
public IEnumerable<string> KnownExtensions => new[] { ".dsk" };
/// <inheritdoc />
public bool IsWriting { get; private set; }
/// <inheritdoc />
public string ErrorMessage { get; private set; }
#endregion
}

View File

@@ -42,6 +42,8 @@ namespace Aaru.DiscImages;
public sealed partial class DriDiskCopy
{
#region IWritableImage Members
/// <inheritdoc />
public ErrorNumber Open(IFilter imageFilter)
{
@@ -50,7 +52,7 @@ public sealed partial class DriDiskCopy
if((stream.Length - Marshal.SizeOf<Footer>()) % 512 != 0)
return ErrorNumber.InvalidArgument;
byte[] buffer = new byte[Marshal.SizeOf<Footer>()];
var buffer = new byte[Marshal.SizeOf<Footer>()];
stream.Seek(-buffer.Length, SeekOrigin.End);
stream.EnsureRead(buffer, 0, buffer.Length);
@@ -67,7 +69,7 @@ public sealed partial class DriDiskCopy
if(_footer.bpb.sptrack * _footer.bpb.cylinders * _footer.bpb.heads != _footer.bpb.sectors)
return ErrorNumber.InvalidArgument;
if((_footer.bpb.sectors * _footer.bpb.bps) + Marshal.SizeOf<Footer>() != stream.Length)
if(_footer.bpb.sectors * _footer.bpb.bps + Marshal.SizeOf<Footer>() != stream.Length)
return ErrorNumber.InvalidArgument;
_imageInfo.Cylinders = _footer.bpb.cylinders;
@@ -144,4 +146,6 @@ public sealed partial class DriDiskCopy
return ErrorNumber.NoError;
}
#endregion
}

View File

@@ -36,17 +36,7 @@ namespace Aaru.DiscImages;
public sealed partial class DriDiskCopy
{
[StructLayout(LayoutKind.Sequential, Pack = 1)]
struct Footer
{
/// <summary>Signature: "DiskImage 2.01 (C) 1990,1991 Digital Research Inc\0"</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 51)]
public byte[] signature;
/// <summary>Information about the disk image, mostly imitates FAT BPB</summary>
public Bpb bpb;
/// <summary>Information about the disk image, mostly imitates FAT BPB, copy</summary>
public Bpb bpbcopy;
}
#region Nested type: Bpb
[StructLayout(LayoutKind.Sequential, Pack = 1)]
struct Bpb
@@ -95,4 +85,22 @@ public sealed partial class DriDiskCopy
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 144)]
public byte[] unknown5;
}
#endregion
#region Nested type: Footer
[StructLayout(LayoutKind.Sequential, Pack = 1)]
struct Footer
{
/// <summary>Signature: "DiskImage 2.01 (C) 1990,1991 Digital Research Inc\0"</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 51)]
public byte[] signature;
/// <summary>Information about the disk image, mostly imitates FAT BPB</summary>
public Bpb bpb;
/// <summary>Information about the disk image, mostly imitates FAT BPB, copy</summary>
public Bpb bpbcopy;
}
#endregion
}

View File

@@ -36,6 +36,8 @@ namespace Aaru.DiscImages;
public sealed partial class DriDiskCopy
{
#region IWritableImage Members
/// <inheritdoc />
public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer)
{
@@ -75,4 +77,6 @@ public sealed partial class DriDiskCopy
return ErrorNumber.NotSupported;
}
#endregion
}

View File

@@ -44,9 +44,11 @@ namespace Aaru.DiscImages;
public sealed partial class DriDiskCopy
{
#region IWritableImage Members
/// <inheritdoc />
public bool Create(string path, MediaType mediaType, Dictionary<string, string> options, ulong sectors,
uint sectorSize)
uint sectorSize)
{
if(sectorSize == 0)
{
@@ -217,8 +219,8 @@ public sealed partial class DriDiskCopy
return false;
}
byte[] hdr = new byte[Marshal.SizeOf<Footer>()];
nint hdrPtr = System.Runtime.InteropServices.Marshal.AllocHGlobal(Marshal.SizeOf<Footer>());
var hdr = new byte[Marshal.SizeOf<Footer>()];
nint hdrPtr = System.Runtime.InteropServices.Marshal.AllocHGlobal(Marshal.SizeOf<Footer>());
System.Runtime.InteropServices.Marshal.StructureToPtr(_footer, hdrPtr, true);
System.Runtime.InteropServices.Marshal.Copy(hdrPtr, hdr, 0, hdr.Length);
System.Runtime.InteropServices.Marshal.FreeHGlobal(hdrPtr);
@@ -262,4 +264,6 @@ public sealed partial class DriDiskCopy
/// <inheritdoc />
public bool SetMetadata(Metadata metadata) => false;
#endregion
}