REFACTOR: Reformat code.

This commit is contained in:
2017-12-19 20:33:03 +00:00
parent 77edc7c91c
commit e6f6ace80b
704 changed files with 82627 additions and 83641 deletions

View File

@@ -57,5 +57,4 @@ namespace DiscImageChef.Filesystems.UCSDPascal
Secure
}
}
}
}

View File

@@ -40,9 +40,8 @@ namespace DiscImageChef.Filesystems.UCSDPascal
{
public override Errno ReadDir(string path, ref List<string> contents)
{
if(!mounted)
return Errno.AccessDenied;
if(!mounted) return Errno.AccessDenied;
if(!string.IsNullOrEmpty(path) && string.Compare(path, "/", StringComparison.OrdinalIgnoreCase) != 0)
return Errno.NotSupported;
@@ -60,5 +59,4 @@ namespace DiscImageChef.Filesystems.UCSDPascal
return Errno.NoError;
}
}
}
}

View File

@@ -39,20 +39,17 @@ namespace DiscImageChef.Filesystems.UCSDPascal
{
public override Errno MapBlock(string path, long fileBlock, ref long deviceBlock)
{
if(!mounted)
return Errno.AccessDenied;
if(!mounted) return Errno.AccessDenied;
return Errno.NotImplemented;
}
public override Errno GetAttributes(string path, ref FileAttributes attributes)
{
if(!mounted)
return Errno.AccessDenied;
if(!mounted) return Errno.AccessDenied;
string[] pathElements = path.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
if(pathElements.Length != 1)
return Errno.NotSupported;
string[] pathElements = path.Split(new char[] {'/'}, StringSplitOptions.RemoveEmptyEntries);
if(pathElements.Length != 1) return Errno.NotSupported;
PascalFileEntry entry;
Errno error = GetFileEntry(path, out entry);
@@ -68,43 +65,35 @@ namespace DiscImageChef.Filesystems.UCSDPascal
public override Errno Read(string path, long offset, long size, ref byte[] buf)
{
if(!mounted)
return Errno.AccessDenied;
if(!mounted) return Errno.AccessDenied;
string[] pathElements = path.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
if(pathElements.Length != 1)
return Errno.NotSupported;
string[] pathElements = path.Split(new char[] {'/'}, StringSplitOptions.RemoveEmptyEntries);
if(pathElements.Length != 1) return Errno.NotSupported;
byte[] file;
Errno error;
if(debug &&
(string.Compare(path, "$", StringComparison.InvariantCulture) == 0
|| string.Compare(path, "$Boot", StringComparison.InvariantCulture) == 0))
if(debug && (string.Compare(path, "$", StringComparison.InvariantCulture) == 0 ||
string.Compare(path, "$Boot", StringComparison.InvariantCulture) == 0))
{
if(string.Compare(path, "$", StringComparison.InvariantCulture) == 0)
file = catalogBlocks;
else
file = bootBlocks;
if(string.Compare(path, "$", StringComparison.InvariantCulture) == 0) file = catalogBlocks;
else file = bootBlocks;
}
else
{
PascalFileEntry entry;
error = GetFileEntry(path, out entry);
if(error != Errno.NoError)
return error;
if(error != Errno.NoError) return error;
byte[] tmp = device.ReadSectors((ulong)entry.firstBlock, (uint)(entry.lastBlock - entry.firstBlock));
file = new byte[(entry.lastBlock - entry.firstBlock - 1) * device.GetSectorSize() + entry.lastBytes];
Array.Copy(tmp, 0, file, 0, file.Length);
}
if(offset >= file.Length)
return Errno.EINVAL;
if(offset >= file.Length) return Errno.EINVAL;
if(size + offset >= file.Length)
size = file.Length - offset;
if(size + offset >= file.Length) size = file.Length - offset;
buf = new byte[size];
@@ -115,15 +104,12 @@ namespace DiscImageChef.Filesystems.UCSDPascal
public override Errno Stat(string path, ref FileEntryInfo stat)
{
if(!mounted)
return Errno.AccessDenied;
if(!mounted) return Errno.AccessDenied;
if(!mounted)
return Errno.AccessDenied;
if(!mounted) return Errno.AccessDenied;
string[] pathElements = path.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
if(pathElements.Length != 1)
return Errno.NotSupported;
string[] pathElements = path.Split(new char[] {'/'}, StringSplitOptions.RemoveEmptyEntries);
if(pathElements.Length != 1) return Errno.NotSupported;
if(debug)
{
@@ -159,8 +145,7 @@ namespace DiscImageChef.Filesystems.UCSDPascal
PascalFileEntry entry;
Errno error = GetFileEntry(path, out entry);
if(error != Errno.NoError)
return error;
if(error != Errno.NoError) return error;
stat = new FileEntryInfo();
stat.Attributes = new FileAttributes();
@@ -185,7 +170,8 @@ namespace DiscImageChef.Filesystems.UCSDPascal
foreach(PascalFileEntry ent in fileEntries)
{
if(string.Compare(path, StringHandlers.PascalToString(ent.filename, CurrentEncoding), StringComparison.InvariantCultureIgnoreCase) == 0)
if(string.Compare(path, StringHandlers.PascalToString(ent.filename, CurrentEncoding),
StringComparison.InvariantCultureIgnoreCase) == 0)
{
entry = ent;
return Errno.NoError;
@@ -195,5 +181,4 @@ namespace DiscImageChef.Filesystems.UCSDPascal
return Errno.NoSuchFile;
}
}
}
}

View File

@@ -41,8 +41,7 @@ namespace DiscImageChef.Filesystems.UCSDPascal
{
public override bool Identify(ImagePlugins.ImagePlugin imagePlugin, Partition partition)
{
if(partition.Length < 3)
return false;
if(partition.Length < 3) return false;
// Blocks 0 and 1 are boot code
byte[] volBlock = imagePlugin.ReadSector(2 + partition.Start);
@@ -63,39 +62,34 @@ namespace DiscImageChef.Filesystems.UCSDPascal
volEntry.tail = BigEndianBitConverter.ToInt32(volBlock, 0x16);
// First block is always 0 (even is it's sector 2)
if(volEntry.firstBlock != 0)
return false;
if(volEntry.firstBlock != 0) return false;
// Last volume record block must be after first block, and before end of device
if(volEntry.lastBlock <= volEntry.firstBlock || (ulong)volEntry.lastBlock > imagePlugin.GetSectors() - 2)
return false;
if(volEntry.lastBlock <= volEntry.firstBlock ||
(ulong)volEntry.lastBlock > imagePlugin.GetSectors() - 2) return false;
// Volume record entry type must be volume or secure
if(volEntry.entryType != PascalFileKind.Volume && volEntry.entryType != PascalFileKind.Secure)
return false;
if(volEntry.entryType != PascalFileKind.Volume && volEntry.entryType != PascalFileKind.Secure) return false;
// Volume name is max 7 characters
if(volEntry.volumeName[0] > 7)
return false;
if(volEntry.volumeName[0] > 7) return false;
// Volume blocks is equal to volume sectors
if(volEntry.blocks < 0 || (ulong)volEntry.blocks != imagePlugin.GetSectors())
return false;
if(volEntry.blocks < 0 || (ulong)volEntry.blocks != imagePlugin.GetSectors()) return false;
// There can be not less than zero files
if(volEntry.files < 0)
return false;
if(volEntry.files < 0) return false;
return true;
}
public override void GetInformation(ImagePlugins.ImagePlugin imagePlugin, Partition partition, out string information)
public override void GetInformation(ImagePlugins.ImagePlugin imagePlugin, Partition partition,
out string information)
{
StringBuilder sbInformation = new StringBuilder();
information = "";
if(imagePlugin.GetSectors() < 3)
return;
if(imagePlugin.GetSectors() < 3) return;
// Blocks 0 and 1 are boot code
byte[] volBlock = imagePlugin.ReadSector(2 + partition.Start);
@@ -116,34 +110,34 @@ namespace DiscImageChef.Filesystems.UCSDPascal
volEntry.tail = BigEndianBitConverter.ToInt32(volBlock, 0x16);
// First block is always 0 (even is it's sector 2)
if(volEntry.firstBlock != 0)
return;
if(volEntry.firstBlock != 0) return;
// Last volume record block must be after first block, and before end of device
if(volEntry.lastBlock <= volEntry.firstBlock || (ulong)volEntry.lastBlock > imagePlugin.GetSectors() - 2)
return;
if(volEntry.lastBlock <= volEntry.firstBlock ||
(ulong)volEntry.lastBlock > imagePlugin.GetSectors() - 2) return;
// Volume record entry type must be volume or secure
if(volEntry.entryType != PascalFileKind.Volume && volEntry.entryType != PascalFileKind.Secure)
return;
if(volEntry.entryType != PascalFileKind.Volume && volEntry.entryType != PascalFileKind.Secure) return;
// Volume name is max 7 characters
if(volEntry.volumeName[0] > 7)
return;
if(volEntry.volumeName[0] > 7) return;
// Volume blocks is equal to volume sectors
if(volEntry.blocks < 0 || (ulong)volEntry.blocks != imagePlugin.GetSectors())
return;
if(volEntry.blocks < 0 || (ulong)volEntry.blocks != imagePlugin.GetSectors()) return;
// There can be not less than zero files
if(volEntry.files < 0)
return;
if(volEntry.files < 0) return;
sbInformation.AppendFormat("Volume record spans from block {0} to block {1}", volEntry.firstBlock, volEntry.lastBlock).AppendLine();
sbInformation.AppendFormat("Volume name: {0}", StringHandlers.PascalToString(volEntry.volumeName, CurrentEncoding)).AppendLine();
sbInformation.AppendFormat("Volume record spans from block {0} to block {1}", volEntry.firstBlock,
volEntry.lastBlock).AppendLine();
sbInformation.AppendFormat("Volume name: {0}",
StringHandlers.PascalToString(volEntry.volumeName, CurrentEncoding))
.AppendLine();
sbInformation.AppendFormat("Volume has {0} blocks", volEntry.blocks).AppendLine();
sbInformation.AppendFormat("Volume has {0} files", volEntry.files).AppendLine();
sbInformation.AppendFormat("Volume last booted at {0}", DateHandlers.UCSDPascalToDateTime(volEntry.lastBoot)).AppendLine();
sbInformation
.AppendFormat("Volume last booted at {0}", DateHandlers.UCSDPascalToDateTime(volEntry.lastBoot))
.AppendLine();
information = sbInformation.ToString();
@@ -159,5 +153,4 @@ namespace DiscImageChef.Filesystems.UCSDPascal
return;
}
}
}
}

View File

@@ -73,5 +73,4 @@ namespace DiscImageChef.Filesystems.UCSDPascal
public short mtime;
}
}
}
}

