REFACTOR: Remove redundant parentheses.

This commit is contained in:
2017-12-20 17:26:28 +00:00
parent a4650c61aa
commit b0936d51c5
160 changed files with 1096 additions and 1106 deletions

View File

@@ -110,7 +110,7 @@ namespace DiscImageChef.Filesystems.CPM
else if(entry.statusUser == 0x21)
{
if(directory[off + 1] == 0x00) { thirdPartyTimestamps = true; }
else standardTimestamps |= (directory[off + 21] == 0x00 && directory[off + 31] == 0x00);
else standardTimestamps |= directory[off + 21] == 0x00 && directory[off + 31] == 0x00;
}
}

View File

@@ -194,9 +194,9 @@ namespace DiscImageChef.Filesystems.CPM
Marshal.FreeHGlobal(amsPtr);
// Check that format byte and sidedness indicate the same number of sizes
if((amsSb.format == 0 && (amsSb.sidedness & 0x02) == 0) ||
(amsSb.format == 2 && (amsSb.sidedness & 0x02) == 1) ||
(amsSb.format == 2 && (amsSb.sidedness & 0x02) == 2))
if(amsSb.format == 0 && (amsSb.sidedness & 0x02) == 0 ||
amsSb.format == 2 && (amsSb.sidedness & 0x02) == 1 ||
amsSb.format == 2 && (amsSb.sidedness & 0x02) == 2)
{
// Calculate device limits
sides = (ulong)(amsSb.format == 0 ? 1 : 2);
@@ -207,7 +207,7 @@ namespace DiscImageChef.Filesystems.CPM
if(sectorSize == imagePlugin.GetSectorSize() && sectorCount == imagePlugin.GetSectors())
{
cpmFound = true;
firstDirectorySector = (ulong)((amsSb.off * amsSb.spt));
firstDirectorySector = (ulong)(amsSb.off * amsSb.spt);
// Build a DiscParameterBlock
dpb = new DiscParameterBlock();
@@ -233,7 +233,7 @@ namespace DiscImageChef.Filesystems.CPM
for(int i = 0; i < dpb.psh; i++) dpb.phm += (byte)Math.Pow(2, i);
dpb.spt = (ushort)(amsSb.spt * (sectorSize / 128));
uint directoryLength = (uint)((((ulong)dpb.drm + 1) * 32) / sectorSize);
uint directoryLength = (uint)(((ulong)dpb.drm + 1) * 32 / sectorSize);
directory = imagePlugin.ReadSectors(firstDirectorySector + partition.Start,
directoryLength);
@@ -314,7 +314,7 @@ namespace DiscImageChef.Filesystems.CPM
sectorsInPartition + partition.Start <= partition.End)
{
cpmFound = true;
firstDirectorySector = (ulong)((hddSb.off * hddSb.sectorsPerTrack));
firstDirectorySector = (ulong)(hddSb.off * hddSb.sectorsPerTrack);
// Build a DiscParameterBlock
dpb = new DiscParameterBlock();
@@ -330,7 +330,7 @@ namespace DiscImageChef.Filesystems.CPM
dpb.phm = 0; // Needed?
dpb.psh = 0; // Needed?
dpb.spt = hddSb.spt;
uint directoryLength = (uint)((((ulong)dpb.drm + 1) * 32) / sectorSize);
uint directoryLength = (uint)(((ulong)dpb.drm + 1) * 32 / sectorSize);
directory = imagePlugin.ReadSectors(firstDirectorySector + partition.Start,
directoryLength);
DicConsole.DebugWriteLine("CP/M Plugin", "Found CP/M-86 hard disk superblock.");
@@ -760,7 +760,7 @@ namespace DiscImageChef.Filesystems.CPM
if(cpmFound)
{
uint directoryLength = (uint)((((ulong)dpb.drm + 1) * 32) / imagePlugin.GetSectorSize());
uint directoryLength = (uint)(((ulong)dpb.drm + 1) * 32 / imagePlugin.GetSectorSize());
directory = imagePlugin.ReadSectors(firstDirectorySector86 + partition.Start, directoryLength);
DicConsole.DebugWriteLine("CP/M Plugin", "Found CP/M-86 floppy identifier.");
}
@@ -799,7 +799,7 @@ namespace DiscImageChef.Filesystems.CPM
if(def.sofs != 0) offset = (ulong)def.sofs;
else offset = (ulong)(def.ofs * def.sectorsPerTrack);
int dirLen = ((def.drm + 1) * 32) / def.bytesPerSector;
int dirLen = (def.drm + 1) * 32 / def.bytesPerSector;
if(def.sides == 1)
{
@@ -819,7 +819,7 @@ namespace DiscImageChef.Filesystems.CPM
// Skip first track (first side)
for(int m = 0; m < def.side2.sectorIds.Length; m++)
sectorMask[m + def.side1.sectorIds.Length] =
(def.side2.sectorIds[m] - def.side2.sectorIds[0]) +
def.side2.sectorIds[m] - def.side2.sectorIds[0] +
def.side1.sectorIds.Length;
}
// Head changes after whole side
@@ -831,7 +831,7 @@ namespace DiscImageChef.Filesystems.CPM
// Skip first track (first side) and first track (second side)
for(int m = 0; m < def.side1.sectorIds.Length; m++)
sectorMask[m + def.side1.sectorIds.Length] =
(def.side1.sectorIds[m] - def.side1.sectorIds[0]) +
def.side1.sectorIds[m] - def.side1.sectorIds[0] +
def.side1.sectorIds.Length + def.side2.sectorIds.Length;
}
// TODO: Implement COLUMBIA ordering
@@ -865,7 +865,7 @@ namespace DiscImageChef.Filesystems.CPM
{
byte[] dirSector =
imagePlugin.ReadSector((ulong)((int)offset + (int)partition.Start +
(p / sectorMask.Length) * sectorMask.Length +
p / sectorMask.Length * sectorMask.Length +
sectorMask[p % sectorMask.Length]));
ms.Write(dirSector, 0, dirSector.Length);
}
@@ -942,7 +942,7 @@ namespace DiscImageChef.Filesystems.CPM
break;
}
dpb.spt = (ushort)((def.sectorsPerTrack * def.bytesPerSector) / 128);
dpb.spt = (ushort)(def.sectorsPerTrack * def.bytesPerSector / 128);
cpmFound = true;
workingDefinition = def;
@@ -985,7 +985,7 @@ namespace DiscImageChef.Filesystems.CPM
sb.AppendFormat("Identified as {0}", workingDefinition.comment).AppendLine();
sb.AppendFormat("Volume block is {0} bytes", 128 << dpb.bsh).AppendLine();
if(dpb.dsm > 0)
sb.AppendFormat("Volume contains {0} blocks ({1} bytes)", dpb.dsm, (dpb.dsm) * (128 << dpb.bsh))
sb.AppendFormat("Volume contains {0} blocks ({1} bytes)", dpb.dsm, dpb.dsm * (128 << dpb.bsh))
.AppendLine();
sb.AppendFormat("Volume contains {0} directory entries", dpb.drm + 1).AppendLine();
if(workingDefinition.sofs > 0)
@@ -1051,7 +1051,7 @@ namespace DiscImageChef.Filesystems.CPM
sb.AppendFormat("Volume updated on {0}", DateHandlers.CPMToDateTime(labelUpdateDate)).AppendLine();
xmlFSType = new Schemas.FileSystemType();
xmlFSType.Bootable |= (workingDefinition.sofs > 0 || workingDefinition.ofs > 0);
xmlFSType.Bootable |= workingDefinition.sofs > 0 || workingDefinition.ofs > 0;
xmlFSType.ClusterSize = 128 << dpb.bsh;
if(dpb.dsm > 0) xmlFSType.Clusters = dpb.dsm;
else xmlFSType.Clusters = (long)(partition.End - partition.Start);

