diff --git a/Aaru.Filesystems/Opera/Dir.cs b/Aaru.Filesystems/Opera/Dir.cs index 19aa7666f..2fe9a01dd 100644 --- a/Aaru.Filesystems/Opera/Dir.cs +++ b/Aaru.Filesystems/Opera/Dir.cs @@ -171,7 +171,7 @@ public sealed partial class OperaFS if(errno != ErrorNumber.NoError) break; - header = Marshal.ByteArrayToStructureBigEndian(data); + header = Marshal.ByteArrayToStructureBigEndianGenerated(data); nextBlock = header.next_block + firstBlock; var off = (int)header.first_used; @@ -180,7 +180,7 @@ public sealed partial class OperaFS while(off + _directoryEntrySize < data.Length) { - entry = Marshal.ByteArrayToStructureBigEndian(data, off, _directoryEntrySize); + entry = Marshal.ByteArrayToStructureBigEndianGenerated(data, off, _directoryEntrySize); string name = StringHandlers.CToString(entry.name, _encoding); var entryWithPointers = new DirectoryEntryWithPointers diff --git a/Aaru.Filesystems/Opera/Info.cs b/Aaru.Filesystems/Opera/Info.cs index 72a476e00..b90a3d6b6 100644 --- a/Aaru.Filesystems/Opera/Info.cs +++ b/Aaru.Filesystems/Opera/Info.cs @@ -74,7 +74,7 @@ public sealed partial class OperaFS if(errno != ErrorNumber.NoError) return; - SuperBlock sb = Marshal.ByteArrayToStructureBigEndian(sbSector); + SuperBlock sb = Marshal.ByteArrayToStructureBigEndianGenerated(sbSector); if(sb.record_type != 1 || sb.record_version != 1) return; diff --git a/Aaru.Filesystems/Opera/Structs.cs b/Aaru.Filesystems/Opera/Structs.cs index f30494564..5fde9356d 100644 --- a/Aaru.Filesystems/Opera/Structs.cs +++ b/Aaru.Filesystems/Opera/Structs.cs @@ -27,6 +27,7 @@ // ****************************************************************************/ using System.Runtime.InteropServices; +using Aaru.CommonTypes.Attributes; using Aaru.CommonTypes.Interfaces; namespace Aaru.Filesystems; @@ -36,29 +37,30 @@ public sealed partial class OperaFS #region Nested type: DirectoryEntry [StructLayout(LayoutKind.Sequential, Pack = 1)] - readonly struct DirectoryEntry + [SwapEndian] + partial struct DirectoryEntry { /// File flags, see - public readonly uint flags; + public uint flags; /// Unique file identifier - public readonly uint id; + public uint id; /// Entry type - public readonly uint type; + public uint type; /// Block size - public readonly uint block_size; + public uint block_size; /// Size in bytes - public readonly uint byte_count; + public uint byte_count; /// Block count - public readonly uint block_count; + public uint block_count; /// Unknown - public readonly uint burst; + public uint burst; /// Unknown - public readonly uint gap; + public uint gap; /// Filename [MarshalAs(UnmanagedType.ByValArray, SizeConst = MAX_NAME)] - public readonly byte[] name; + public byte[] name; /// Last copy - public readonly uint last_copy; + public uint last_copy; } #endregion @@ -76,18 +78,19 @@ public sealed partial class OperaFS #region Nested type: DirectoryHeader [StructLayout(LayoutKind.Sequential, Pack = 1)] - readonly struct DirectoryHeader + [SwapEndian] + partial struct DirectoryHeader { /// Next block from this directory, -1 if last - public readonly int next_block; + public int next_block; /// Previous block from this directory, -1 if first - public readonly int prev_block; + public int prev_block; /// Directory flags - public readonly uint flags; + public uint flags; /// Offset to first free unused byte in the directory - public readonly uint first_free; + public uint first_free; /// Offset to first directory entry - public readonly uint first_used; + public uint first_used; } #endregion @@ -134,37 +137,38 @@ public sealed partial class OperaFS #region Nested type: SuperBlock [StructLayout(LayoutKind.Sequential, Pack = 1)] - readonly struct SuperBlock + [SwapEndian] + partial struct SuperBlock { /// 0x000, Record type, must be 1 - public readonly byte record_type; + public byte record_type; /// 0x001, 5 bytes, "ZZZZZ" [MarshalAs(UnmanagedType.ByValArray, SizeConst = 5)] - public readonly byte[] sync_bytes; + public byte[] sync_bytes; /// 0x006, Record version, must be 1 - public readonly byte record_version; + public byte record_version; /// 0x007, Volume flags - public readonly byte volume_flags; + public byte volume_flags; /// 0x008, 32 bytes, volume comment [MarshalAs(UnmanagedType.ByValArray, SizeConst = MAX_NAME)] - public readonly byte[] volume_comment; + public byte[] volume_comment; /// 0x028, 32 bytes, volume label [MarshalAs(UnmanagedType.ByValArray, SizeConst = MAX_NAME)] - public readonly byte[] volume_label; + public byte[] volume_label; /// 0x048, Volume ID - public readonly uint volume_id; + public uint volume_id; /// 0x04C, Block size in bytes - public readonly uint block_size; + public uint block_size; /// 0x050, Blocks in volume - public readonly uint block_count; + public uint block_count; /// 0x054, Root directory ID - public readonly uint root_dirid; + public uint root_dirid; /// 0x058, Root directory blocks - public readonly uint rootdir_blocks; + public uint rootdir_blocks; /// 0x05C, Root directory block size - public readonly uint rootdir_bsize; + public uint rootdir_bsize; /// 0x060, Last root directory copy - public readonly uint last_root_copy; + public uint last_root_copy; } #endregion diff --git a/Aaru.Filesystems/Opera/Super.cs b/Aaru.Filesystems/Opera/Super.cs index 54a216de0..86e8993e9 100644 --- a/Aaru.Filesystems/Opera/Super.cs +++ b/Aaru.Filesystems/Opera/Super.cs @@ -57,7 +57,7 @@ public sealed partial class OperaFS if(errno != ErrorNumber.NoError) return errno; - SuperBlock sb = Marshal.ByteArrayToStructureBigEndian(sbSector); + SuperBlock sb = Marshal.ByteArrayToStructureBigEndianGenerated(sbSector); if(sb.record_type != 1 || sb.record_version != 1) return ErrorNumber.InvalidArgument;