diff --git a/Aaru.Filters/MacBinary.cs b/Aaru.Filters/MacBinary.cs
index 71892681e..f52c73d94 100644
--- a/Aaru.Filters/MacBinary.cs
+++ b/Aaru.Filters/MacBinary.cs
@@ -34,6 +34,7 @@ using System;
using System.IO;
using System.Runtime.InteropServices;
using System.Text;
+using Aaru.CommonTypes.Attributes;
using Aaru.CommonTypes.Enums;
using Aaru.CommonTypes.Interfaces;
using Aaru.Helpers;
@@ -45,7 +46,7 @@ namespace Aaru.Filters;
// TODO: Interpret fdScript
///
/// Decodes MacBinary files
-public sealed class MacBinary : IFilter
+public sealed partial class MacBinary : IFilter
{
const uint MAGIC = 0x6D42494E;
byte[] _bytes;
@@ -55,6 +56,83 @@ public sealed class MacBinary : IFilter
long _rsrcForkOff;
Stream _stream;
+#region Nested type: Header
+
+ [StructLayout(LayoutKind.Sequential, Pack = 1)]
+ [SwapEndian]
+ struct Header
+ {
+ /// 0x00, MacBinary version, 0
+ public byte version;
+ /// 0x01, Str63 Pascal filename
+ [MarshalAs(UnmanagedType.ByValArray, SizeConst = 64)]
+ public byte[] filename;
+ /// 0x41, File type
+ public uint type;
+ /// 0x45, File creator
+ public uint creator;
+ /// 0x49, High byte of Finder flags
+ public byte finderFlags;
+ /// 0x4A, Must be 0
+ public byte zero1;
+ /// 0x4B, File's icon vertical position within its window
+ public ushort verticalPosition;
+ /// 0x4D, File's icon horizontal position within its window
+ public ushort horizontalPosition;
+ /// 0x4F, File's window or folder ID
+ public short windowID;
+ /// 0x51, Protected flag
+ public byte protect;
+ /// 0x52, Must be 0
+ public byte zero2;
+ /// 0x53, Size of data fork
+ public uint dataLength;
+ /// 0x57, Size of resource fork
+ public uint resourceLength;
+ /// 0x5B, File's creation time
+ public uint creationTime;
+ /// 0x5F, File's last modified time
+ public uint modificationTime;
+ /// 0x63, Length of Get Info comment
+ public ushort commentLength;
+ /// 0x65, Low byte of Finder flags
+ public byte finderFlags2;
+
+#region MacBinary III
+
+ /// 0x66, magic identifier, "mBIN"
+ public uint magic;
+ /// 0x6A, fdScript from fxInfo, identifies codepage of filename
+ public byte fdScript;
+ /// 0x6B, fdXFlags from fxInfo, extended Mac OS 8 finder flags
+ public byte fdXFlags;
+
+#endregion MacBinary III
+
+ /// 0x6C, unused
+ public ulong reserved;
+ /// 0x74, Total unpacked files
+ public uint totalPackedFiles;
+
+#region MacBinary II
+
+ /// 0x78, Length of secondary header
+ public ushort secondaryHeaderLength;
+ /// 0x7A, version number of MacBinary that wrote this file, starts at 129
+ public byte version2;
+ /// 0x7B, version number of MacBinary required to open this file, starts at 129
+ public byte minVersion;
+ /// 0x7C, CRC of previous bytes
+ public short crc;
+
+#endregion MacBinary II
+
+ /// 0x7E, Reserved for computer type and OS ID
+ public short computerID;
+ }
+
+#endregion
+
#region IFilter Members
///
@@ -155,7 +233,7 @@ public sealed class MacBinary : IFilter
var hdrB = new byte[128];
Array.Copy(buffer, 0, hdrB, 0, 128);
- _header = Marshal.ByteArrayToStructureBigEndian(hdrB);
+ _header = Marshal.ByteArrayToStructureBigEndianGenerated(hdrB);
return _header.magic == MAGIC ||
_header.version == 0 &&
@@ -174,7 +252,7 @@ public sealed class MacBinary : IFilter
var hdrB = new byte[128];
stream.Seek(0, SeekOrigin.Begin);
stream.EnsureRead(hdrB, 0, 128);
- _header = Marshal.ByteArrayToStructureBigEndian(hdrB);
+ _header = Marshal.ByteArrayToStructureBigEndianGenerated(hdrB);
return _header.magic == MAGIC ||
_header.version == 0 &&
@@ -196,7 +274,7 @@ public sealed class MacBinary : IFilter
var hdrB = new byte[128];
fstream.EnsureRead(hdrB, 0, 128);
- _header = Marshal.ByteArrayToStructureBigEndian(hdrB);
+ _header = Marshal.ByteArrayToStructureBigEndianGenerated(hdrB);
fstream.Close();
@@ -217,7 +295,7 @@ public sealed class MacBinary : IFilter
var hdrB = new byte[128];
ms.EnsureRead(hdrB, 0, 128);
- _header = Marshal.ByteArrayToStructureBigEndian(hdrB);
+ _header = Marshal.ByteArrayToStructureBigEndianGenerated(hdrB);
uint blocks = 1;
blocks += (uint)(_header.secondaryHeaderLength / 128);
@@ -249,7 +327,7 @@ public sealed class MacBinary : IFilter
var hdrB = new byte[128];
stream.EnsureRead(hdrB, 0, 128);
- _header = Marshal.ByteArrayToStructureBigEndian(hdrB);
+ _header = Marshal.ByteArrayToStructureBigEndianGenerated(hdrB);
uint blocks = 1;
blocks += (uint)(_header.secondaryHeaderLength / 128);
@@ -282,7 +360,7 @@ public sealed class MacBinary : IFilter
var hdrB = new byte[128];
fs.EnsureRead(hdrB, 0, 128);
- _header = Marshal.ByteArrayToStructureBigEndian(hdrB);
+ _header = Marshal.ByteArrayToStructureBigEndianGenerated(hdrB);
uint blocks = 1;
blocks += (uint)(_header.secondaryHeaderLength / 128);
@@ -307,81 +385,5 @@ public sealed class MacBinary : IFilter
return ErrorNumber.NoError;
}
-#endregion
-
-#region Nested type: Header
-
- [StructLayout(LayoutKind.Sequential, Pack = 1)]
- struct Header
- {
- /// 0x00, MacBinary version, 0
- public readonly byte version;
- /// 0x01, Str63 Pascal filename
- [MarshalAs(UnmanagedType.ByValArray, SizeConst = 64)]
- public readonly byte[] filename;
- /// 0x41, File type
- public readonly uint type;
- /// 0x45, File creator
- public readonly uint creator;
- /// 0x49, High byte of Finder flags
- public readonly byte finderFlags;
- /// 0x4A, Must be 0
- public readonly byte zero1;
- /// 0x4B, File's icon vertical position within its window
- public readonly ushort verticalPosition;
- /// 0x4D, File's icon horizontal position within its window
- public readonly ushort horizontalPosition;
- /// 0x4F, File's window or folder ID
- public readonly short windowID;
- /// 0x51, Protected flag
- public readonly byte protect;
- /// 0x52, Must be 0
- public readonly byte zero2;
- /// 0x53, Size of data fork
- public readonly uint dataLength;
- /// 0x57, Size of resource fork
- public readonly uint resourceLength;
- /// 0x5B, File's creation time
- public readonly uint creationTime;
- /// 0x5F, File's last modified time
- public readonly uint modificationTime;
- /// 0x63, Length of Get Info comment
- public readonly ushort commentLength;
- /// 0x65, Low byte of Finder flags
- public readonly byte finderFlags2;
-
-#region MacBinary III
-
- /// 0x66, magic identifier, "mBIN"
- public readonly uint magic;
- /// 0x6A, fdScript from fxInfo, identifies codepage of filename
- public readonly byte fdScript;
- /// 0x6B, fdXFlags from fxInfo, extended Mac OS 8 finder flags
- public readonly byte fdXFlags;
-
-#endregion MacBinary III
-
- /// 0x6C, unused
- public readonly ulong reserved;
- /// 0x74, Total unpacked files
- public readonly uint totalPackedFiles;
-
-#region MacBinary II
-
- /// 0x78, Length of secondary header
- public readonly ushort secondaryHeaderLength;
- /// 0x7A, version number of MacBinary that wrote this file, starts at 129
- public readonly byte version2;
- /// 0x7B, version number of MacBinary required to open this file, starts at 129
- public readonly byte minVersion;
- /// 0x7C, CRC of previous bytes
- public readonly short crc;
-
-#endregion MacBinary II
-
- /// 0x7E, Reserved for computer type and OS ID
- public readonly short computerID;
- }
-
#endregion
}
\ No newline at end of file