General cleanup and refactor.

This commit is contained in:
2022-03-07 07:36:44 +00:00
parent bc6e432565
commit 762e3eb6d2
1321 changed files with 44657 additions and 45479 deletions

View File

@@ -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++;