mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
[FATX] Use new source generator based big endian marshaller
This commit is contained in:
@@ -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>());
|
||||
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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>());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user