mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
General cleanup and refactor.
This commit is contained in:
@@ -30,6 +30,8 @@
|
||||
// Copyright © 2011-2022 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
namespace Aaru.Filesystems;
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
@@ -41,8 +43,6 @@ using Aaru.Helpers;
|
||||
using Schemas;
|
||||
using Marshal = Aaru.Helpers.Marshal;
|
||||
|
||||
namespace Aaru.Filesystems;
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>Implements detection of SGI's XFS</summary>
|
||||
public sealed class XFS : IFilesystem
|
||||
@@ -69,7 +69,7 @@ public sealed class XFS : IFilesystem
|
||||
// Misaligned
|
||||
if(imagePlugin.Info.XmlMediaType == XmlMediaType.OpticalDisc)
|
||||
{
|
||||
uint sbSize = (uint)((Marshal.SizeOf<Superblock>() + 0x400) / imagePlugin.Info.SectorSize);
|
||||
var sbSize = (uint)((Marshal.SizeOf<Superblock>() + 0x400) / imagePlugin.Info.SectorSize);
|
||||
|
||||
if((Marshal.SizeOf<Superblock>() + 0x400) % imagePlugin.Info.SectorSize != 0)
|
||||
sbSize++;
|
||||
@@ -82,7 +82,7 @@ public sealed class XFS : IFilesystem
|
||||
if(sector.Length < Marshal.SizeOf<Superblock>())
|
||||
return false;
|
||||
|
||||
byte[] sbpiece = new byte[Marshal.SizeOf<Superblock>()];
|
||||
var sbpiece = new byte[Marshal.SizeOf<Superblock>()];
|
||||
|
||||
foreach(int location in new[]
|
||||
{
|
||||
@@ -93,8 +93,8 @@ public sealed class XFS : IFilesystem
|
||||
|
||||
Superblock xfsSb = Marshal.ByteArrayToStructureBigEndian<Superblock>(sbpiece);
|
||||
|
||||
AaruConsole.DebugWriteLine("XFS plugin", "magic at 0x{0:X3} = 0x{1:X8} (expected 0x{2:X8})",
|
||||
location, xfsSb.magicnum, XFS_MAGIC);
|
||||
AaruConsole.DebugWriteLine("XFS plugin", "magic at 0x{0:X3} = 0x{1:X8} (expected 0x{2:X8})", location,
|
||||
xfsSb.magicnum, XFS_MAGIC);
|
||||
|
||||
if(xfsSb.magicnum == XFS_MAGIC)
|
||||
return true;
|
||||
@@ -106,9 +106,9 @@ public sealed class XFS : IFilesystem
|
||||
0, 1, 2
|
||||
})
|
||||
{
|
||||
ulong location = (ulong)i;
|
||||
var location = (ulong)i;
|
||||
|
||||
uint sbSize = (uint)(Marshal.SizeOf<Superblock>() / imagePlugin.Info.SectorSize);
|
||||
var sbSize = (uint)(Marshal.SizeOf<Superblock>() / imagePlugin.Info.SectorSize);
|
||||
|
||||
if(Marshal.SizeOf<Superblock>() % imagePlugin.Info.SectorSize != 0)
|
||||
sbSize++;
|
||||
@@ -134,8 +134,7 @@ public sealed class XFS : IFilesystem
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information,
|
||||
Encoding encoding)
|
||||
public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, Encoding encoding)
|
||||
{
|
||||
Encoding = encoding ?? Encoding.GetEncoding("iso-8859-15");
|
||||
information = "";
|
||||
@@ -148,7 +147,7 @@ public sealed class XFS : IFilesystem
|
||||
// Misaligned
|
||||
if(imagePlugin.Info.XmlMediaType == XmlMediaType.OpticalDisc)
|
||||
{
|
||||
uint sbSize = (uint)((Marshal.SizeOf<Superblock>() + 0x400) / imagePlugin.Info.SectorSize);
|
||||
var sbSize = (uint)((Marshal.SizeOf<Superblock>() + 0x400) / imagePlugin.Info.SectorSize);
|
||||
|
||||
if((Marshal.SizeOf<Superblock>() + 0x400) % imagePlugin.Info.SectorSize != 0)
|
||||
sbSize++;
|
||||
@@ -159,7 +158,7 @@ public sealed class XFS : IFilesystem
|
||||
sector.Length < Marshal.SizeOf<Superblock>())
|
||||
return;
|
||||
|
||||
byte[] sbpiece = new byte[Marshal.SizeOf<Superblock>()];
|
||||
var sbpiece = new byte[Marshal.SizeOf<Superblock>()];
|
||||
|
||||
foreach(int location in new[]
|
||||
{
|
||||
@@ -170,8 +169,8 @@ public sealed class XFS : IFilesystem
|
||||
|
||||
xfsSb = Marshal.ByteArrayToStructureBigEndian<Superblock>(sbpiece);
|
||||
|
||||
AaruConsole.DebugWriteLine("XFS plugin", "magic at 0x{0:X3} = 0x{1:X8} (expected 0x{2:X8})",
|
||||
location, xfsSb.magicnum, XFS_MAGIC);
|
||||
AaruConsole.DebugWriteLine("XFS plugin", "magic at 0x{0:X3} = 0x{1:X8} (expected 0x{2:X8})", location,
|
||||
xfsSb.magicnum, XFS_MAGIC);
|
||||
|
||||
if(xfsSb.magicnum == XFS_MAGIC)
|
||||
break;
|
||||
@@ -183,8 +182,8 @@ public sealed class XFS : IFilesystem
|
||||
0, 1, 2
|
||||
})
|
||||
{
|
||||
ulong location = (ulong)i;
|
||||
uint sbSize = (uint)(Marshal.SizeOf<Superblock>() / imagePlugin.Info.SectorSize);
|
||||
var location = (ulong)i;
|
||||
var sbSize = (uint)(Marshal.SizeOf<Superblock>() / imagePlugin.Info.SectorSize);
|
||||
|
||||
if(Marshal.SizeOf<Superblock>() % imagePlugin.Info.SectorSize != 0)
|
||||
sbSize++;
|
||||
|
||||
Reference in New Issue
Block a user