diff --git a/BigEndianBitConverter.cs b/BigEndianBitConverter.cs index b017ce94d..33e2e713c 100644 --- a/BigEndianBitConverter.cs +++ b/BigEndianBitConverter.cs @@ -239,7 +239,7 @@ namespace DiscImageChef public static short ToInt16(byte[] value, int startIndex) { return !IsLittleEndian - ? BitConverter.ToInt16(value, startIndex) + ? BitConverter.ToInt16(value, startIndex) : BitConverter.ToInt16(value.Reverse().ToArray(), value.Length - sizeof(short) - startIndex); } @@ -261,7 +261,7 @@ namespace DiscImageChef public static int ToInt32(byte[] value, int startIndex) { return !IsLittleEndian - ? BitConverter.ToInt32(value, startIndex) + ? BitConverter.ToInt32(value, startIndex) : BitConverter.ToInt32(value.Reverse().ToArray(), value.Length - sizeof(int) - startIndex); } @@ -283,7 +283,7 @@ namespace DiscImageChef public static long ToInt64(byte[] value, int startIndex) { return !IsLittleEndian - ? BitConverter.ToInt64(value, startIndex) + ? BitConverter.ToInt64(value, startIndex) : BitConverter.ToInt64(value.Reverse().ToArray(), value.Length - sizeof(long) - startIndex); } @@ -306,7 +306,7 @@ namespace DiscImageChef public static float ToSingle(byte[] value, int startIndex) { return !IsLittleEndian - ? BitConverter.ToSingle(value, startIndex) + ? BitConverter.ToSingle(value, startIndex) : BitConverter.ToSingle(value.Reverse().ToArray(), value.Length - sizeof(float) - startIndex); } @@ -343,7 +343,7 @@ namespace DiscImageChef public static string ToString(byte[] value, int startIndex) { return !IsLittleEndian - ? BitConverter.ToString(value, startIndex) + ? BitConverter.ToString(value, startIndex) : BitConverter.ToString(value.Reverse().ToArray(), startIndex); } @@ -370,7 +370,7 @@ namespace DiscImageChef public static string ToString(byte[] value, int startIndex, int length) { return !IsLittleEndian - ? BitConverter.ToString(value, startIndex, length) + ? BitConverter.ToString(value, startIndex, length) : BitConverter.ToString(value.Reverse().ToArray(), startIndex, length); } @@ -389,7 +389,7 @@ namespace DiscImageChef public static ushort ToUInt16(byte[] value, int startIndex) { return !IsLittleEndian - ? BitConverter.ToUInt16(value, startIndex) + ? BitConverter.ToUInt16(value, startIndex) : BitConverter.ToUInt16(value.Reverse().ToArray(), value.Length - sizeof(ushort) - startIndex); } @@ -411,7 +411,7 @@ namespace DiscImageChef public static uint ToUInt32(byte[] value, int startIndex) { return !IsLittleEndian - ? BitConverter.ToUInt32(value, startIndex) + ? BitConverter.ToUInt32(value, startIndex) : BitConverter.ToUInt32(value.Reverse().ToArray(), value.Length - sizeof(uint) - startIndex); } @@ -433,16 +433,19 @@ namespace DiscImageChef public static ulong ToUInt64(byte[] value, int startIndex) { return !IsLittleEndian - ? BitConverter.ToUInt64(value, startIndex) + ? BitConverter.ToUInt64(value, startIndex) : BitConverter.ToUInt64(value.Reverse().ToArray(), value.Length - sizeof(ulong) - startIndex); } public static Guid ToGuid(byte[] value, int startIndex) { return new Guid(ToUInt32(value, 0 + startIndex), ToUInt16(value, 4 + startIndex), - ToUInt16(value, 6 + startIndex), value[8 + startIndex + 0], value[8 + startIndex + 1], - value[8 + startIndex + 2], value[8 + startIndex + 3], value[8 + startIndex + 5], - value[8 + startIndex + 5], value[8 + startIndex + 6], value[8 + startIndex + 7]); + ToUInt16(value, 6 + startIndex), value[8 + startIndex + 0], + value[8 + startIndex + 1], + value[8 + startIndex + 2], value[8 + startIndex + 3], + value[8 + startIndex + 5], + value[8 + startIndex + 5], value[8 + startIndex + 6], + value[8 + startIndex + 7]); } } } \ No newline at end of file diff --git a/CHS.cs b/CHS.cs index 29f69b35d..5f7aca7ac 100644 --- a/CHS.cs +++ b/CHS.cs @@ -46,7 +46,7 @@ namespace DiscImageChef.Helpers public static uint ToLBA(uint cyl, uint head, uint sector, uint maxHead, uint maxSector) { return maxHead == 0 || maxSector == 0 - ? (cyl * 16 + head) * 63 + sector - 1 + ? (cyl * 16 + head) * 63 + sector - 1 : (cyl * maxHead + head) * maxSector + sector - 1; } } diff --git a/CompareBytes.cs b/CompareBytes.cs index 321ce8f1c..e5953b81e 100644 --- a/CompareBytes.cs +++ b/CompareBytes.cs @@ -42,20 +42,20 @@ namespace DiscImageChef /// Left array /// Right array public static void CompareBytes(out bool different, out bool sameSize, byte[] compareArray1, - byte[] compareArray2) + byte[] compareArray2) { different = false; - sameSize = true; + sameSize = true; long leastBytes; if(compareArray1.LongLength < compareArray2.LongLength) { - sameSize = false; + sameSize = false; leastBytes = compareArray1.LongLength; } else if(compareArray1.LongLength > compareArray2.LongLength) { - sameSize = false; + sameSize = false; leastBytes = compareArray2.LongLength; } else leastBytes = compareArray1.LongLength; diff --git a/CountBits.cs b/CountBits.cs index 3c0b926ca..e2aae95de 100644 --- a/CountBits.cs +++ b/CountBits.cs @@ -42,7 +42,7 @@ namespace DiscImageChef.Helpers public static int Count(uint number) { number = number - ((number >> 1) & 0x55555555); - number = (number & 0x33333333) + ((number >> 2) & 0x33333333); + number = (number & 0x33333333) + ((number >> 2) & 0x33333333); return (int)((((number + (number >> 4)) & 0x0F0F0F0F) * 0x01010101) >> 24); } } diff --git a/DateHandlers.cs b/DateHandlers.cs index 6014650aa..4d3345432 100644 --- a/DateHandlers.cs +++ b/DateHandlers.cs @@ -39,7 +39,7 @@ namespace DiscImageChef public static class DateHandlers { static readonly DateTime LisaEpoch = new DateTime(1901, 1, 1, 0, 0, 0); - static readonly DateTime MacEpoch = new DateTime(1904, 1, 1, 0, 0, 0); + static readonly DateTime MacEpoch = new DateTime(1904, 1, 1, 0, 0, 0); static readonly DateTime UnixEpoch = new DateTime(1970, 1, 1, 0, 0, 0); /// /// Day 0 of Julian Date system @@ -138,7 +138,7 @@ namespace DiscImageChef /// .NET DateTime public static DateTime Iso9660ToDateTime(byte[] vdDateTime) { - byte[] twocharvalue = new byte[2]; + byte[] twocharvalue = new byte[2]; byte[] fourcharvalue = new byte[4]; fourcharvalue[0] = vdDateTime[0]; @@ -228,8 +228,8 @@ namespace DiscImageChef /// .NET DateTime public static DateTime UcsdPascalToDateTime(short dateRecord) { - int year = ((dateRecord & 0xFE00) >> 9) + 1900; - int day = (dateRecord & 0x01F0) >> 4; + int year = ((dateRecord & 0xFE00) >> 9) + 1900; + int day = (dateRecord & 0x01F0) >> 4; int month = dateRecord & 0x000F; DicConsole.DebugWriteLine("UCSDPascalToDateTime handler", @@ -246,11 +246,11 @@ namespace DiscImageChef /// .NET DateTime public static DateTime DosToDateTime(ushort date, ushort time) { - int year = ((date & 0xFE00) >> 9) + 1980; - int month = (date & 0x1E0) >> 5; - int day = date & 0x1F; - int hour = (time & 0xF800) >> 11; - int minute = (time & 0x7E0) >> 5; + int year = ((date & 0xFE00) >> 9) + 1980; + int month = (date & 0x1E0) >> 5; + int day = date & 0x1F; + int hour = (time & 0xF800) >> 11; + int minute = (time & 0x7E0) >> 5; int second = (time & 0x1F) * 2; DicConsole.DebugWriteLine("DOSToDateTime handler", "date = 0x{0:X4}, year = {1}, month = {2}, day = {3}", @@ -273,9 +273,9 @@ namespace DiscImageChef /// .NET DateTime public static DateTime CpmToDateTime(byte[] timestamp) { - ushort days = BitConverter.ToUInt16(timestamp, 0); - int hours = timestamp[2]; - int minutes = timestamp[3]; + ushort days = BitConverter.ToUInt16(timestamp, 0); + int hours = timestamp[2]; + int minutes = timestamp[3]; DateTime temp = AmigaEpoch.AddDays(days); temp = temp.AddHours(hours); @@ -298,20 +298,23 @@ namespace DiscImageChef /// Hundreds of microseconds /// Microseconds /// - public static DateTime EcmaToDateTime(ushort typeAndTimeZone, short year, byte month, byte day, byte hour, - byte minute, byte second, byte centiseconds, byte hundredsOfMicroseconds, - byte microseconds) + public static DateTime EcmaToDateTime(ushort typeAndTimeZone, short year, byte month, byte day, + byte hour, + byte minute, byte second, byte centiseconds, + byte hundredsOfMicroseconds, + byte microseconds) { byte specification = (byte)((typeAndTimeZone & 0xF000) >> 12); - long ticks = (long)centiseconds * 100000 + (long)hundredsOfMicroseconds * 1000 + (long)microseconds * 10; + long ticks = (long)centiseconds * 100000 + (long)hundredsOfMicroseconds * 1000 + + (long)microseconds * 10; if(specification == 0) return new DateTime(year, month, day, hour, minute, second, DateTimeKind.Utc).AddTicks(ticks); ushort preOffset = (ushort)(typeAndTimeZone & 0xFFF); - short offset; + short offset; if((preOffset & 0x800) == 0x800) offset = (short)(preOffset | 0xF000); - else offset = (short)(preOffset & 0x7FF); + else offset = (short)(preOffset & 0x7FF); if(offset == -2047) return new DateTime(year, month, day, hour, minute, second, DateTimeKind.Unspecified).AddTicks(ticks); @@ -319,7 +322,7 @@ namespace DiscImageChef if(offset < -1440 || offset > 1440) offset = 0; return new DateTimeOffset(year, month, day, hour, minute, second, new TimeSpan(0, offset, 0)) - .AddTicks(ticks).DateTime; + .AddTicks(ticks).DateTime; } /// @@ -347,7 +350,7 @@ namespace DiscImageChef { os9Date = date.Length == 5 ? new DateTime(1900 + date[0], date[1], date[2], date[3], date[4], 0) - : new DateTime(1900 + date[0], date[1], date[2], 0, 0, 0); + : new DateTime(1900 + date[0], date[1], date[2], 0, 0, 0); } catch(ArgumentOutOfRangeException) { os9Date = new DateTime(1900, 0, 0, 0, 0, 0); } @@ -380,15 +383,15 @@ namespace DiscImageChef { try { - int iyear = (year >> 4) * 10 + (year & 0xF); - int imonth = (month >> 4) * 10 + (month & 0xF); - int iday = (day >> 4) * 10 + (day & 0xF); + int iyear = (year >> 4) * 10 + (year & 0xF); + int imonth = (month >> 4) * 10 + (month & 0xF); + int iday = (day >> 4) * 10 + (day & 0xF); int iminute = (minute >> 4) * 10 + (minute & 0xF); - int ihour = (hour >> 4) * 10 + (hour & 0xF); + int ihour = (hour >> 4) * 10 + (hour & 0xF); int isecond = (second >> 4) * 10 + (second & 0xF); if(iyear >= 70) iyear += 1900; - else iyear += 2000; + else iyear += 2000; return new DateTime(iyear, imonth, iday, ihour, iminute, isecond); } diff --git a/Extents/ExtentsByte.cs b/Extents/ExtentsByte.cs index 7d52a69a9..ba2b3c678 100644 --- a/Extents/ExtentsByte.cs +++ b/Extents/ExtentsByte.cs @@ -135,7 +135,7 @@ namespace Extents { byte realEnd; if(run) realEnd = (byte)(start + end - 1); - else realEnd = end; + else realEnd = end; // TODO: Optimize this for(byte t = start; t <= realEnd; t++) Add(t); @@ -177,7 +177,7 @@ namespace Extents { toRemove = extent; toAddOne = new Tuple(extent.Item1, (byte)(item - 1)); - toAddTwo = new Tuple((byte)(item + 1), extent.Item2); + toAddTwo = new Tuple((byte)(item + 1), extent.Item2); break; } diff --git a/Extents/ExtentsInt.cs b/Extents/ExtentsInt.cs index 8d4006347..39b8dbae6 100644 --- a/Extents/ExtentsInt.cs +++ b/Extents/ExtentsInt.cs @@ -135,7 +135,7 @@ namespace Extents { int realEnd; if(run) realEnd = start + end - 1; - else realEnd = end; + else realEnd = end; // TODO: Optimize this for(int t = start; t <= realEnd; t++) Add(t); @@ -177,7 +177,7 @@ namespace Extents { toRemove = extent; toAddOne = new Tuple(extent.Item1, item - 1); - toAddTwo = new Tuple(item + 1, extent.Item2); + toAddTwo = new Tuple(item + 1, extent.Item2); break; } diff --git a/Extents/ExtentsLong.cs b/Extents/ExtentsLong.cs index b70c85a98..5ccef4389 100644 --- a/Extents/ExtentsLong.cs +++ b/Extents/ExtentsLong.cs @@ -135,7 +135,7 @@ namespace Extents { long realEnd; if(run) realEnd = start + end - 1; - else realEnd = end; + else realEnd = end; // TODO: Optimize this for(long t = start; t <= realEnd; t++) Add(t); @@ -177,7 +177,7 @@ namespace Extents { toRemove = extent; toAddOne = new Tuple(extent.Item1, item - 1); - toAddTwo = new Tuple(item + 1, extent.Item2); + toAddTwo = new Tuple(item + 1, extent.Item2); break; } diff --git a/Extents/ExtentsSByte.cs b/Extents/ExtentsSByte.cs index b7479683d..f77c2848e 100644 --- a/Extents/ExtentsSByte.cs +++ b/Extents/ExtentsSByte.cs @@ -135,7 +135,7 @@ namespace Extents { sbyte realEnd; if(run) realEnd = (sbyte)(start + end - 1); - else realEnd = end; + else realEnd = end; // TODO: Optimize this for(sbyte t = start; t <= realEnd; t++) Add(t); @@ -177,7 +177,7 @@ namespace Extents { toRemove = extent; toAddOne = new Tuple(extent.Item1, (sbyte)(item - 1)); - toAddTwo = new Tuple((sbyte)(item + 1), extent.Item2); + toAddTwo = new Tuple((sbyte)(item + 1), extent.Item2); break; } diff --git a/Extents/ExtentsShort.cs b/Extents/ExtentsShort.cs index 0a26ee0b5..ae92ee891 100644 --- a/Extents/ExtentsShort.cs +++ b/Extents/ExtentsShort.cs @@ -135,7 +135,7 @@ namespace Extents { short realEnd; if(run) realEnd = (short)(start + end - 1); - else realEnd = end; + else realEnd = end; // TODO: Optimize this for(short t = start; t <= realEnd; t++) Add(t); @@ -177,7 +177,7 @@ namespace Extents { toRemove = extent; toAddOne = new Tuple(extent.Item1, (short)(item - 1)); - toAddTwo = new Tuple((short)(item + 1), extent.Item2); + toAddTwo = new Tuple((short)(item + 1), extent.Item2); break; } diff --git a/Extents/ExtentsUInt.cs b/Extents/ExtentsUInt.cs index 874173c0a..6a917d69d 100644 --- a/Extents/ExtentsUInt.cs +++ b/Extents/ExtentsUInt.cs @@ -135,7 +135,7 @@ namespace Extents { uint realEnd; if(run) realEnd = start + end - 1; - else realEnd = end; + else realEnd = end; // TODO: Optimize this for(uint t = start; t <= realEnd; t++) Add(t); @@ -177,7 +177,7 @@ namespace Extents { toRemove = extent; toAddOne = new Tuple(extent.Item1, item - 1); - toAddTwo = new Tuple(item + 1, extent.Item2); + toAddTwo = new Tuple(item + 1, extent.Item2); break; } diff --git a/Extents/ExtentsULong.cs b/Extents/ExtentsULong.cs index 71a82200c..09c76e8c8 100644 --- a/Extents/ExtentsULong.cs +++ b/Extents/ExtentsULong.cs @@ -135,7 +135,7 @@ namespace Extents { ulong realEnd; if(run) realEnd = start + end - 1; - else realEnd = end; + else realEnd = end; // TODO: Optimize this for(ulong t = start; t <= realEnd; t++) Add(t); @@ -177,7 +177,7 @@ namespace Extents { toRemove = extent; toAddOne = new Tuple(extent.Item1, item - 1); - toAddTwo = new Tuple(item + 1, extent.Item2); + toAddTwo = new Tuple(item + 1, extent.Item2); break; } diff --git a/Extents/ExtentsUShort.cs b/Extents/ExtentsUShort.cs index fa6122c1f..6a8689cf0 100644 --- a/Extents/ExtentsUShort.cs +++ b/Extents/ExtentsUShort.cs @@ -135,7 +135,7 @@ namespace Extents { ushort realEnd; if(run) realEnd = (ushort)(start + end - 1); - else realEnd = end; + else realEnd = end; // TODO: Optimize this for(ushort t = start; t <= realEnd; t++) Add(t); @@ -177,7 +177,7 @@ namespace Extents { toRemove = extent; toAddOne = new Tuple(extent.Item1, (ushort)(item - 1)); - toAddTwo = new Tuple((ushort)(item + 1), extent.Item2); + toAddTwo = new Tuple((ushort)(item + 1), extent.Item2); break; } diff --git a/PrintHex.cs b/PrintHex.cs index 0cd4f144b..551beefaa 100644 --- a/PrintHex.cs +++ b/PrintHex.cs @@ -57,7 +57,7 @@ namespace DiscImageChef { StringBuilder sb = new StringBuilder(); - int counter = 0; + int counter = 0; int subcounter = 0; for(long i = 0; i < array.LongLength; i++) { @@ -84,7 +84,7 @@ namespace DiscImageChef if(counter == width - 1) { - counter = 0; + counter = 0; subcounter = 0; } else counter++; diff --git a/StringHandlers.cs b/StringHandlers.cs index 8ab0e350f..ad2fb0cb5 100644 --- a/StringHandlers.cs +++ b/StringHandlers.cs @@ -71,10 +71,12 @@ namespace DiscImageChef len++; break; } + // if((i + 1) == CString.Length) // break; } - else break; + else + break; len++; } @@ -107,7 +109,7 @@ namespace DiscImageChef if(PascalString == null) return null; byte length = PascalString[start]; - int len = 0; + int len = 0; for(int i = start + 1; i < length + 1 && i < PascalString.Length; i++) { @@ -166,15 +168,15 @@ namespace DiscImageChef public static string DecompressUnicode(byte[] dstring) { ushort unicode; - byte compId = dstring[0]; - string temp = ""; + byte compId = dstring[0]; + string temp = ""; if(compId != 8 && compId != 16) return null; for(int byteIndex = 1; byteIndex < dstring.Length;) { if(compId == 16) unicode = (ushort)(dstring[byteIndex++] << 8); - else unicode = 0; + else unicode = 0; if(byteIndex < dstring.Length) unicode |= dstring[byteIndex++]; diff --git a/Swapping.cs b/Swapping.cs index 75bec257e..cf52121eb 100644 --- a/Swapping.cs +++ b/Swapping.cs @@ -107,7 +107,7 @@ namespace DiscImageChef { x = ((x & 0x00000000FFFFFFFF) << 32) | ((x & 0xFFFFFFFF00000000) >> 32); x = ((x & 0x0000FFFF0000FFFF) << 16) | ((x & 0xFFFF0000FFFF0000) >> 16); - x = ((x & 0x00FF00FF00FF00FF) << 8) | ((x & 0xFF00FF00FF00FF00) >> 8); + x = ((x & 0x00FF00FF00FF00FF) << 8) | ((x & 0xFF00FF00FF00FF00) >> 8); return x; }