REFACTOR: Remove unneeded code.

This commit is contained in:
2017-12-21 14:30:38 +00:00
parent 35ce7db892
commit dcd053b20d
343 changed files with 2842 additions and 2588 deletions

View File

@@ -34,7 +34,9 @@ using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text;
using DiscImageChef.CommonTypes;
using DiscImageChef.Console;
using DiscImageChef.DiscImages;
namespace DiscImageChef.Partitions
{
@@ -57,15 +59,15 @@ namespace DiscImageChef.Partitions
PluginUuid = new Guid("36405F8D-4F1A-07F5-209C-223D735D6D22");
}
public override bool GetInformation(DiscImages.ImagePlugin imagePlugin,
out List<CommonTypes.Partition> partitions, ulong sectorOffset)
public override bool GetInformation(ImagePlugin imagePlugin,
out List<Partition> partitions, ulong sectorOffset)
{
uint sector_size;
if(imagePlugin.GetSectorSize() == 2352 || imagePlugin.GetSectorSize() == 2448) sector_size = 2048;
else sector_size = imagePlugin.GetSectorSize();
partitions = new List<CommonTypes.Partition>();
partitions = new List<Partition>();
if(sectorOffset + 2 >= imagePlugin.GetSectors()) return false;
@@ -113,7 +115,7 @@ namespace DiscImageChef.Partitions
if(ddm.sbMap[i].ddSize == 0) continue;
CommonTypes.Partition part = new CommonTypes.Partition
Partition part = new Partition
{
Size = (ulong)(ddm.sbMap[i].ddSize * 512),
Length = (ulong)(ddm.sbMap[i].ddSize * 512 / sector_size),
@@ -158,7 +160,7 @@ namespace DiscImageChef.Partitions
continue;
}
CommonTypes.Partition part = new CommonTypes.Partition
Partition part = new Partition
{
Size = old_entry.pdStart * ddm.sbBlockSize,
Length = old_entry.pdStart * ddm.sbBlockSize / sector_size,
@@ -282,7 +284,7 @@ namespace DiscImageChef.Partitions
StringBuilder sb = new StringBuilder();
CommonTypes.Partition _partition = new CommonTypes.Partition
Partition _partition = new Partition
{
Sequence = sequence,
Type = StringHandlers.CToString(entry.type),

View File

@@ -33,7 +33,10 @@
using System;
using System.Collections.Generic;
using System.Text;
using DiscImageChef.Checksums;
using DiscImageChef.CommonTypes;
using DiscImageChef.Console;
using DiscImageChef.DiscImages;
namespace DiscImageChef.Partitions
{
@@ -58,10 +61,10 @@ namespace DiscImageChef.Partitions
PluginUuid = new Guid("d1dd0f24-ec39-4c4d-9072-be31919a3b5e");
}
public override bool GetInformation(DiscImages.ImagePlugin imagePlugin,
out List<CommonTypes.Partition> partitions, ulong sectorOffset)
public override bool GetInformation(ImagePlugin imagePlugin,
out List<Partition> partitions, ulong sectorOffset)
{
partitions = new List<CommonTypes.Partition>();
partitions = new List<Partition>();
if(imagePlugin.GetSectorSize() < 512) return false;
@@ -99,7 +102,7 @@ namespace DiscImageChef.Partitions
table.badLength = BigEndianBitConverter.ToUInt32(sector, 506);
table.checksum = BigEndianBitConverter.ToUInt16(sector, 510);
Checksums.Sha1Context sha1Ctx = new Checksums.Sha1Context();
Sha1Context sha1Ctx = new Sha1Context();
sha1Ctx.Init();
sha1Ctx.Update(table.boot);
DicConsole.DebugWriteLine("Atari partition plugin", "Boot code SHA1: {0}", sha1Ctx.End());
@@ -169,7 +172,7 @@ namespace DiscImageChef.Partitions
partType[1] = (byte)((type & 0x00FF00) >> 8);
partType[2] = (byte)(type & 0x0000FF);
CommonTypes.Partition part = new CommonTypes.Partition
Partition part = new Partition
{
Size = table.entries[i].length * sectorSize,
Length = table.entries[i].length,
@@ -264,7 +267,7 @@ namespace DiscImageChef.Partitions
partType[1] = (byte)((extendedType & 0x00FF00) >> 8);
partType[2] = (byte)(extendedType & 0x0000FF);
CommonTypes.Partition part = new CommonTypes.Partition
Partition part = new Partition
{
Size = extendedTable.entries[j].length * sectorSize,
Length = extendedTable.entries[j].length,
@@ -345,7 +348,7 @@ namespace DiscImageChef.Partitions
partType[1] = (byte)((type & 0x00FF00) >> 8);
partType[2] = (byte)(type & 0x0000FF);
CommonTypes.Partition part = new CommonTypes.Partition
Partition part = new Partition
{
Size = table.icdEntries[i].length * sectorSize,
Length = table.icdEntries[i].length,

View File

@@ -34,7 +34,9 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using DiscImageChef.CommonTypes;
using DiscImageChef.Console;
using DiscImageChef.DiscImages;
namespace DiscImageChef.Partitions
{
@@ -49,10 +51,10 @@ namespace DiscImageChef.Partitions
PluginUuid = new Guid("CBC9D281-C1D0-44E8-9038-4D66FD2678AB");
}
public override bool GetInformation(DiscImages.ImagePlugin imagePlugin,
out List<CommonTypes.Partition> partitions, ulong sectorOffset)
public override bool GetInformation(ImagePlugin imagePlugin,
out List<Partition> partitions, ulong sectorOffset)
{
partitions = new List<CommonTypes.Partition>();
partitions = new List<Partition>();
if(sectorOffset + 2 >= imagePlugin.GetSectors()) return false;
@@ -65,7 +67,7 @@ namespace DiscImageChef.Partitions
DicConsole.DebugWriteLine("GPT Plugin", "hdr.signature = 0x{0:X16}", signature);
if(signature != GptMagic)
if(imagePlugin.ImageInfo.XmlMediaType == DiscImages.XmlMediaType.OpticalDisc)
if(imagePlugin.ImageInfo.XmlMediaType == XmlMediaType.OpticalDisc)
{
hdrBytes = imagePlugin.ReadSector(sectorOffset);
signature = BitConverter.ToUInt64(hdrBytes, 512);
@@ -162,7 +164,7 @@ namespace DiscImageChef.Partitions
if(entry.startLBA / divisor > imagePlugin.GetSectors() ||
entry.endLBA / divisor > imagePlugin.GetSectors()) return false;
CommonTypes.Partition part = new CommonTypes.Partition
Partition part = new Partition
{
Description = string.Format("ID: {0}", entry.partitionId),
Size = (entry.endLBA - entry.startLBA + 1) * sectorSize,

View File

@@ -36,6 +36,7 @@ using System.Runtime.InteropServices;
using DiscImageChef.CommonTypes;
using DiscImageChef.Console;
using DiscImageChef.DiscImages;
using DiscImageChef.Helpers;
namespace DiscImageChef.Partitions
{
@@ -50,12 +51,12 @@ namespace DiscImageChef.Partitions
PluginUuid = new Guid("5E8A34E8-4F1A-59E6-4BF7-7EA647063A76");
}
public override bool GetInformation(DiscImages.ImagePlugin imagePlugin,
out List<CommonTypes.Partition> partitions, ulong sectorOffset)
public override bool GetInformation(ImagePlugin imagePlugin,
out List<Partition> partitions, ulong sectorOffset)
{
ulong counter = 0;
partitions = new List<CommonTypes.Partition>();
partitions = new List<Partition>();
if(imagePlugin.GetSectorSize() < 512) return false;
@@ -63,7 +64,7 @@ namespace DiscImageChef.Partitions
// Divider of sector size in MBR between real sector size
ulong divider = 1;
if(imagePlugin.ImageInfo.XmlMediaType == DiscImages.XmlMediaType.OpticalDisc)
if(imagePlugin.ImageInfo.XmlMediaType == XmlMediaType.OpticalDisc)
{
sectorSize = 512;
divider = 4;
@@ -149,9 +150,9 @@ namespace DiscImageChef.Partitions
entry.end_head != 0 || entry.end_sector != 0;
if(entry.lba_start == 0 && entry.lba_sectors == 0 && valid)
{
lba_start = Helpers.CHS.ToLBA(start_cylinder, entry.start_head, start_sector,
lba_start = CHS.ToLBA(start_cylinder, entry.start_head, start_sector,
imagePlugin.ImageInfo.Heads, imagePlugin.ImageInfo.SectorsPerTrack);
lba_sectors = Helpers.CHS.ToLBA(end_cylinder, entry.end_head, entry.end_sector,
lba_sectors = CHS.ToLBA(end_cylinder, entry.end_head, entry.end_sector,
imagePlugin.ImageInfo.Heads,
imagePlugin.ImageInfo.SectorsPerTrack) - lba_start;
}
@@ -195,7 +196,7 @@ namespace DiscImageChef.Partitions
if(valid && !minix)
{
CommonTypes.Partition part = new CommonTypes.Partition();
Partition part = new Partition();
if((lba_start > 0 || imagePlugin.ImageInfo.XmlMediaType == XmlMediaType.OpticalDisc) &&
lba_sectors > 0)
{
@@ -274,10 +275,10 @@ namespace DiscImageChef.Partitions
ebr_entry.end_head != 0 || ebr_entry.end_sector != 0;
if(ebr_entry.lba_start == 0 && ebr_entry.lba_sectors == 0 && ext_valid)
{
ext_start = Helpers.CHS.ToLBA(start_cylinder, ebr_entry.start_head, start_sector,
ext_start = CHS.ToLBA(start_cylinder, ebr_entry.start_head, start_sector,
imagePlugin.ImageInfo.Heads,
imagePlugin.ImageInfo.SectorsPerTrack);
ext_sectors = Helpers.CHS.ToLBA(end_cylinder, ebr_entry.end_head, ebr_entry.end_sector,
ext_sectors = CHS.ToLBA(end_cylinder, ebr_entry.end_head, ebr_entry.end_sector,
imagePlugin.ImageInfo.Heads,
imagePlugin.ImageInfo.SectorsPerTrack) - ext_start;
}
@@ -392,9 +393,9 @@ namespace DiscImageChef.Partitions
mnx_entry.end_head != 0 || mnx_entry.end_sector != 0;
if(mnx_entry.lba_start == 0 && mnx_entry.lba_sectors == 0 && mnx_valid)
{
mnx_start = Helpers.CHS.ToLBA(start_cylinder, mnx_entry.start_head, start_sector,
mnx_start = CHS.ToLBA(start_cylinder, mnx_entry.start_head, start_sector,
imagePlugin.ImageInfo.Heads, imagePlugin.ImageInfo.SectorsPerTrack);
mnx_sectors = Helpers.CHS.ToLBA(end_cylinder, mnx_entry.end_head, mnx_entry.end_sector,
mnx_sectors = CHS.ToLBA(end_cylinder, mnx_entry.end_head, mnx_entry.end_sector,
imagePlugin.ImageInfo.Heads,
imagePlugin.ImageInfo.SectorsPerTrack) - mnx_start;
}
@@ -408,7 +409,7 @@ namespace DiscImageChef.Partitions
if(!mnx_valid) continue;
CommonTypes.Partition part = new CommonTypes.Partition();
Partition part = new Partition();
if(mnx_start > 0 && mnx_sectors > 0)
{
part.Start = mnx_start + sectorOffset;

View File

@@ -35,7 +35,9 @@ using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using DiscImageChef.CommonTypes;
using DiscImageChef.Console;
using DiscImageChef.DiscImages;
// Information learnt from XNU source and testing against real disks
namespace DiscImageChef.Partitions
@@ -59,8 +61,8 @@ namespace DiscImageChef.Partitions
PluginUuid = new Guid("246A6D93-4F1A-1F8A-344D-50187A5513A9");
}
public override bool GetInformation(DiscImages.ImagePlugin imagePlugin,
out List<CommonTypes.Partition> partitions, ulong sectorOffset)
public override bool GetInformation(ImagePlugin imagePlugin,
out List<Partition> partitions, ulong sectorOffset)
{
bool magic_found = false;
byte[] label_sector;
@@ -71,7 +73,7 @@ namespace DiscImageChef.Partitions
if(imagePlugin.GetSectorSize() == 2352 || imagePlugin.GetSectorSize() == 2448) sector_size = 2048;
else sector_size = imagePlugin.GetSectorSize();
partitions = new List<CommonTypes.Partition>();
partitions = new List<Partition>();
BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian;
@@ -168,7 +170,7 @@ namespace DiscImageChef.Partitions
StringBuilder sb = new StringBuilder();
CommonTypes.Partition part = new CommonTypes.Partition
Partition part = new Partition
{
Size = (ulong)(label.dl_dt.d_partitions[i].p_size * label.dl_dt.d_secsize),
Offset =

View File

@@ -37,6 +37,7 @@ using System.Text;
using DiscImageChef.CommonTypes;
using DiscImageChef.Console;
using DiscImageChef.DiscImages;
using DiscImageChef.Helpers;
namespace DiscImageChef.Partitions
{
@@ -94,7 +95,7 @@ namespace DiscImageChef.Partitions
Partition part = new Partition
{
Start = Helpers.CHS.ToLBA(entry.dp_scyl, entry.dp_shd, (uint)(entry.dp_ssect + 1),
Start = CHS.ToLBA(entry.dp_scyl, entry.dp_shd, (uint)(entry.dp_ssect + 1),
imagePlugin.ImageInfo.Heads, imagePlugin.ImageInfo.SectorsPerTrack),
Type = DecodePC98Sid(entry.dp_sid),
Name = StringHandlers.CToString(entry.dp_name, Encoding.GetEncoding(932)).Trim(),
@@ -102,7 +103,7 @@ namespace DiscImageChef.Partitions
Scheme = Name
};
part.Offset = part.Start * imagePlugin.GetSectorSize();
part.Length = Helpers.CHS.ToLBA(entry.dp_ecyl, entry.dp_ehd, (uint)(entry.dp_esect + 1),
part.Length = CHS.ToLBA(entry.dp_ecyl, entry.dp_ehd, (uint)(entry.dp_esect + 1),
imagePlugin.ImageInfo.Heads,
imagePlugin.ImageInfo.SectorsPerTrack) - part.Start;
part.Size = part.Length * imagePlugin.GetSectorSize();

View File

@@ -33,6 +33,8 @@
using System;
using System.Collections.Generic;
using DiscImageChef.CommonTypes;
using DiscImageChef.DiscImages;
namespace DiscImageChef.Partitions
{
@@ -46,8 +48,6 @@ namespace DiscImageChef.Partitions
/// <summary>Plugin UUID.</summary>
public Guid PluginUuid;
protected PartitionPlugin() { }
/// <summary>
/// Interprets a partitioning scheme.
/// </summary>
@@ -55,7 +55,7 @@ namespace DiscImageChef.Partitions
/// <param name="imagePlugin">Disk image.</param>
/// <param name="partitions">Returns list of partitions.</param>
/// <param name="sectorOffset">At which sector to start searching for the partition scheme.</param>
public abstract bool GetInformation(DiscImages.ImagePlugin imagePlugin,
out List<CommonTypes.Partition> partitions, ulong sectorOffset);
public abstract bool GetInformation(ImagePlugin imagePlugin,
out List<Partition> partitions, ulong sectorOffset);
}
}

View File

@@ -34,6 +34,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
using DiscImageChef.CommonTypes;
using DiscImageChef.DiscImages;
namespace DiscImageChef.Partitions
{
@@ -50,7 +51,7 @@ namespace DiscImageChef.Partitions
PluginUuid = new Guid("F0BF4FFC-056E-4E7C-8B65-4EAEE250ADD9");
}
public override bool GetInformation(DiscImages.ImagePlugin imagePlugin, out List<Partition> partitions,
public override bool GetInformation(ImagePlugin imagePlugin, out List<Partition> partitions,
ulong sectorOffset)
{
partitions = new List<Partition>();
@@ -59,9 +60,9 @@ namespace DiscImageChef.Partitions
byte[] sector = imagePlugin.ReadSector(sectorOffset + 1);
// While all of Plan9 is supposedly UTF-8, it uses ASCII strcmp for reading its partition table
string[] really = StringHandlers.CToString(sector).Split(new[] {'\n'});
string[] really = StringHandlers.CToString(sector).Split('\n');
foreach(string[] tokens in really.TakeWhile(part => part.Length >= 5 && part.Substring(0, 5) == "part ").Select(part => part.Split(new[] {' '})).TakeWhile(tokens => tokens.Length == 4)) {
foreach(string[] tokens in really.TakeWhile(part => part.Length >= 5 && part.Substring(0, 5) == "part ").Select(part => part.Split(' ')).TakeWhile(tokens => tokens.Length == 4)) {
if(!ulong.TryParse(tokens[2], out ulong start) || !ulong.TryParse(tokens[3], out ulong end)) break;
Partition _part = new Partition

View File

@@ -34,8 +34,10 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DiscImageChef.Checksums;
using DiscImageChef.CommonTypes;
using DiscImageChef.Console;
using DiscImageChef.DiscImages;
namespace DiscImageChef.Partitions
{
@@ -891,10 +893,10 @@ namespace DiscImageChef.Partitions
public byte[] LoadData;
}
public override bool GetInformation(DiscImages.ImagePlugin imagePlugin,
out List<CommonTypes.Partition> partitions, ulong sectorOffset)
public override bool GetInformation(ImagePlugin imagePlugin,
out List<Partition> partitions, ulong sectorOffset)
{
partitions = new List<CommonTypes.Partition>();
partitions = new List<Partition>();
BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian;
ulong rdbBlock = 0;
bool foundRdb = false;
@@ -1323,7 +1325,7 @@ namespace DiscImageChef.Partitions
nextBlock = fshd.Dnode.SeglistPtr;
bool thereAreLoadSegments = false;
Checksums.Sha1Context sha1Ctx = new Checksums.Sha1Context();
Sha1Context sha1Ctx = new Sha1Context();
sha1Ctx.Init();
while(nextBlock != 0xFFFFFFFF)
{
@@ -1371,7 +1373,7 @@ namespace DiscImageChef.Partitions
}
ulong sequence = 0;
foreach(Partition entry in partitionEntries.Select(rdbEntry => new CommonTypes.Partition
foreach(Partition entry in partitionEntries.Select(rdbEntry => new Partition
{
Description = AmigaDosTypeToDescriptionString(rdbEntry.DosEnvVec.DosType),
Name = rdbEntry.DriveName,

View File

@@ -33,7 +33,10 @@
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text;
using DiscImageChef.CommonTypes;
using DiscImageChef.Console;
using DiscImageChef.DiscImages;
namespace DiscImageChef.Partitions
{
@@ -106,10 +109,10 @@ namespace DiscImageChef.Partitions
PluginUuid = new Guid("50F35CC4-8375-4445-8DCB-1BA550C931A3");
}
public override bool GetInformation(DiscImages.ImagePlugin imagePlugin,
out List<CommonTypes.Partition> partitions, ulong sectorOffset)
public override bool GetInformation(ImagePlugin imagePlugin,
out List<Partition> partitions, ulong sectorOffset)
{
partitions = new List<CommonTypes.Partition>();
partitions = new List<Partition>();
if(imagePlugin.GetSectorSize() < 512) return false;
@@ -189,7 +192,7 @@ namespace DiscImageChef.Partitions
for(int i = 0; i < NDKMAP; i++)
if(dkl.dkl_map[i].dkl_cylno > 0 && dkl.dkl_map[i].dkl_nblk > 0)
{
CommonTypes.Partition part = new CommonTypes.Partition
Partition part = new Partition
{
Size = (ulong)dkl.dkl_map[i].dkl_nblk * DK_LABEL_SIZE,
Length = (ulong)(dkl.dkl_map[i].dkl_nblk * DK_LABEL_SIZE / imagePlugin.GetSectorSize()),
@@ -254,7 +257,7 @@ namespace DiscImageChef.Partitions
if(dkl8.dkl_map[i].dkl_nblk > 0 && dkl8.dkl_vtoc.v_part[i].p_tag != SunTag.SunEmpty &&
dkl8.dkl_vtoc.v_part[i].p_tag != SunTag.SunWholeDisk)
{
CommonTypes.Partition part = new CommonTypes.Partition
Partition part = new Partition
{
Description = SunFlagsToString(dkl8.dkl_vtoc.v_part[i].p_flag),
Size = (ulong)dkl8.dkl_map[i].dkl_nblk * DK_LABEL_SIZE,
@@ -322,7 +325,7 @@ namespace DiscImageChef.Partitions
if(dkl16.dkl_vtoc.v_part[i].p_size > 0 && dkl16.dkl_vtoc.v_part[i].p_tag != SunTag.SunEmpty &&
dkl16.dkl_vtoc.v_part[i].p_tag != SunTag.SunWholeDisk)
{
CommonTypes.Partition part = new CommonTypes.Partition
Partition part = new Partition
{
Description = SunFlagsToString(dkl16.dkl_vtoc.v_part[i].p_flag),
Size = (ulong)dkl16.dkl_vtoc.v_part[i].p_size * dkl16.dkl_vtoc.v_sectorsz,
@@ -406,7 +409,7 @@ namespace DiscImageChef.Partitions
public static string SunFlagsToString(SunFlags flags)
{
System.Text.StringBuilder sb = new System.Text.StringBuilder();
StringBuilder sb = new StringBuilder();
if(flags.HasFlag(SunFlags.NoMount)) sb.AppendLine("Unmountable");
if(flags.HasFlag(SunFlags.ReadOnly)) sb.AppendLine("Read-only");
return sb.ToString();

View File

@@ -146,7 +146,7 @@ namespace DiscImageChef.Partitions
{
Description = "Data volume",
Size =
(ulong)imagePlugin.ImageInfo.Sectors * imagePlugin.ImageInfo.SectorSize - MemoryUnitDataOff,
imagePlugin.ImageInfo.Sectors * imagePlugin.ImageInfo.SectorSize - MemoryUnitDataOff,
Length = imagePlugin.ImageInfo.Sectors - sysCachePart.Length,
Sequence = 2,
Offset = MemoryUnitDataOff,