Code cleanup.

This commit is contained in:
2018-06-22 08:08:38 +01:00
parent 82f474c7e3
commit 88da8fc019
581 changed files with 22423 additions and 20839 deletions

View File

@@ -72,19 +72,16 @@ namespace DiscImageChef.Filesystems.UCSDPascal
if(debug && (string.Compare(path, "$", StringComparison.InvariantCulture) == 0 ||
string.Compare(path, "$Boot", StringComparison.InvariantCulture) == 0))
file = string.Compare(path, "$", StringComparison.InvariantCulture) == 0
? catalogBlocks
: bootBlocks;
file = string.Compare(path, "$", StringComparison.InvariantCulture) == 0 ? catalogBlocks : bootBlocks;
else
{
Errno error = GetFileEntry(path, out PascalFileEntry entry);
if(error != Errno.NoError) return error;
byte[] tmp = device.ReadSectors((ulong)entry.FirstBlock * multiplier,
(uint)(entry.LastBlock - entry.FirstBlock) * multiplier);
file = new byte[(entry.LastBlock - entry.FirstBlock - 1) *
device.Info.SectorSize * multiplier +
byte[] tmp = device.ReadSectors((ulong)entry.FirstBlock * multiplier,
(uint)(entry.LastBlock - entry.FirstBlock) * multiplier);
file = new byte[(entry.LastBlock - entry.FirstBlock - 1) * device.Info.SectorSize * multiplier +
entry.LastBytes];
Array.Copy(tmp, 0, file, 0, file.Length);
}
@@ -150,7 +147,7 @@ namespace DiscImageChef.Filesystems.UCSDPascal
GID = 0,
Inode = 0,
LastWriteTimeUtc = DateHandlers.UcsdPascalToDateTime(entry.ModificationTime),
Length = (entry.LastBlock - entry.FirstBlock) * device.Info.SectorSize * multiplier +
Length = (entry.LastBlock - entry.FirstBlock) * device.Info.SectorSize * multiplier +
entry.LastBytes,
Links = 1,
Mode = 0x124,

View File

@@ -59,8 +59,8 @@ namespace DiscImageChef.Filesystems.UCSDPascal
BigEndianBitConverter.IsLittleEndian =
multiplier == 2 ? !BitConverter.IsLittleEndian : BitConverter.IsLittleEndian;
volEntry.FirstBlock = BigEndianBitConverter.ToInt16(volBlock, 0x00);
volEntry.LastBlock = BigEndianBitConverter.ToInt16(volBlock, 0x02);
volEntry.FirstBlock = BigEndianBitConverter.ToInt16(volBlock, 0x00);
volEntry.LastBlock = BigEndianBitConverter.ToInt16(volBlock, 0x02);
volEntry.EntryType = (PascalFileKind)BigEndianBitConverter.ToInt16(volBlock, 0x04);
volEntry.VolumeName = new byte[8];
Array.Copy(volBlock, 0x06, volEntry.VolumeName, 0, 8);
@@ -103,10 +103,10 @@ namespace DiscImageChef.Filesystems.UCSDPascal
public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information,
Encoding encoding)
{
Encoding = encoding ?? new Apple2();
Encoding = encoding ?? new Apple2();
StringBuilder sbInformation = new StringBuilder();
information = "";
multiplier = (uint)(imagePlugin.Info.SectorSize == 256 ? 2 : 1);
information = "";
multiplier = (uint)(imagePlugin.Info.SectorSize == 256 ? 2 : 1);
if(imagePlugin.Info.Sectors < 3) return;
@@ -119,8 +119,8 @@ namespace DiscImageChef.Filesystems.UCSDPascal
BigEndianBitConverter.IsLittleEndian =
multiplier == 2 ? !BitConverter.IsLittleEndian : BitConverter.IsLittleEndian;
volEntry.FirstBlock = BigEndianBitConverter.ToInt16(volBlock, 0x00);
volEntry.LastBlock = BigEndianBitConverter.ToInt16(volBlock, 0x02);
volEntry.FirstBlock = BigEndianBitConverter.ToInt16(volBlock, 0x00);
volEntry.LastBlock = BigEndianBitConverter.ToInt16(volBlock, 0x02);
volEntry.EntryType = (PascalFileKind)BigEndianBitConverter.ToInt16(volBlock, 0x04);
volEntry.VolumeName = new byte[8];
Array.Copy(volBlock, 0x06, volEntry.VolumeName, 0, 8);
@@ -154,7 +154,7 @@ namespace DiscImageChef.Filesystems.UCSDPascal
sbInformation.AppendFormat("Volume name: {0}", StringHandlers.PascalToString(volEntry.VolumeName, Encoding))
.AppendLine();
sbInformation.AppendFormat("Volume has {0} blocks", volEntry.Blocks).AppendLine();
sbInformation.AppendFormat("Volume has {0} files", volEntry.Files).AppendLine();
sbInformation.AppendFormat("Volume has {0} files", volEntry.Files).AppendLine();
sbInformation
.AppendFormat("Volume last booted at {0}", DateHandlers.UcsdPascalToDateTime(volEntry.LastBoot))
.AppendLine();

View File

@@ -46,8 +46,8 @@ namespace DiscImageChef.Filesystems.UCSDPascal
public Errno Mount(IMediaImage imagePlugin, Partition partition, Encoding encoding,
Dictionary<string, string> options)
{
device = imagePlugin;
Encoding = encoding ?? new Apple2();
device = imagePlugin;
Encoding = encoding ?? new Apple2();
if(options == null) options = GetDefaultOptions();
if(options.TryGetValue("debug", out string debugString)) bool.TryParse(debugString, out debug);
if(device.Info.Sectors < 3) return Errno.InvalidArgument;
@@ -61,8 +61,8 @@ namespace DiscImageChef.Filesystems.UCSDPascal
BigEndianBitConverter.IsLittleEndian =
multiplier == 2 ? !BitConverter.IsLittleEndian : BitConverter.IsLittleEndian;
mountedVolEntry.FirstBlock = BigEndianBitConverter.ToInt16(catalogBlocks, 0x00);
mountedVolEntry.LastBlock = BigEndianBitConverter.ToInt16(catalogBlocks, 0x02);
mountedVolEntry.FirstBlock = BigEndianBitConverter.ToInt16(catalogBlocks, 0x00);
mountedVolEntry.LastBlock = BigEndianBitConverter.ToInt16(catalogBlocks, 0x02);
mountedVolEntry.EntryType = (PascalFileKind)BigEndianBitConverter.ToInt16(catalogBlocks, 0x04);
mountedVolEntry.VolumeName = new byte[8];
Array.Copy(catalogBlocks, 0x06, mountedVolEntry.VolumeName, 0, 8);
@@ -75,14 +75,14 @@ namespace DiscImageChef.Filesystems.UCSDPascal
if(mountedVolEntry.FirstBlock != 0 ||
mountedVolEntry.LastBlock <= mountedVolEntry.FirstBlock ||
(ulong)mountedVolEntry.LastBlock > device.Info.Sectors / multiplier - 2 ||
mountedVolEntry.EntryType != PascalFileKind.Volume &&
mountedVolEntry.EntryType != PascalFileKind.Secure ||
mountedVolEntry.VolumeName[0] > 7 ||
mountedVolEntry.Blocks < 0 ||
(ulong)mountedVolEntry.Blocks != device.Info.Sectors / multiplier ||
mountedVolEntry.Files < 0) return Errno.InvalidArgument;
mountedVolEntry.EntryType != PascalFileKind.Volume &&
mountedVolEntry.EntryType != PascalFileKind.Secure || mountedVolEntry.VolumeName[0] > 7 ||
mountedVolEntry.Blocks < 0 ||
(ulong)mountedVolEntry.Blocks != device.Info.Sectors / multiplier ||
mountedVolEntry.Files < 0)
return Errno.InvalidArgument;
catalogBlocks = device.ReadSectors(multiplier * 2,
catalogBlocks = device.ReadSectors(multiplier * 2,
(uint)(mountedVolEntry.LastBlock - mountedVolEntry.FirstBlock - 2) *
multiplier);
int offset = 26;
@@ -93,11 +93,11 @@ namespace DiscImageChef.Filesystems.UCSDPascal
PascalFileEntry entry = new PascalFileEntry
{
Filename = new byte[16],
FirstBlock = BigEndianBitConverter.ToInt16(catalogBlocks, offset + 0x00),
LastBlock = BigEndianBitConverter.ToInt16(catalogBlocks, offset + 0x02),
FirstBlock = BigEndianBitConverter.ToInt16(catalogBlocks, offset + 0x00),
LastBlock = BigEndianBitConverter.ToInt16(catalogBlocks, offset + 0x02),
EntryType = (PascalFileKind)BigEndianBitConverter.ToInt16(catalogBlocks, offset + 0x04),
LastBytes = BigEndianBitConverter.ToInt16(catalogBlocks, offset + 0x16),
ModificationTime = BigEndianBitConverter.ToInt16(catalogBlocks, offset + 0x18)
LastBytes = BigEndianBitConverter.ToInt16(catalogBlocks, offset + 0x16),
ModificationTime = BigEndianBitConverter.ToInt16(catalogBlocks, offset + 0x18)
};
Array.Copy(catalogBlocks, offset + 0x06, entry.Filename, 0, 16);

View File

@@ -76,7 +76,7 @@ namespace DiscImageChef.Filesystems.UCSDPascal
}
public IEnumerable<(string name, Type type, string description)> SupportedOptions =>
new(string name, Type type, string description)[] { };
new (string name, Type type, string description)[] { };
static Dictionary<string, string> GetDefaultOptions()
{