mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
General refactor.
This commit is contained in:
@@ -276,7 +276,7 @@ namespace DiscImageChef.Partitions
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
Partition _partition = new Partition
|
||||
Partition partition = new Partition
|
||||
{
|
||||
Sequence = sequence,
|
||||
Type = StringHandlers.CToString(entry.type),
|
||||
@@ -309,25 +309,25 @@ namespace DiscImageChef.Partitions
|
||||
sb.AppendLine("Partition's boot code is position independent.");
|
||||
}
|
||||
|
||||
_partition.Description = sb.ToString();
|
||||
if(_partition.Start < imagePlugin.Info.Sectors && _partition.End < imagePlugin.Info.Sectors)
|
||||
partition.Description = sb.ToString();
|
||||
if(partition.Start < imagePlugin.Info.Sectors && partition.End < imagePlugin.Info.Sectors)
|
||||
{
|
||||
partitions.Add(_partition);
|
||||
partitions.Add(partition);
|
||||
sequence++;
|
||||
}
|
||||
// Some CD and DVDs end with an Apple_Free that expands beyond the disc size...
|
||||
else if(_partition.Start < imagePlugin.Info.Sectors)
|
||||
else if(partition.Start < imagePlugin.Info.Sectors)
|
||||
{
|
||||
DicConsole.DebugWriteLine("AppleMap Plugin", "Cutting last partition end ({0}) to media size ({1})",
|
||||
_partition.End, imagePlugin.Info.Sectors - 1);
|
||||
_partition.Length = imagePlugin.Info.Sectors - _partition.Start;
|
||||
partitions.Add(_partition);
|
||||
partition.End, imagePlugin.Info.Sectors - 1);
|
||||
partition.Length = imagePlugin.Info.Sectors - partition.Start;
|
||||
partitions.Add(partition);
|
||||
sequence++;
|
||||
}
|
||||
else
|
||||
DicConsole.DebugWriteLine("AppleMap Plugin",
|
||||
"Not adding partition becaus start ({0}) is outside media size ({1})",
|
||||
_partition.Start, imagePlugin.Info.Sectors - 1);
|
||||
partition.Start, imagePlugin.Info.Sectors - 1);
|
||||
}
|
||||
|
||||
return partitions.Count > 0;
|
||||
|
||||
@@ -444,11 +444,9 @@ namespace DiscImageChef.Partitions
|
||||
DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.reserved24 = 0x{0:X8}", rdb.Reserved24);
|
||||
DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.reserved25 = 0x{0:X8}", rdb.Reserved25);
|
||||
|
||||
ulong nextBlock;
|
||||
|
||||
// Reading BadBlock list
|
||||
List<BadBlockList> badBlockChain = new List<BadBlockList>();
|
||||
nextBlock = rdb.BadblockPtr;
|
||||
ulong nextBlock = rdb.BadblockPtr;
|
||||
while(nextBlock != 0xFFFFFFFF)
|
||||
{
|
||||
DicConsole.DebugWriteLine("Amiga RDB plugin", "Going to block {0} in search of a BadBlock block",
|
||||
|
||||
@@ -49,8 +49,7 @@ namespace DiscImageChef.Partitions
|
||||
|
||||
public bool GetInformation(IMediaImage imagePlugin, out List<Partition> partitions, ulong sectorOffset)
|
||||
{
|
||||
partitions = new List<Partition>();
|
||||
|
||||
partitions = null;
|
||||
byte[] sector = imagePlugin.ReadSector(sectorOffset);
|
||||
if(sector.Length < 512) return false;
|
||||
|
||||
@@ -63,23 +62,19 @@ namespace DiscImageChef.Partitions
|
||||
|
||||
ulong counter = 0;
|
||||
|
||||
foreach(Partition part in from entry in table.entries
|
||||
let part = new Partition
|
||||
{
|
||||
Start = entry.offset,
|
||||
Offset = (ulong)(entry.offset * sector.Length),
|
||||
Size = entry.size,
|
||||
Length = (ulong)(entry.size * sector.Length),
|
||||
Type = "Rio Karma",
|
||||
Sequence = counter,
|
||||
Scheme = Name
|
||||
}
|
||||
where entry.type == ENTRY_MAGIC
|
||||
select part)
|
||||
{
|
||||
partitions.Add(part);
|
||||
counter++;
|
||||
}
|
||||
partitions = (from entry in table.entries
|
||||
let part = new Partition
|
||||
{
|
||||
Start = entry.offset,
|
||||
Offset = (ulong)(entry.offset * sector.Length),
|
||||
Size = entry.size,
|
||||
Length = (ulong)(entry.size * sector.Length),
|
||||
Type = "Rio Karma",
|
||||
Sequence = counter++,
|
||||
Scheme = Name
|
||||
}
|
||||
where entry.type == ENTRY_MAGIC
|
||||
select part).ToList();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -51,16 +51,16 @@ namespace DiscImageChef.Partitions
|
||||
public string Name => "XENIX";
|
||||
public Guid Id => new Guid("53BE01DE-E68B-469F-A17F-EC2E4BD61CD9");
|
||||
|
||||
public bool GetInformation(IMediaImage imagePlugin, out List<Partition> partitions, ulong sectorOffset)
|
||||
public bool GetInformation(IMediaImage imagePlugin, out List<CommonTypes.Partition> partitions, ulong sectorOffset)
|
||||
{
|
||||
partitions = new List<Partition>();
|
||||
partitions = new List<CommonTypes.Partition>();
|
||||
|
||||
if(42 + sectorOffset >= imagePlugin.Info.Sectors) return false;
|
||||
|
||||
byte[] tblsector = imagePlugin.ReadSector(42 + sectorOffset);
|
||||
|
||||
GCHandle handle = GCHandle.Alloc(tblsector, GCHandleType.Pinned);
|
||||
partable xnxtbl = (partable)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(partable));
|
||||
Partable xnxtbl = (Partable)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(Partable));
|
||||
handle.Free();
|
||||
|
||||
DicConsole.DebugWriteLine("XENIX plugin", "xnxtbl.p_magic = 0x{0:X4} (should be 0x{1:X4})", xnxtbl.p_magic,
|
||||
@@ -74,7 +74,7 @@ namespace DiscImageChef.Partitions
|
||||
DicConsole.DebugWriteLine("XENIX plugin", "xnxtbl.p[{0}].p_size = {1}", i, xnxtbl.p[i].p_size);
|
||||
if(xnxtbl.p[i].p_size <= 0) continue;
|
||||
|
||||
Partition part = new Partition
|
||||
CommonTypes.Partition part = new CommonTypes.Partition
|
||||
{
|
||||
Start =
|
||||
(ulong)((xnxtbl.p[i].p_off + XENIX_OFFSET) * XENIX_BSIZE) / imagePlugin.Info.SectorSize +
|
||||
@@ -96,14 +96,14 @@ namespace DiscImageChef.Partitions
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
struct partable
|
||||
struct Partable
|
||||
{
|
||||
public ushort p_magic; /* magic number validity indicator */
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = MAXPARTS)] public partition[] p; /*partition headers*/
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = MAXPARTS)] public Partition[] p; /*partition headers*/
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
struct partition
|
||||
struct Partition
|
||||
{
|
||||
public int p_off; /*start 1K block no of partition*/
|
||||
public int p_size; /*# of 1K blocks in partition*/
|
||||
|
||||
Reference in New Issue
Block a user