[FATX] Use new source generator based big endian marshaller

This commit is contained in:
2025-10-21 02:55:33 +01:00
parent 6ededddb2c
commit 6f787002fc
4 changed files with 26 additions and 23 deletions

View File

@@ -130,7 +130,7 @@ public sealed partial class XboxFatPlugin
? Marshal.ByteArrayToStructureLittleEndian<DirectoryEntry>(directoryBuffer,
pos,
Marshal.SizeOf<DirectoryEntry>())
: Marshal.ByteArrayToStructureBigEndian<DirectoryEntry>(directoryBuffer,
: Marshal.ByteArrayToStructureBigEndianGenerated<DirectoryEntry>(directoryBuffer,
pos,
Marshal.SizeOf<DirectoryEntry>());

View File

@@ -48,7 +48,7 @@ public sealed partial class XboxFatPlugin
if(errno != ErrorNumber.NoError) return false;
Superblock sb = Marshal.ByteArrayToStructureBigEndian<Superblock>(sector);
Superblock sb = Marshal.ByteArrayToStructureBigEndianGenerated<Superblock>(sector);
return sb.magic is FATX_MAGIC or FATX_CIGAM;
}
@@ -68,7 +68,7 @@ public sealed partial class XboxFatPlugin
if(errno != ErrorNumber.NoError) return;
Superblock fatxSb = Marshal.ByteArrayToStructureBigEndian<Superblock>(sector);
Superblock fatxSb = Marshal.ByteArrayToStructureBigEndianGenerated<Superblock>(sector);
if(fatxSb.magic == FATX_CIGAM)
{

View File

@@ -27,6 +27,7 @@
// ****************************************************************************/
using System.Runtime.InteropServices;
using Aaru.CommonTypes.Attributes;
using Aaru.CommonTypes.Interfaces;
namespace Aaru.Filesystems;
@@ -36,20 +37,21 @@ public sealed partial class XboxFatPlugin
#region Nested type: DirectoryEntry
[StructLayout(LayoutKind.Sequential, Pack = 1)]
readonly struct DirectoryEntry
[SwapEndian]
partial struct DirectoryEntry
{
public readonly byte filenameSize;
public readonly Attributes attributes;
public byte filenameSize;
public Attributes attributes;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = MAX_FILENAME)]
public readonly byte[] filename;
public readonly uint firstCluster;
public readonly uint length;
public readonly ushort lastWrittenTime;
public readonly ushort lastWrittenDate;
public readonly ushort lastAccessTime;
public readonly ushort lastAccessDate;
public readonly ushort creationTime;
public readonly ushort creationDate;
public byte[] filename;
public uint firstCluster;
public uint length;
public ushort lastWrittenTime;
public ushort lastWrittenDate;
public ushort lastAccessTime;
public ushort lastAccessDate;
public ushort creationTime;
public ushort creationDate;
}
#endregion
@@ -96,16 +98,17 @@ public sealed partial class XboxFatPlugin
#region Nested type: Superblock
[StructLayout(LayoutKind.Sequential, Pack = 1)]
readonly struct Superblock
[SwapEndian]
partial struct Superblock
{
public readonly uint magic;
public readonly uint id;
public readonly uint sectorsPerCluster;
public readonly uint rootDirectoryCluster;
public uint magic;
public uint id;
public uint sectorsPerCluster;
public uint rootDirectoryCluster;
// TODO: Undetermined size
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
public readonly byte[] volumeLabel;
public byte[] volumeLabel;
}
#endregion

View File

@@ -69,7 +69,7 @@ public sealed partial class XboxFatPlugin
if(_superblock.magic == FATX_CIGAM)
{
_superblock = Marshal.ByteArrayToStructureBigEndian<Superblock>(sector);
_superblock = Marshal.ByteArrayToStructureBigEndianGenerated<Superblock>(sector);
_littleEndian = false;
}
@@ -233,7 +233,7 @@ public sealed partial class XboxFatPlugin
? Marshal.ByteArrayToStructureLittleEndian<DirectoryEntry>(rootDirectoryBuffer,
pos,
Marshal.SizeOf<DirectoryEntry>())
: Marshal.ByteArrayToStructureBigEndian<DirectoryEntry>(rootDirectoryBuffer,
: Marshal.ByteArrayToStructureBigEndianGenerated<DirectoryEntry>(rootDirectoryBuffer,
pos,
Marshal.SizeOf<DirectoryEntry>());