diff --git a/Aaru.Filesystems/CBM/Structs.cs b/Aaru.Filesystems/CBM/Structs.cs
index 166d763a2..7a8ceff69 100644
--- a/Aaru.Filesystems/CBM/Structs.cs
+++ b/Aaru.Filesystems/CBM/Structs.cs
@@ -27,6 +27,7 @@
// ****************************************************************************/
using System.Runtime.InteropServices;
+using Aaru.CommonTypes.Attributes;
using Aaru.CommonTypes.Interfaces;
using FileAttributes = Aaru.CommonTypes.Structs.FileAttributes;
@@ -39,46 +40,47 @@ public sealed partial class CBM
#region Nested type: BAM
[StructLayout(LayoutKind.Sequential, Pack = 1)]
- readonly struct BAM
+ [SwapEndian]
+ partial struct BAM
{
/// Track where directory starts
- public readonly byte directoryTrack;
+ public byte directoryTrack;
/// Sector where directory starts
- public readonly byte directorySector;
+ public byte directorySector;
/// Disk DOS version, 0x41
- public readonly byte dosVersion;
+ public byte dosVersion;
/// Set to 0x80 if 1571, 0x00 if not
- public readonly byte doubleSided;
+ public byte doubleSided;
/// Block allocation map
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 140)]
- public readonly byte[] bam;
+ public byte[] bam;
/// Disk name
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
- public readonly byte[] name;
+ public byte[] name;
/// Filled with 0xA0
- public readonly ushort fill1;
+ public ushort fill1;
/// Disk ID
- public readonly ushort diskId;
+ public ushort diskId;
/// Filled with 0xA0
- public readonly byte fill2;
+ public byte fill2;
/// DOS type
- public readonly ushort dosType;
+ public ushort dosType;
/// Filled with 0xA0
- public readonly uint fill3;
+ public uint fill3;
/// Unused
- public readonly byte unused1;
+ public byte unused1;
/// Block allocation map for Dolphin DOS extended tracks
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 20)]
- public readonly byte[] dolphinBam;
+ public byte[] dolphinBam;
/// Block allocation map for Speed DOS extended tracks
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 20)]
- public readonly byte[] speedBam;
+ public byte[] speedBam;
/// Unused
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 9)]
- public readonly byte[] unused2;
+ public byte[] unused2;
/// Free sector count for second side in 1571
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 9)]
- public readonly byte[] freeCount;
+ public byte[] freeCount;
}
#endregion
@@ -138,22 +140,23 @@ public sealed partial class CBM
#region Nested type: DirectoryEntry
[StructLayout(LayoutKind.Sequential, Pack = 1)]
- readonly struct DirectoryEntry
+ [SwapEndian]
+ partial struct DirectoryEntry
{
- public readonly byte nextDirBlockTrack;
- public readonly byte nextDirBlockSector;
- public readonly byte fileType;
- public readonly byte firstFileBlockTrack;
- public readonly byte firstFileBlockSector;
+ public byte nextDirBlockTrack;
+ public byte nextDirBlockSector;
+ public byte fileType;
+ public byte firstFileBlockTrack;
+ public byte firstFileBlockSector;
/// Filename
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
- public readonly byte[] name;
- public readonly byte firstSideBlockTrack;
- public readonly byte firstSideBlockSector;
- public readonly uint unused;
- public readonly byte replacementTrack;
- public readonly byte replacementSector;
- public readonly short blocks;
+ public byte[] name;
+ public byte firstSideBlockTrack;
+ public byte firstSideBlockSector;
+ public uint unused;
+ public byte replacementTrack;
+ public byte replacementSector;
+ public short blocks;
}
#endregion
@@ -161,31 +164,32 @@ public sealed partial class CBM
#region Nested type: Header
[StructLayout(LayoutKind.Sequential, Pack = 1)]
- readonly struct Header
+ [SwapEndian]
+ partial struct Header
{
/// Track where directory starts
- public readonly byte directoryTrack;
+ public byte directoryTrack;
/// Sector where directory starts
- public readonly byte directorySector;
+ public byte directorySector;
/// Disk DOS version, 0x44
- public readonly byte diskDosVersion;
+ public byte diskDosVersion;
/// Unusued
- public readonly byte unused1;
+ public byte unused1;
/// Disk name
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
- public readonly byte[] name;
+ public byte[] name;
/// Filled with 0xA0
- public readonly ushort fill1;
+ public ushort fill1;
/// Disk ID
- public readonly ushort diskId;
+ public ushort diskId;
/// Filled with 0xA0
- public readonly byte fill2;
+ public byte fill2;
/// DOS version ('3')
- public readonly byte dosVersion;
+ public byte dosVersion;
/// Disk version ('D')
- public readonly byte diskVersion;
+ public byte diskVersion;
/// Filled with 0xA0
- public readonly short fill3;
+ public short fill3;
}
#endregion
diff --git a/Aaru.Filesystems/CBM/Super.cs b/Aaru.Filesystems/CBM/Super.cs
index a308dce73..1a2e57fb4 100644
--- a/Aaru.Filesystems/CBM/Super.cs
+++ b/Aaru.Filesystems/CBM/Super.cs
@@ -88,7 +88,7 @@ public sealed partial class CBM
if(errno != ErrorNumber.NoError) return errno;
- Header cbmHdr = Marshal.ByteArrayToStructureBigEndian(_diskHeader);
+ Header cbmHdr = Marshal.ByteArrayToStructureBigEndianGenerated(_diskHeader);
if(cbmHdr.diskDosVersion != 0x44 || cbmHdr is not { dosVersion: 0x33, diskVersion: 0x44 })
return ErrorNumber.InvalidArgument;
@@ -126,7 +126,7 @@ public sealed partial class CBM
if(errno != ErrorNumber.NoError) return errno;
- BAM cbmBam = Marshal.ByteArrayToStructureBigEndian(_bam);
+ BAM cbmBam = Marshal.ByteArrayToStructureBigEndianGenerated(_bam);
if(cbmBam is not ({ dosVersion: 0x41, doubleSided : 0x00 or 0x80 }
and { unused1 : 0x00, directoryTrack: 0x12 }))
@@ -143,7 +143,7 @@ public sealed partial class CBM
ulong nextLba = rootLba;
var rootMs = new MemoryStream();
- bool relativeFileWarningShown = false;
+ var relativeFileWarningShown = false;
do
{
@@ -180,7 +180,7 @@ public sealed partial class CBM
// As this filesystem comes in (by nowadays standards) very small sizes, we can cache all files
_cache = new Dictionary();
- int offset = 0;
+ var offset = 0;
ulong fileId = 0;
if(_debug)
@@ -228,7 +228,7 @@ public sealed partial class CBM
while(offset < _root.Length)
{
- DirectoryEntry dirEntry = Marshal.ByteArrayToStructureBigEndian(_root, offset, 32);
+ DirectoryEntry dirEntry = Marshal.ByteArrayToStructureBigEndianGenerated(_root, offset, 32);
if(dirEntry.fileType == 0)
{
@@ -240,10 +240,9 @@ public sealed partial class CBM
_statfs.Files++;
_statfs.FreeFiles--;
- for(int i = 0; i < dirEntry.name.Length; i++)
- {
- if(dirEntry.name[i] == 0xA0) dirEntry.name[i] = 0;
- }
+ for(var i = 0; i < dirEntry.name.Length; i++)
+ if(dirEntry.name[i] == 0xA0)
+ dirEntry.name[i] = 0;
string name = StringHandlers.CToString(dirEntry.name, encoding);