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

@@ -50,15 +50,13 @@ namespace DiscImageChef.Decoders.PCMCIA
tuple.Code = (TupleCodes)data[position];
if(tuple.Code == TupleCodes.CISTPL_NULL)
continue;
if(tuple.Code == TupleCodes.CISTPL_END)
break;
if(tuple.Code == TupleCodes.CISTPL_NULL) continue;
if(tuple.Code == TupleCodes.CISTPL_END) break;
tuple.Link = data[position + 1];
if(position + 2 + tuple.Link > data.Length)
break;
if(position + 2 + tuple.Link > data.Length) break;
tuple.Data = new byte[tuple.Link + 2];
Array.Copy(data, position, tuple.Data, 0, tuple.Link + 2);
@@ -72,24 +70,19 @@ namespace DiscImageChef.Decoders.PCMCIA
public static DeviceGeometryTuple DecodeDeviceGeometryTuple(Tuple tuple)
{
if(tuple == null)
return null;
if(tuple == null) return null;
if(tuple.Code != TupleCodes.CISTPL_DEVICEGEO && tuple.Code != TupleCodes.CISTPL_DEVICEGEO_A)
return null;
if(tuple.Code != TupleCodes.CISTPL_DEVICEGEO && tuple.Code != TupleCodes.CISTPL_DEVICEGEO_A) return null;
if(tuple.Data == null)
return null;
if(tuple.Data == null) return null;
return DecodeDeviceGeometryTuple(tuple.Data);
}
public static DeviceGeometryTuple DecodeDeviceGeometryTuple(byte[] data)
{
if(data == null)
return null;
if((data.Length - 2) % 6 != 0)
return null;
if(data == null) return null;
if((data.Length - 2) % 6 != 0) return null;
DeviceGeometryTuple tuple = new DeviceGeometryTuple();
List<DeviceGeometry> geometries = new List<DeviceGeometry>();
@@ -115,11 +108,9 @@ namespace DiscImageChef.Decoders.PCMCIA
public static string PrettifyDeviceGeometryTuple(DeviceGeometryTuple tuple)
{
if(tuple == null)
return null;
if(tuple == null) return null;
if(tuple.Code != TupleCodes.CISTPL_DEVICEGEO && tuple.Code != TupleCodes.CISTPL_DEVICEGEO_A)
return null;
if(tuple.Code != TupleCodes.CISTPL_DEVICEGEO && tuple.Code != TupleCodes.CISTPL_DEVICEGEO_A) return null;
StringBuilder sb = new StringBuilder();
sb.AppendLine("PCMCIA Device Geometry Tuples:");
@@ -127,10 +118,15 @@ namespace DiscImageChef.Decoders.PCMCIA
{
sb.AppendLine("\tGeometry:");
sb.AppendFormat("\t\tDevice width: {0} bits", (1 << (geometry.CardInterface - 1)) * 8).AppendLine();
sb.AppendFormat("\t\tErase block = {0} bytes", (1 << (geometry.EraseBlockSize - 1)) * (1 << (geometry.Interleaving - 1))).AppendLine();
sb.AppendFormat("\t\tRead block = {0} bytes", (1 << (geometry.ReadBlockSize - 1)) * (1 << (geometry.Interleaving - 1))).AppendLine();
sb.AppendFormat("\t\tWrite block = {0} bytes", (1 << (geometry.WriteBlockSize - 1)) * (1 << (geometry.Interleaving - 1))).AppendLine();
sb.AppendFormat("\t\tPartition alignment = {0} bytes", (1 << (geometry.EraseBlockSize - 1)) * (1 << (geometry.Interleaving - 1)) * (1 << (geometry.Partitions - 1))).AppendLine();
sb.AppendFormat("\t\tErase block = {0} bytes",
(1 << (geometry.EraseBlockSize - 1)) * (1 << (geometry.Interleaving - 1))).AppendLine();
sb.AppendFormat("\t\tRead block = {0} bytes",
(1 << (geometry.ReadBlockSize - 1)) * (1 << (geometry.Interleaving - 1))).AppendLine();
sb.AppendFormat("\t\tWrite block = {0} bytes",
(1 << (geometry.WriteBlockSize - 1)) * (1 << (geometry.Interleaving - 1))).AppendLine();
sb.AppendFormat("\t\tPartition alignment = {0} bytes",
(1 << (geometry.EraseBlockSize - 1)) * (1 << (geometry.Interleaving - 1)) *
(1 << (geometry.Partitions - 1))).AppendLine();
}
return sb.ToString();
@@ -148,25 +144,20 @@ namespace DiscImageChef.Decoders.PCMCIA
public static ManufacturerIdentificationTuple DecodeManufacturerIdentificationTuple(Tuple tuple)
{
if(tuple == null)
return null;
if(tuple == null) return null;
if(tuple.Code != TupleCodes.CISTPL_MANFID)
return null;
if(tuple.Code != TupleCodes.CISTPL_MANFID) return null;
if(tuple.Data == null)
return null;
if(tuple.Data == null) return null;
return DecodeManufacturerIdentificationTuple(tuple.Data);
}
public static ManufacturerIdentificationTuple DecodeManufacturerIdentificationTuple(byte[] data)
{
if(data == null)
return null;
if(data == null) return null;
if(data.Length < 6)
return null;
if(data.Length < 6) return null;
ManufacturerIdentificationTuple tuple = new ManufacturerIdentificationTuple();
tuple.Code = (TupleCodes)data[0];
@@ -179,11 +170,9 @@ namespace DiscImageChef.Decoders.PCMCIA
public static string PrettifyManufacturerIdentificationTuple(ManufacturerIdentificationTuple tuple)
{
if(tuple == null)
return null;
if(tuple == null) return null;
if(tuple.Code != TupleCodes.CISTPL_MANFID)
return null;
if(tuple.Code != TupleCodes.CISTPL_MANFID) return null;
StringBuilder sb = new StringBuilder();
sb.AppendLine("PCMCIA Manufacturer Identification Tuple:");
@@ -205,25 +194,20 @@ namespace DiscImageChef.Decoders.PCMCIA
public static Level1VersionTuple DecodeLevel1VersionTuple(Tuple tuple)
{
if(tuple == null)
return null;
if(tuple == null) return null;
if(tuple.Code != TupleCodes.CISTPL_VERS_1)
return null;
if(tuple.Code != TupleCodes.CISTPL_VERS_1) return null;
if(tuple.Data == null)
return null;
if(tuple.Data == null) return null;
return DecodeLevel1VersionTuple(tuple.Data);
}
public static Level1VersionTuple DecodeLevel1VersionTuple(byte[] data)
{
if(data == null)
return null;
if(data == null) return null;
if(data.Length < 4)
return null;
if(data.Length < 4) return null;
List<byte> buffer = new List<byte>();
List<string> strings = null;
@@ -238,8 +222,7 @@ namespace DiscImageChef.Decoders.PCMCIA
for(int position = 4; position < data.Length; position++)
{
if(data[position] == 0xFF)
break;
if(data[position] == 0xFF) break;
buffer.Add(data[position]);
@@ -261,42 +244,35 @@ namespace DiscImageChef.Decoders.PCMCIA
continue;
}
if(strings == null)
strings = new List<string>();
if(strings == null) strings = new List<string>();
strings.Add(StringHandlers.CToString(buffer.ToArray()));
buffer = new List<byte>();
}
}
if(strings != null)
tuple.AdditionalInformation = strings.ToArray();
if(strings != null) tuple.AdditionalInformation = strings.ToArray();
return tuple;
}
public static string PrettifyLevel1VersionTuple(Level1VersionTuple tuple)
{
if(tuple == null)
return null;
if(tuple == null) return null;
if(tuple.Code != TupleCodes.CISTPL_VERS_1)
return null;
if(tuple.Code != TupleCodes.CISTPL_VERS_1) return null;
StringBuilder sb = new StringBuilder();
sb.AppendLine("PCMCIA Level 1 Version / Product Information Tuple:");
sb.AppendFormat("\tCard indicates compliance with PC Card Standard Release {0}.{1}", tuple.MajorVersion, tuple.MinorVersion).AppendLine();
sb.AppendFormat("\tCard indicates compliance with PC Card Standard Release {0}.{1}", tuple.MajorVersion,
tuple.MinorVersion).AppendLine();
if(string.IsNullOrEmpty(tuple.Manufacturer))
sb.AppendLine("\tNo manufacturer information string.");
else
sb.AppendFormat("\tManufacturer: {0}", tuple.Manufacturer).AppendLine();
if(string.IsNullOrEmpty(tuple.Manufacturer)) sb.AppendLine("\tNo manufacturer information string.");
else sb.AppendFormat("\tManufacturer: {0}", tuple.Manufacturer).AppendLine();
if(string.IsNullOrEmpty(tuple.Product))
sb.AppendLine("\tNo product name string.");
else
sb.AppendFormat("\tProduct name: {0}", tuple.Product).AppendLine();
if(string.IsNullOrEmpty(tuple.Product)) sb.AppendLine("\tNo product name string.");
else sb.AppendFormat("\tProduct name: {0}", tuple.Product).AppendLine();
if(tuple.AdditionalInformation == null || tuple.AdditionalInformation.Length == 0)
sb.AppendLine("\tNo additional information.");
@@ -305,8 +281,7 @@ namespace DiscImageChef.Decoders.PCMCIA
sb.AppendLine("\tAdditional information:");
foreach(string info in tuple.AdditionalInformation)
{
if(!string.IsNullOrEmpty(info))
sb.AppendFormat("\t\t{0}", info).AppendLine();
if(!string.IsNullOrEmpty(info)) sb.AppendFormat("\t\t{0}", info).AppendLine();
}
}
@@ -317,10 +292,10 @@ namespace DiscImageChef.Decoders.PCMCIA
{
return PrettifyLevel1VersionTuple(DecodeLevel1VersionTuple(tuple));
}
public static string PrettifyLevel1VersionTuple(byte[] data)
{
return PrettifyLevel1VersionTuple(DecodeLevel1VersionTuple(data));
}
}
}
}
}