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,6 +30,8 @@
|
||||
// Copyright © 2011-2022 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
namespace Aaru.DiscImages;
|
||||
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@@ -37,8 +39,6 @@ using Aaru.CommonTypes.Interfaces;
|
||||
using Aaru.Console;
|
||||
using Aaru.Helpers;
|
||||
|
||||
namespace Aaru.DiscImages;
|
||||
|
||||
public sealed partial class Nhdr0
|
||||
{
|
||||
/// <inheritdoc />
|
||||
@@ -53,7 +53,7 @@ public sealed partial class Nhdr0
|
||||
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);
|
||||
|
||||
_nhdhdr = Marshal.ByteArrayToStructureLittleEndian<Header>(hdrB);
|
||||
|
||||
@@ -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;
|
||||
|
||||
// Info from http://www.geocities.jp/t98next/nhdr0.txt
|
||||
/// <inheritdoc />
|
||||
/// <summary>Implements reading and writing T98-Next disk images</summary>
|
||||
|
||||
@@ -30,6 +30,8 @@
|
||||
// Copyright © 2011-2022 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
namespace Aaru.DiscImages;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Aaru.CommonTypes;
|
||||
@@ -37,14 +39,12 @@ using Aaru.CommonTypes.Enums;
|
||||
using Aaru.CommonTypes.Structs;
|
||||
using Schemas;
|
||||
|
||||
namespace Aaru.DiscImages;
|
||||
|
||||
public sealed partial class Nhdr0
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public string Name => "T98-Next NHD r0 Disk Image";
|
||||
/// <inheritdoc />
|
||||
public Guid Id => new Guid("6ECACD0A-8F4D-4465-8815-AEA000D370E3");
|
||||
public Guid Id => new("6ECACD0A-8F4D-4465-8815-AEA000D370E3");
|
||||
/// <inheritdoc />
|
||||
public ImageInfo Info => _imageInfo;
|
||||
/// <inheritdoc />
|
||||
|
||||
@@ -30,6 +30,8 @@
|
||||
// Copyright © 2011-2022 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
namespace Aaru.DiscImages;
|
||||
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using Aaru.CommonTypes;
|
||||
@@ -37,8 +39,6 @@ using Aaru.CommonTypes.Enums;
|
||||
using Aaru.CommonTypes.Interfaces;
|
||||
using Aaru.Helpers;
|
||||
|
||||
namespace Aaru.DiscImages;
|
||||
|
||||
public sealed partial class Nhdr0
|
||||
{
|
||||
/// <inheritdoc />
|
||||
@@ -53,7 +53,7 @@ public sealed partial class Nhdr0
|
||||
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);
|
||||
|
||||
_nhdhdr = Marshal.ByteArrayToStructureLittleEndian<Header>(hdrB);
|
||||
@@ -78,8 +78,7 @@ public sealed partial class Nhdr0
|
||||
}
|
||||
|
||||
/// <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)
|
||||
@@ -96,7 +95,7 @@ public sealed partial class Nhdr0
|
||||
|
||||
Stream stream = _nhdImageFilter.GetDataForkStream();
|
||||
|
||||
stream.Seek((long)((ulong)_nhdhdr.dwHeadSize + (sectorAddress * _imageInfo.SectorSize)), SeekOrigin.Begin);
|
||||
stream.Seek((long)((ulong)_nhdhdr.dwHeadSize + 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 Nhdr0
|
||||
{
|
||||
[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 Nhdr0
|
||||
{
|
||||
/// <inheritdoc />
|
||||
|
||||
@@ -30,6 +30,8 @@
|
||||
// Copyright © 2011-2022 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
namespace Aaru.DiscImages;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
@@ -41,8 +43,6 @@ using Aaru.CommonTypes.Structs;
|
||||
using Aaru.Helpers;
|
||||
using Schemas;
|
||||
|
||||
namespace Aaru.DiscImages;
|
||||
|
||||
public sealed partial class Nhdr0
|
||||
{
|
||||
/// <inheritdoc />
|
||||
@@ -119,7 +119,7 @@ public sealed partial class Nhdr0
|
||||
return false;
|
||||
}
|
||||
|
||||
_writingStream.Seek((long)((ulong)Marshal.SizeOf<Header>() + (sectorAddress * _imageInfo.SectorSize)),
|
||||
_writingStream.Seek((long)((ulong)Marshal.SizeOf<Header>() + sectorAddress * _imageInfo.SectorSize),
|
||||
SeekOrigin.Begin);
|
||||
|
||||
_writingStream.Write(data, 0, data.Length);
|
||||
@@ -153,7 +153,7 @@ public sealed partial class Nhdr0
|
||||
return false;
|
||||
}
|
||||
|
||||
_writingStream.Seek((long)((ulong)Marshal.SizeOf<Header>() + (sectorAddress * _imageInfo.SectorSize)),
|
||||
_writingStream.Seek((long)((ulong)Marshal.SizeOf<Header>() + sectorAddress * _imageInfo.SectorSize),
|
||||
SeekOrigin.Begin);
|
||||
|
||||
_writingStream.Write(data, 0, data.Length);
|
||||
@@ -235,7 +235,7 @@ public sealed partial class Nhdr0
|
||||
commentBytes.Length >= 0x100 ? 0x100 : commentBytes.Length);
|
||||
}
|
||||
|
||||
byte[] hdr = new byte[Marshal.SizeOf<Header>()];
|
||||
var hdr = new byte[Marshal.SizeOf<Header>()];
|
||||
IntPtr hdrPtr = System.Runtime.InteropServices.Marshal.AllocHGlobal(Marshal.SizeOf<Header>());
|
||||
System.Runtime.InteropServices.Marshal.StructureToPtr(header, hdrPtr, true);
|
||||
System.Runtime.InteropServices.Marshal.Copy(hdrPtr, hdr, 0, hdr.Length);
|
||||
|
||||
Reference in New Issue
Block a user