View File

@@ -46,8 +46,7 @@ namespace DiscImageChef.Filesystems.UCSDPascal
public override Errno Mount(bool debug)
{
this.debug = debug;
if(device.GetSectors() < 3)
return Errno.InvalidArgument;
if(device.GetSectors() < 3) return Errno.InvalidArgument;
// Blocks 0 and 1 are boot code
catalogBlocks = device.ReadSector(2);
@@ -67,10 +66,10 @@ namespace DiscImageChef.Filesystems.UCSDPascal
if(mountedVolEntry.firstBlock != 0 || mountedVolEntry.lastBlock <= mountedVolEntry.firstBlock ||
(ulong)mountedVolEntry.lastBlock > device.GetSectors() - 2 ||
(mountedVolEntry.entryType != PascalFileKind.Volume && mountedVolEntry.entryType != PascalFileKind.Secure) ||
mountedVolEntry.volumeName[0] > 7 || mountedVolEntry.blocks < 0 || (ulong)mountedVolEntry.blocks != device.GetSectors() ||
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.GetSectors() ||
mountedVolEntry.files < 0) return Errno.InvalidArgument;
catalogBlocks = device.ReadSectors(2, (uint)(mountedVolEntry.lastBlock - mountedVolEntry.firstBlock - 2));
int offset = 26;
@@ -87,8 +86,7 @@ namespace DiscImageChef.Filesystems.UCSDPascal
entry.lastBytes = BigEndianBitConverter.ToInt16(catalogBlocks, offset + 0x16);
entry.mtime = BigEndianBitConverter.ToInt16(catalogBlocks, offset + 0x18);
if(entry.filename[0] <= 15 && entry.filename[0] > 0)
fileEntries.Add(entry);
if(entry.filename[0] <= 15 && entry.filename[0] > 0) fileEntries.Add(entry);
offset += 26;
}
@@ -127,11 +125,9 @@ namespace DiscImageChef.Filesystems.UCSDPascal
stat.Type = "UCSD Pascal";
stat.FreeBlocks = mountedVolEntry.blocks - (mountedVolEntry.lastBlock - mountedVolEntry.firstBlock);
foreach(PascalFileEntry entry in fileEntries)
stat.FreeBlocks -= (entry.lastBlock - entry.firstBlock);
foreach(PascalFileEntry entry in fileEntries) stat.FreeBlocks -= (entry.lastBlock - entry.firstBlock);
return Errno.NotImplemented;
}
}
}
}

View File

@@ -89,5 +89,4 @@ namespace DiscImageChef.Filesystems.UCSDPascal
return Errno.NotSupported;
}
}
}
}