mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
General cleanup and refactor.
This commit is contained in:
@@ -30,14 +30,14 @@
|
||||
// Copyright © 2011-2022 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
namespace Aaru.DiscImages;
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Aaru.CommonTypes.Enums;
|
||||
using Aaru.CommonTypes.Interfaces;
|
||||
using Aaru.CommonTypes.Structs;
|
||||
|
||||
namespace Aaru.DiscImages;
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>Implements reading and writing Anex-86 disk images</summary>
|
||||
public sealed partial class Anex86 : IWritableImage
|
||||
|
||||
@@ -30,13 +30,13 @@
|
||||
// Copyright © 2011-2022 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
namespace Aaru.DiscImages;
|
||||
|
||||
using System.IO;
|
||||
using Aaru.CommonTypes.Interfaces;
|
||||
using Aaru.Console;
|
||||
using Aaru.Helpers;
|
||||
|
||||
namespace Aaru.DiscImages;
|
||||
|
||||
public sealed partial class Anex86
|
||||
{
|
||||
/// <inheritdoc />
|
||||
@@ -48,7 +48,7 @@ public sealed partial class Anex86
|
||||
if(stream.Length < Marshal.SizeOf<Header>())
|
||||
return false;
|
||||
|
||||
byte[] hdrB = new byte[Marshal.SizeOf<Header>()];
|
||||
var hdrB = new byte[Marshal.SizeOf<Header>()];
|
||||
stream.Read(hdrB, 0, hdrB.Length);
|
||||
|
||||
_header = Marshal.SpanToStructureLittleEndian<Header>(hdrB);
|
||||
|
||||
@@ -30,6 +30,8 @@
|
||||
// Copyright © 2011-2022 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
namespace Aaru.DiscImages;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Aaru.CommonTypes;
|
||||
@@ -37,8 +39,6 @@ using Aaru.CommonTypes.Enums;
|
||||
using Aaru.CommonTypes.Structs;
|
||||
using Schemas;
|
||||
|
||||
namespace Aaru.DiscImages;
|
||||
|
||||
public sealed partial class Anex86
|
||||
{
|
||||
/// <inheritdoc />
|
||||
@@ -47,7 +47,7 @@ public sealed partial class Anex86
|
||||
/// <inheritdoc />
|
||||
public string Name => "Anex86 Disk Image";
|
||||
/// <inheritdoc />
|
||||
public Guid Id => new Guid("0410003E-6E7B-40E6-9328-BA5651ADF6B7");
|
||||
public Guid Id => new("0410003E-6E7B-40E6-9328-BA5651ADF6B7");
|
||||
/// <inheritdoc />
|
||||
public string Author => "Natalia Portillo";
|
||||
/// <inheritdoc />
|
||||
@@ -78,10 +78,9 @@ public sealed partial class Anex86
|
||||
MediaType.ACORN_35_DS_DD, MediaType.DOS_35_DS_DD_8, MediaType.DOS_35_DS_DD_9, MediaType.ACORN_35_DS_HD,
|
||||
MediaType.DOS_525_HD, MediaType.ACORN_525_DS_DD, MediaType.DOS_35_HD, MediaType.XDF_525, MediaType.DMF,
|
||||
MediaType.XDF_35, MediaType.DOS_35_ED, MediaType.FDFORMAT_35_DD, MediaType.FDFORMAT_525_HD,
|
||||
MediaType.FDFORMAT_35_HD, MediaType.NEC_35_TD, MediaType.Unknown, MediaType.GENERIC_HDD,
|
||||
MediaType.FlashDrive, MediaType.CompactFlash, MediaType.CompactFlashType2, MediaType.PCCardTypeI,
|
||||
MediaType.PCCardTypeII, MediaType.PCCardTypeIII, MediaType.PCCardTypeIV, MediaType.MetaFloppy_Mod_I,
|
||||
MediaType.MetaFloppy_Mod_II
|
||||
MediaType.FDFORMAT_35_HD, MediaType.NEC_35_TD, MediaType.Unknown, MediaType.GENERIC_HDD, MediaType.FlashDrive,
|
||||
MediaType.CompactFlash, MediaType.CompactFlashType2, MediaType.PCCardTypeI, MediaType.PCCardTypeII,
|
||||
MediaType.PCCardTypeIII, MediaType.PCCardTypeIV, MediaType.MetaFloppy_Mod_I, MediaType.MetaFloppy_Mod_II
|
||||
};
|
||||
/// <inheritdoc />
|
||||
public IEnumerable<(string name, Type type, string description, object @default)> SupportedOptions =>
|
||||
|
||||
@@ -30,6 +30,8 @@
|
||||
// Copyright © 2011-2022 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
namespace Aaru.DiscImages;
|
||||
|
||||
using System.IO;
|
||||
using Aaru.CommonTypes;
|
||||
using Aaru.CommonTypes.Enums;
|
||||
@@ -37,8 +39,6 @@ using Aaru.CommonTypes.Interfaces;
|
||||
using Aaru.Console;
|
||||
using Aaru.Helpers;
|
||||
|
||||
namespace Aaru.DiscImages;
|
||||
|
||||
public sealed partial class Anex86
|
||||
{
|
||||
/// <inheritdoc />
|
||||
@@ -50,7 +50,7 @@ public sealed partial class Anex86
|
||||
if(stream.Length < Marshal.SizeOf<Header>())
|
||||
return ErrorNumber.InvalidArgument;
|
||||
|
||||
byte[] hdrB = new byte[Marshal.SizeOf<Header>()];
|
||||
var hdrB = new byte[Marshal.SizeOf<Header>()];
|
||||
stream.Read(hdrB, 0, hdrB.Length);
|
||||
|
||||
_header = Marshal.SpanToStructureLittleEndian<Header>(hdrB);
|
||||
@@ -81,8 +81,7 @@ public sealed partial class Anex86
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer) =>
|
||||
ReadSectors(sectorAddress, 1, out buffer);
|
||||
public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer) => ReadSectors(sectorAddress, 1, out buffer);
|
||||
|
||||
/// <inheritdoc />
|
||||
public ErrorNumber ReadSectors(ulong sectorAddress, uint length, out byte[] buffer)
|
||||
@@ -99,7 +98,7 @@ public sealed partial class Anex86
|
||||
|
||||
Stream stream = _anexImageFilter.GetDataForkStream();
|
||||
|
||||
stream.Seek((long)((ulong)_header.hdrSize + (sectorAddress * _imageInfo.SectorSize)), SeekOrigin.Begin);
|
||||
stream.Seek((long)((ulong)_header.hdrSize + sectorAddress * _imageInfo.SectorSize), SeekOrigin.Begin);
|
||||
|
||||
stream.Read(buffer, 0, (int)(length * _imageInfo.SectorSize));
|
||||
|
||||
|
||||
@@ -30,10 +30,10 @@
|
||||
// Copyright © 2011-2022 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Aaru.DiscImages;
|
||||
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
public sealed partial class Anex86
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
|
||||
@@ -30,10 +30,10 @@
|
||||
// Copyright © 2011-2022 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using Aaru.CommonTypes.Enums;
|
||||
|
||||
namespace Aaru.DiscImages;
|
||||
|
||||
using Aaru.CommonTypes.Enums;
|
||||
|
||||
public sealed partial class Anex86
|
||||
{
|
||||
/// <inheritdoc />
|
||||
|
||||
@@ -30,6 +30,8 @@
|
||||
// Copyright © 2011-2022 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
namespace Aaru.DiscImages;
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
@@ -40,8 +42,6 @@ using Aaru.CommonTypes.Structs;
|
||||
using Schemas;
|
||||
using Marshal = Aaru.Helpers.Marshal;
|
||||
|
||||
namespace Aaru.DiscImages;
|
||||
|
||||
public sealed partial class Anex86
|
||||
{
|
||||
/// <inheritdoc />
|
||||
@@ -133,7 +133,7 @@ public sealed partial class Anex86
|
||||
return false;
|
||||
}
|
||||
|
||||
_writingStream.Seek((long)(4096 + (sectorAddress * _imageInfo.SectorSize)), SeekOrigin.Begin);
|
||||
_writingStream.Seek((long)(4096 + sectorAddress * _imageInfo.SectorSize), SeekOrigin.Begin);
|
||||
_writingStream.Write(data, 0, data.Length);
|
||||
|
||||
ErrorMessage = "";
|
||||
@@ -165,7 +165,7 @@ public sealed partial class Anex86
|
||||
return false;
|
||||
}
|
||||
|
||||
_writingStream.Seek((long)(4096 + (sectorAddress * _imageInfo.SectorSize)), SeekOrigin.Begin);
|
||||
_writingStream.Seek((long)(4096 + sectorAddress * _imageInfo.SectorSize), SeekOrigin.Begin);
|
||||
_writingStream.Write(data, 0, data.Length);
|
||||
|
||||
ErrorMessage = "";
|
||||
@@ -229,7 +229,7 @@ public sealed partial class Anex86
|
||||
}
|
||||
}
|
||||
|
||||
byte[] hdr = new byte[Marshal.SizeOf<Header>()];
|
||||
var hdr = new byte[Marshal.SizeOf<Header>()];
|
||||
MemoryMarshal.Write(hdr, ref _header);
|
||||
|
||||
_writingStream.Seek(0, SeekOrigin.Begin);
|
||||
|
||||
Reference in New Issue
Block a user