View File

@@ -73,7 +73,7 @@ namespace DiscImageChef.Filesystems.CPM
// Skip first track (first side)
for(int m = 0; m < workingDefinition.side2.sectorIds.Length; m++)
sectorMask[m + workingDefinition.side1.sectorIds.Length] =
(workingDefinition.side2.sectorIds[m] - workingDefinition.side2.sectorIds[0]) +
workingDefinition.side2.sectorIds[m] - workingDefinition.side2.sectorIds[0] +
workingDefinition.side1.sectorIds.Length;
}
// Head changes after whole side
@@ -85,7 +85,7 @@ namespace DiscImageChef.Filesystems.CPM
// Skip first track (first side) and first track (second side)
for(int m = 0; m < workingDefinition.side1.sectorIds.Length; m++)
sectorMask[m + workingDefinition.side1.sectorIds.Length] =
(workingDefinition.side1.sectorIds[m] - workingDefinition.side1.sectorIds[0]) +
workingDefinition.side1.sectorIds[m] - workingDefinition.side1.sectorIds[0] +
workingDefinition.side1.sectorIds.Length + workingDefinition.side2.sectorIds.Length;
// TODO: Implement CYLINDERS ordering
@@ -128,7 +128,7 @@ namespace DiscImageChef.Filesystems.CPM
for(int p = 0; p <= (int)(partition.End - partition.Start); p++)
{
byte[] readSector =
device.ReadSector((ulong)((int)partition.Start + (p / sectorMask.Length) * sectorMask.Length +
device.ReadSector((ulong)((int)partition.Start + p / sectorMask.Length * sectorMask.Length +
sectorMask[p % sectorMask.Length]));
if(workingDefinition.complement)
{
@@ -156,7 +156,7 @@ namespace DiscImageChef.Filesystems.CPM
// May it happen? Just in case, CP/M blocks are smaller than physical sectors
if(sector.Length > blockSize)
{
for(int i = 0; i < (sector.Length / blockSize); i++)
for(int i = 0; i < sector.Length / blockSize; i++)
{
byte[] tmp = new byte[blockSize];
Array.Copy(sector, blockSize * i, tmp, 0, blockSize);
@@ -183,7 +183,7 @@ namespace DiscImageChef.Filesystems.CPM
DicConsole.DebugWriteLine("CP/M Plugin", "Reading directory.");
int dirOff;
int dirSectors = ((dpb.drm + 1) * 32) / workingDefinition.bytesPerSector;
int dirSectors = (dpb.drm + 1) * 32 / workingDefinition.bytesPerSector;
if(workingDefinition.sofs > 0) dirOff = workingDefinition.sofs;
else dirOff = workingDefinition.ofs * workingDefinition.sectorsPerTrack;
@@ -235,7 +235,7 @@ namespace DiscImageChef.Filesystems.CPM
bool rdOnly = (entry.filename[0] & 0x80) == 0x80 || (entry.extension[0] & 0x80) == 0x80;
bool system = (entry.filename[1] & 0x80) == 0x80 || (entry.extension[2] & 0x80) == 0x80;
//bool backed = (entry.filename[3] & 0x80) == 0x80 || (entry.extension[3] & 0x80) == 0x80;
int user = (entry.statusUser & 0x0F);
int user = entry.statusUser & 0x0F;
bool validEntry = true;
@@ -259,7 +259,7 @@ namespace DiscImageChef.Filesystems.CPM
if(user > 0) filename = string.Format("{0:X1}:{1}", user, filename);
if(!string.IsNullOrEmpty(extension)) filename = filename + "." + extension;
int entryNo = ((32 * entry.extentCounter) + entry.extentCounterHigh) / (dpb.exm + 1);
int entryNo = (32 * entry.extentCounter + entry.extentCounterHigh) / (dpb.exm + 1);
List<ushort> blocks;
Dictionary<int, List<ushort>> extentBlocks;
FileEntryInfo fInfo;
@@ -332,7 +332,7 @@ namespace DiscImageChef.Filesystems.CPM
bool rdOnly = (entry.filename[0] & 0x80) == 0x80 || (entry.extension[0] & 0x80) == 0x80;
bool system = (entry.filename[1] & 0x80) == 0x80 || (entry.extension[2] & 0x80) == 0x80;
//bool backed = (entry.filename[3] & 0x80) == 0x80 || (entry.extension[3] & 0x80) == 0x80;
int user = (entry.statusUser & 0x0F);
int user = entry.statusUser & 0x0F;
bool validEntry = true;
@@ -356,7 +356,7 @@ namespace DiscImageChef.Filesystems.CPM
if(user > 0) filename = string.Format("{0:X1}:{1}", user, filename);
if(!string.IsNullOrEmpty(extension)) filename = filename + "." + extension;
int entryNo = ((32 * entry.extentCounterHigh) + entry.extentCounter) / (dpb.exm + 1);
int entryNo = (32 * entry.extentCounterHigh + entry.extentCounter) / (dpb.exm + 1);
List<ushort> blocks;
Dictionary<int, List<ushort>> extentBlocks;
FileEntryInfo fInfo;
@@ -427,7 +427,7 @@ namespace DiscImageChef.Filesystems.CPM
entry = (PasswordEntry)Marshal.PtrToStructure(dirPtr, typeof(PasswordEntry));
Marshal.FreeHGlobal(dirPtr);
int user = (entry.userNumber & 0x0F);
int user = entry.userNumber & 0x0F;
for(int i = 0; i < 8; i++) entry.filename[i] &= 0x7F;
for(int i = 0; i < 3; i++) entry.extension[i] &= 0x7F;