Reformatted.

This commit is contained in:
2016-04-19 02:11:47 +01:00
parent 0ce352425c
commit 025f080728
7 changed files with 64 additions and 64 deletions

View File

@@ -42,12 +42,12 @@ namespace DiscImageChef
public static void ArrayFill<T>(T[] destinationArray, T[] value) public static void ArrayFill<T>(T[] destinationArray, T[] value)
{ {
if (destinationArray == null) if(destinationArray == null)
{ {
throw new ArgumentNullException("destinationArray"); throw new ArgumentNullException("destinationArray");
} }
if (value.Length > destinationArray.Length) if(value.Length > destinationArray.Length)
{ {
throw new ArgumentException("Length of value array must not be more than length of destination"); throw new ArgumentException("Length of value array must not be more than length of destination");
} }

View File

@@ -43,11 +43,11 @@ namespace DiscImageChef
{ {
public static bool ArrayIsNullOrWhiteSpace(byte[] array) public static bool ArrayIsNullOrWhiteSpace(byte[] array)
{ {
if (array == null) if(array == null)
return true; return true;
foreach (byte b in array) foreach(byte b in array)
if (b != 0x00 && b != 0x20) if(b != 0x00 && b != 0x20)
return false; return false;
return true; return true;
@@ -55,11 +55,11 @@ namespace DiscImageChef
public static bool ArrayIsNullOrEmpty(byte[] array) public static bool ArrayIsNullOrEmpty(byte[] array)
{ {
if (array == null) if(array == null)
return true; return true;
foreach (byte b in array) foreach(byte b in array)
if (b != 0x00) if(b != 0x00)
return false; return false;
return true; return true;

View File

@@ -649,7 +649,7 @@ namespace DiscImageChef
public static Guid ToGuid(byte[] value, int startIndex) public static Guid ToGuid(byte[] value, int startIndex)
{ {
return new Guid(BigEndianBitConverter.ToUInt32(value, 0 + startIndex), return new Guid(BigEndianBitConverter.ToUInt32(value, 0 + startIndex),
BigEndianBitConverter.ToUInt16(value, 4 + startIndex), BigEndianBitConverter.ToUInt16(value, 4 + startIndex),
BigEndianBitConverter.ToUInt16(value, 6 + startIndex), BigEndianBitConverter.ToUInt16(value, 6 + startIndex),
value[8 + startIndex + 0], value[8 + startIndex + 1], value[8 + startIndex + 0], value[8 + startIndex + 1],
value[8 + startIndex + 2], value[8 + startIndex + 3], value[8 + startIndex + 2], value[8 + startIndex + 3],

View File

@@ -75,61 +75,61 @@ namespace DiscImageChef
int year, month, day, hour, minute, second, hundredths; int year, month, day, hour, minute, second, hundredths;
byte[] twocharvalue = new byte[2]; byte[] twocharvalue = new byte[2];
byte[] fourcharvalue = new byte[4]; byte[] fourcharvalue = new byte[4];
fourcharvalue[0] = VDDateTime[0]; fourcharvalue[0] = VDDateTime[0];
fourcharvalue[1] = VDDateTime[1]; fourcharvalue[1] = VDDateTime[1];
fourcharvalue[2] = VDDateTime[2]; fourcharvalue[2] = VDDateTime[2];
fourcharvalue[3] = VDDateTime[3]; fourcharvalue[3] = VDDateTime[3];
DicConsole.DebugWriteLine("ISO9600ToDateTime handler", "year = \"{0}\"", StringHandlers.CToString(fourcharvalue)); DicConsole.DebugWriteLine("ISO9600ToDateTime handler", "year = \"{0}\"", StringHandlers.CToString(fourcharvalue));
if (!Int32.TryParse(StringHandlers.CToString(fourcharvalue), out year)) if(!Int32.TryParse(StringHandlers.CToString(fourcharvalue), out year))
year = 0; year = 0;
// year = Convert.ToInt32(StringHandlers.CToString(fourcharvalue)); // year = Convert.ToInt32(StringHandlers.CToString(fourcharvalue));
twocharvalue[0] = VDDateTime[4]; twocharvalue[0] = VDDateTime[4];
twocharvalue[1] = VDDateTime[5]; twocharvalue[1] = VDDateTime[5];
DicConsole.DebugWriteLine("ISO9600ToDateTime handler", "month = \"{0}\"", StringHandlers.CToString(twocharvalue)); DicConsole.DebugWriteLine("ISO9600ToDateTime handler", "month = \"{0}\"", StringHandlers.CToString(twocharvalue));
if (!Int32.TryParse(StringHandlers.CToString(twocharvalue), out month)) if(!Int32.TryParse(StringHandlers.CToString(twocharvalue), out month))
month = 0; month = 0;
// month = Convert.ToInt32(StringHandlers.CToString(twocharvalue)); // month = Convert.ToInt32(StringHandlers.CToString(twocharvalue));
twocharvalue[0] = VDDateTime[6]; twocharvalue[0] = VDDateTime[6];
twocharvalue[1] = VDDateTime[7]; twocharvalue[1] = VDDateTime[7];
DicConsole.DebugWriteLine("ISO9600ToDateTime handler", "day = \"{0}\"", StringHandlers.CToString(twocharvalue)); DicConsole.DebugWriteLine("ISO9600ToDateTime handler", "day = \"{0}\"", StringHandlers.CToString(twocharvalue));
if (!Int32.TryParse(StringHandlers.CToString(twocharvalue), out day)) if(!Int32.TryParse(StringHandlers.CToString(twocharvalue), out day))
day = 0; day = 0;
// day = Convert.ToInt32(StringHandlers.CToString(twocharvalue)); // day = Convert.ToInt32(StringHandlers.CToString(twocharvalue));
twocharvalue[0] = VDDateTime[8]; twocharvalue[0] = VDDateTime[8];
twocharvalue[1] = VDDateTime[9]; twocharvalue[1] = VDDateTime[9];
DicConsole.DebugWriteLine("ISO9600ToDateTime handler", "hour = \"{0}\"", StringHandlers.CToString(twocharvalue)); DicConsole.DebugWriteLine("ISO9600ToDateTime handler", "hour = \"{0}\"", StringHandlers.CToString(twocharvalue));
if (!Int32.TryParse(StringHandlers.CToString(twocharvalue), out hour)) if(!Int32.TryParse(StringHandlers.CToString(twocharvalue), out hour))
hour = 0; hour = 0;
// hour = Convert.ToInt32(StringHandlers.CToString(twocharvalue)); // hour = Convert.ToInt32(StringHandlers.CToString(twocharvalue));
twocharvalue[0] = VDDateTime[10]; twocharvalue[0] = VDDateTime[10];
twocharvalue[1] = VDDateTime[11]; twocharvalue[1] = VDDateTime[11];
DicConsole.DebugWriteLine("ISO9600ToDateTime handler", "minute = \"{0}\"", StringHandlers.CToString(twocharvalue)); DicConsole.DebugWriteLine("ISO9600ToDateTime handler", "minute = \"{0}\"", StringHandlers.CToString(twocharvalue));
if (!Int32.TryParse(StringHandlers.CToString(twocharvalue), out minute)) if(!Int32.TryParse(StringHandlers.CToString(twocharvalue), out minute))
minute = 0; minute = 0;
// minute = Convert.ToInt32(StringHandlers.CToString(twocharvalue)); // minute = Convert.ToInt32(StringHandlers.CToString(twocharvalue));
twocharvalue[0] = VDDateTime[12]; twocharvalue[0] = VDDateTime[12];
twocharvalue[1] = VDDateTime[13]; twocharvalue[1] = VDDateTime[13];
DicConsole.DebugWriteLine("ISO9600ToDateTime handler", "second = \"{0}\"", StringHandlers.CToString(twocharvalue)); DicConsole.DebugWriteLine("ISO9600ToDateTime handler", "second = \"{0}\"", StringHandlers.CToString(twocharvalue));
if (!Int32.TryParse(StringHandlers.CToString(twocharvalue), out second)) if(!Int32.TryParse(StringHandlers.CToString(twocharvalue), out second))
second = 0; second = 0;
// second = Convert.ToInt32(StringHandlers.CToString(twocharvalue)); // second = Convert.ToInt32(StringHandlers.CToString(twocharvalue));
twocharvalue[0] = VDDateTime[14]; twocharvalue[0] = VDDateTime[14];
twocharvalue[1] = VDDateTime[15]; twocharvalue[1] = VDDateTime[15];
DicConsole.DebugWriteLine("ISO9600ToDateTime handler", "hundredths = \"{0}\"", StringHandlers.CToString(twocharvalue)); DicConsole.DebugWriteLine("ISO9600ToDateTime handler", "hundredths = \"{0}\"", StringHandlers.CToString(twocharvalue));
if (!Int32.TryParse(StringHandlers.CToString(twocharvalue), out hundredths)) if(!Int32.TryParse(StringHandlers.CToString(twocharvalue), out hundredths))
hundredths = 0; hundredths = 0;
// hundredths = Convert.ToInt32(StringHandlers.CToString(twocharvalue)); // hundredths = Convert.ToInt32(StringHandlers.CToString(twocharvalue));
DicConsole.DebugWriteLine("ISO9600ToDateTime handler", "decodedDT = new DateTime({0}, {1}, {2}, {3}, {4}, {5}, {6}, DateTimeKind.Unspecified);", year, month, day, hour, minute, second, hundredths * 10); DicConsole.DebugWriteLine("ISO9600ToDateTime handler", "decodedDT = new DateTime({0}, {1}, {2}, {3}, {4}, {5}, {6}, DateTimeKind.Unspecified);", year, month, day, hour, minute, second, hundredths * 10);
DateTime decodedDT = new DateTime(year, month, day, hour, minute, second, hundredths * 10, DateTimeKind.Unspecified); DateTime decodedDT = new DateTime(year, month, day, hour, minute, second, hundredths * 10, DateTimeKind.Unspecified);
return decodedDT; return decodedDT;
} }

View File

@@ -48,13 +48,13 @@ namespace DiscImageChef
byte[] buffer = new byte[8]; byte[] buffer = new byte[8];
public EndianAwareBinaryReader(Stream input, Encoding encoding, bool isLittleEndian) public EndianAwareBinaryReader(Stream input, Encoding encoding, bool isLittleEndian)
: base(input, encoding) : base(input, encoding)
{ {
IsLittleEndian = isLittleEndian; IsLittleEndian = isLittleEndian;
} }
public EndianAwareBinaryReader(Stream input, bool isLittleEndian) public EndianAwareBinaryReader(Stream input, bool isLittleEndian)
: this(input, Encoding.UTF8, isLittleEndian) : this(input, Encoding.UTF8, isLittleEndian)
{ {
} }
@@ -66,7 +66,7 @@ namespace DiscImageChef
public override double ReadDouble() public override double ReadDouble()
{ {
if (IsLittleEndian) if(IsLittleEndian)
return base.ReadDouble(); return base.ReadDouble();
FillMyBuffer(8); FillMyBuffer(8);
return BitConverter.ToDouble(buffer.Take(8).Reverse().ToArray(), 0); return BitConverter.ToDouble(buffer.Take(8).Reverse().ToArray(), 0);
@@ -74,34 +74,34 @@ namespace DiscImageChef
public override short ReadInt16() public override short ReadInt16()
{ {
if (IsLittleEndian) if(IsLittleEndian)
return base.ReadInt16(); return base.ReadInt16();
FillMyBuffer(2); FillMyBuffer(2);
return BitConverter.ToInt16(buffer.Take(2).Reverse().ToArray(), 0); return BitConverter.ToInt16(buffer.Take(2).Reverse().ToArray(), 0);
} }
public override int ReadInt32() public override int ReadInt32()
{ {
if (IsLittleEndian) if(IsLittleEndian)
return base.ReadInt32(); return base.ReadInt32();
FillMyBuffer(4); FillMyBuffer(4);
return BitConverter.ToInt32(buffer.Take(4).Reverse().ToArray(), 0); return BitConverter.ToInt32(buffer.Take(4).Reverse().ToArray(), 0);
} }
public override long ReadInt64() public override long ReadInt64()
{ {
if (IsLittleEndian) if(IsLittleEndian)
return base.ReadInt64(); return base.ReadInt64();
FillMyBuffer(8); FillMyBuffer(8);
return BitConverter.ToInt64(buffer.Take(8).Reverse().ToArray(), 0); return BitConverter.ToInt64(buffer.Take(8).Reverse().ToArray(), 0);
} }
public override float ReadSingle() public override float ReadSingle()
{ {
if (IsLittleEndian) if(IsLittleEndian)
return base.ReadSingle(); return base.ReadSingle();
FillMyBuffer(4); FillMyBuffer(4);
return BitConverter.ToSingle(buffer.Take(4).Reverse().ToArray(), 0); return BitConverter.ToSingle(buffer.Take(4).Reverse().ToArray(), 0);
@@ -109,7 +109,7 @@ namespace DiscImageChef
public override ushort ReadUInt16() public override ushort ReadUInt16()
{ {
if (IsLittleEndian) if(IsLittleEndian)
return base.ReadUInt16(); return base.ReadUInt16();
FillMyBuffer(2); FillMyBuffer(2);
return BitConverter.ToUInt16(buffer.Take(2).Reverse().ToArray(), 0); return BitConverter.ToUInt16(buffer.Take(2).Reverse().ToArray(), 0);
@@ -117,7 +117,7 @@ namespace DiscImageChef
public override uint ReadUInt32() public override uint ReadUInt32()
{ {
if (IsLittleEndian) if(IsLittleEndian)
return base.ReadUInt32(); return base.ReadUInt32();
FillMyBuffer(4); FillMyBuffer(4);
return BitConverter.ToUInt32(buffer.Take(4).Reverse().ToArray(), 0); return BitConverter.ToUInt32(buffer.Take(4).Reverse().ToArray(), 0);
@@ -125,7 +125,7 @@ namespace DiscImageChef
public override ulong ReadUInt64() public override ulong ReadUInt64()
{ {
if (IsLittleEndian) if(IsLittleEndian)
return base.ReadUInt64(); return base.ReadUInt64();
FillMyBuffer(8); FillMyBuffer(8);
return BitConverter.ToUInt64(buffer.Take(8).Reverse().ToArray(), 0); return BitConverter.ToUInt64(buffer.Take(8).Reverse().ToArray(), 0);
@@ -135,10 +135,10 @@ namespace DiscImageChef
{ {
int offset = 0; int offset = 0;
int num2; int num2;
if (numBytes == 1) if(numBytes == 1)
{ {
num2 = BaseStream.ReadByte(); num2 = BaseStream.ReadByte();
if (num2 == -1) if(num2 == -1)
{ {
throw new EndOfStreamException("Attempted to read past the end of the stream."); throw new EndOfStreamException("Attempted to read past the end of the stream.");
} }
@@ -149,13 +149,13 @@ namespace DiscImageChef
do do
{ {
num2 = BaseStream.Read(buffer, offset, numBytes - offset); num2 = BaseStream.Read(buffer, offset, numBytes - offset);
if (num2 == 0) if(num2 == 0)
{ {
throw new EndOfStreamException("Attempted to read past the end of the stream."); throw new EndOfStreamException("Attempted to read past the end of the stream.");
} }
offset += num2; offset += num2;
} }
while (offset < numBytes); while(offset < numBytes);
} }
} }
} }

View File

@@ -53,16 +53,16 @@ namespace DiscImageChef
int counter = 0; int counter = 0;
int subcounter = 0; int subcounter = 0;
for (long i = 0; i < array.LongLength; i++) for(long i = 0; i < array.LongLength; i++)
{ {
if (counter == 0) if(counter == 0)
{ {
sb.AppendLine(); sb.AppendLine();
sb.AppendFormat("{0:X16} ", i); sb.AppendFormat("{0:X16} ", i);
} }
else else
{ {
if (subcounter == 3 ) if(subcounter == 3)
{ {
sb.Append(" "); sb.Append(" ");
subcounter = 0; subcounter = 0;
@@ -76,7 +76,7 @@ namespace DiscImageChef
sb.AppendFormat("{0:X2}", array[i]); sb.AppendFormat("{0:X2}", array[i]);
if (counter == width - 1) if(counter == width - 1)
{ {
counter = 0; counter = 0;
subcounter = 0; subcounter = 0;

View File

@@ -61,19 +61,19 @@ namespace DiscImageChef
/// <param name="encoding">Encoding.</param> /// <param name="encoding">Encoding.</param>
public static string CToString(byte[] CString, Encoding encoding) public static string CToString(byte[] CString, Encoding encoding)
{ {
if (CString == null) if(CString == null)
return null; return null;
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
for (int i = 0; i < CString.Length; i++) for(int i = 0; i < CString.Length; i++)
{ {
if (CString[i] == 0) if(CString[i] == 0)
break; break;
sb.Append(encoding.GetString(CString, i, 1)); sb.Append(encoding.GetString(CString, i, 1));
} }
return sb.ToString(); return sb.ToString();
} }
@@ -84,14 +84,14 @@ namespace DiscImageChef
/// <param name="PascalString">A length-prefixed (aka Pascal string) ASCII byte array</param> /// <param name="PascalString">A length-prefixed (aka Pascal string) ASCII byte array</param>
public static string PascalToString(byte[] PascalString) public static string PascalToString(byte[] PascalString)
{ {
if (PascalString == null) if(PascalString == null)
return null; return null;
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
byte length = PascalString[0]; byte length = PascalString[0];
for (int i = 1; i < length + 1; i++) for(int i = 1; i < length + 1; i++)
{ {
sb.Append(Encoding.ASCII.GetString(PascalString, i, 1)); sb.Append(Encoding.ASCII.GetString(PascalString, i, 1));
} }
@@ -106,17 +106,17 @@ namespace DiscImageChef
/// <param name="SpacePaddedString">A space (' ', 0x20, ASCII SPACE) padded ASCII byte array</param> /// <param name="SpacePaddedString">A space (' ', 0x20, ASCII SPACE) padded ASCII byte array</param>
public static string SpacePaddedToString(byte[] SpacePaddedString) public static string SpacePaddedToString(byte[] SpacePaddedString)
{ {
if (SpacePaddedString == null) if(SpacePaddedString == null)
return null; return null;
int length = 0; int length = 0;
for (int i = SpacePaddedString.Length; i >= 0; i--) for(int i = SpacePaddedString.Length; i >= 0; i--)
{ {
if (i == 0) if(i == 0)
return ""; return "";
if (SpacePaddedString[i - 1] != 0x20) if(SpacePaddedString[i - 1] != 0x20)
{ {
length = i; length = i;
break; break;