diff --git a/ArrayFill.cs b/ArrayFill.cs index 6cc52325f..733a35136 100644 --- a/ArrayFill.cs +++ b/ArrayFill.cs @@ -34,15 +34,12 @@ namespace DiscImageChef public static void ArrayFill(T[] destinationArray, T value) { // if called with a single value, wrap the value in an array and call the main function - ArrayFill(destinationArray, new T[] { value }); + ArrayFill(destinationArray, new T[] {value}); } public static void ArrayFill(T[] destinationArray, T[] value) { - if(destinationArray == null) - { - throw new ArgumentNullException(nameof(destinationArray)); - } + if(destinationArray == null) { throw new ArgumentNullException(nameof(destinationArray)); } if(value.Length > destinationArray.Length) { @@ -71,11 +68,9 @@ namespace DiscImageChef public static string ByteArrayToHex(byte[] array, bool upper) { StringBuilder sb = new StringBuilder(); - for(long i = 0; i < array.LongLength; i++) - sb.AppendFormat("{0:x2}", array[i]); + for(long i = 0; i < array.LongLength; i++) sb.AppendFormat("{0:x2}", array[i]); return upper ? sb.ToString().ToUpper() : sb.ToString(); } } -} - +} \ No newline at end of file diff --git a/ArrayIsEmpty.cs b/ArrayIsEmpty.cs index 41df20741..b83f8b10c 100644 --- a/ArrayIsEmpty.cs +++ b/ArrayIsEmpty.cs @@ -36,27 +36,20 @@ namespace DiscImageChef { public static bool ArrayIsNullOrWhiteSpace(byte[] array) { - if(array == null) - return true; + if(array == null) return true; - foreach(byte b in array) - if(b != 0x00 && b != 0x20) - return false; + foreach(byte b in array) if(b != 0x00 && b != 0x20) return false; return true; } public static bool ArrayIsNullOrEmpty(byte[] array) { - if(array == null) - return true; + if(array == null) return true; - foreach(byte b in array) - if(b != 0x00) - return false; + foreach(byte b in array) if(b != 0x00) return false; return true; } } -} - +} \ No newline at end of file diff --git a/BigEndianBitConverter.cs b/BigEndianBitConverter.cs index 91a995dad..46d0706f1 100644 --- a/BigEndianBitConverter.cs +++ b/BigEndianBitConverter.cs @@ -48,6 +48,7 @@ namespace DiscImageChef /// architecture. /// public static bool IsLittleEndian { get; set; } + // should default to false, which is what we want for Empire /// /// Converts the specified double-precision floating point number to a 64-bit @@ -362,7 +363,9 @@ namespace DiscImageChef /// public static short ToInt16(byte[] value, int startIndex) { - return !IsLittleEndian ? BitConverter.ToInt16(value, startIndex) : BitConverter.ToInt16(value.Reverse().ToArray(), value.Length - sizeof(short) - startIndex); + return !IsLittleEndian + ? BitConverter.ToInt16(value, startIndex) + : BitConverter.ToInt16(value.Reverse().ToArray(), value.Length - sizeof(short) - startIndex); } /// @@ -393,7 +396,9 @@ namespace DiscImageChef /// public static int ToInt32(byte[] value, int startIndex) { - return !IsLittleEndian ? BitConverter.ToInt32(value, startIndex) : BitConverter.ToInt32(value.Reverse().ToArray(), value.Length - sizeof(int) - startIndex); + return !IsLittleEndian + ? BitConverter.ToInt32(value, startIndex) + : BitConverter.ToInt32(value.Reverse().ToArray(), value.Length - sizeof(int) - startIndex); } /// @@ -424,7 +429,9 @@ namespace DiscImageChef /// public static long ToInt64(byte[] value, int startIndex) { - return !IsLittleEndian ? BitConverter.ToInt64(value, startIndex) : BitConverter.ToInt64(value.Reverse().ToArray(), value.Length - sizeof(long) - startIndex); + return !IsLittleEndian + ? BitConverter.ToInt64(value, startIndex) + : BitConverter.ToInt64(value.Reverse().ToArray(), value.Length - sizeof(long) - startIndex); } /// @@ -456,7 +463,9 @@ namespace DiscImageChef /// public static float ToSingle(byte[] value, int startIndex) { - return !IsLittleEndian ? BitConverter.ToSingle(value, startIndex) : BitConverter.ToSingle(value.Reverse().ToArray(), value.Length - sizeof(float) - startIndex); + return !IsLittleEndian + ? BitConverter.ToSingle(value, startIndex) + : BitConverter.ToSingle(value.Reverse().ToArray(), value.Length - sizeof(float) - startIndex); } /// @@ -507,7 +516,9 @@ namespace DiscImageChef /// public static string ToString(byte[] value, int startIndex) { - return !IsLittleEndian ? BitConverter.ToString(value, startIndex) : BitConverter.ToString(value.Reverse().ToArray(), startIndex); + return !IsLittleEndian + ? BitConverter.ToString(value, startIndex) + : BitConverter.ToString(value.Reverse().ToArray(), startIndex); } /// @@ -545,7 +556,9 @@ namespace DiscImageChef /// public static string ToString(byte[] value, int startIndex, int length) { - return !IsLittleEndian ? BitConverter.ToString(value, startIndex, length) : BitConverter.ToString(value.Reverse().ToArray(), startIndex, length); + return !IsLittleEndian + ? BitConverter.ToString(value, startIndex, length) + : BitConverter.ToString(value.Reverse().ToArray(), startIndex, length); } /// @@ -575,7 +588,9 @@ namespace DiscImageChef /// public static ushort ToUInt16(byte[] value, int startIndex) { - return !IsLittleEndian ? BitConverter.ToUInt16(value, startIndex) : BitConverter.ToUInt16(value.Reverse().ToArray(), value.Length - sizeof(ushort) - startIndex); + return !IsLittleEndian + ? BitConverter.ToUInt16(value, startIndex) + : BitConverter.ToUInt16(value.Reverse().ToArray(), value.Length - sizeof(ushort) - startIndex); } /// @@ -606,7 +621,9 @@ namespace DiscImageChef /// public static uint ToUInt32(byte[] value, int startIndex) { - return !IsLittleEndian ? BitConverter.ToUInt32(value, startIndex) : BitConverter.ToUInt32(value.Reverse().ToArray(), value.Length - sizeof(uint) - startIndex); + return !IsLittleEndian + ? BitConverter.ToUInt32(value, startIndex) + : BitConverter.ToUInt32(value.Reverse().ToArray(), value.Length - sizeof(uint) - startIndex); } /// @@ -637,18 +654,17 @@ namespace DiscImageChef /// public static ulong ToUInt64(byte[] value, int startIndex) { - return !IsLittleEndian ? BitConverter.ToUInt64(value, startIndex) : BitConverter.ToUInt64(value.Reverse().ToArray(), value.Length - sizeof(ulong) - startIndex); + return !IsLittleEndian + ? 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]); + 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]); } } } \ No newline at end of file diff --git a/BigEndianMarshal.cs b/BigEndianMarshal.cs index 548a35bde..84fadb932 100644 --- a/BigEndianMarshal.cs +++ b/BigEndianMarshal.cs @@ -124,8 +124,8 @@ namespace DiscImageChef fi.SetValueDirect(__makeref(str), BitConverter.ToDouble(dbl_r, 0)); } } + return str; } } -} - +} \ No newline at end of file diff --git a/CHS.cs b/CHS.cs index 34e4cebca..869669143 100644 --- a/CHS.cs +++ b/CHS.cs @@ -36,7 +36,9 @@ 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 * maxHead + head) * maxSector + sector - 1; + return maxHead == 0 || maxSector == 0 + ? (cyl * 16 + head) * 63 + sector - 1 + : (cyl * maxHead + head) * maxSector + sector - 1; } } -} +} \ No newline at end of file diff --git a/CompareBytes.cs b/CompareBytes.cs index 9712b01e3..776fffa33 100644 --- a/CompareBytes.cs +++ b/CompareBytes.cs @@ -34,7 +34,8 @@ namespace DiscImageChef { public static partial class ArrayHelpers { - public static void CompareBytes(out bool different, out bool sameSize, byte[] compareArray1, byte[] compareArray2) + public static void CompareBytes(out bool different, out bool sameSize, byte[] compareArray1, + byte[] compareArray2) { different = false; sameSize = true; @@ -50,8 +51,7 @@ namespace DiscImageChef sameSize = false; leastBytes = compareArray2.LongLength; } - else - leastBytes = compareArray1.LongLength; + else leastBytes = compareArray1.LongLength; for(long i = 0; i < leastBytes; i++) { @@ -63,4 +63,4 @@ namespace DiscImageChef } } } -} +} \ No newline at end of file diff --git a/CountBits.cs b/CountBits.cs index 0a377d6fe..29a153fb4 100644 --- a/CountBits.cs +++ b/CountBits.cs @@ -41,4 +41,4 @@ namespace DiscImageChef.Helpers return (int)((((number + (number >> 4)) & 0x0F0F0F0F) * 0x01010101) >> 24); } } -} +} \ No newline at end of file diff --git a/DateHandlers.cs b/DateHandlers.cs index 5399d6cae..87160d81e 100644 --- a/DateHandlers.cs +++ b/DateHandlers.cs @@ -99,55 +99,58 @@ namespace DiscImageChef fourcharvalue[1] = VDDateTime[1]; fourcharvalue[2] = VDDateTime[2]; fourcharvalue[3] = VDDateTime[3]; - DicConsole.DebugWriteLine("ISO9600ToDateTime handler", "year = \"{0}\"", StringHandlers.CToString(fourcharvalue, Encoding.ASCII)); - if(!int.TryParse(StringHandlers.CToString(fourcharvalue, Encoding.ASCII), out year)) - year = 0; + DicConsole.DebugWriteLine("ISO9600ToDateTime handler", "year = \"{0}\"", + StringHandlers.CToString(fourcharvalue, Encoding.ASCII)); + if(!int.TryParse(StringHandlers.CToString(fourcharvalue, Encoding.ASCII), out year)) year = 0; // year = Convert.ToInt32(StringHandlers.CToString(fourcharvalue, Encoding.ASCII)); twocharvalue[0] = VDDateTime[4]; twocharvalue[1] = VDDateTime[5]; - DicConsole.DebugWriteLine("ISO9600ToDateTime handler", "month = \"{0}\"", StringHandlers.CToString(twocharvalue, Encoding.ASCII)); - if(!int.TryParse(StringHandlers.CToString(twocharvalue, Encoding.ASCII), out month)) - month = 0; + DicConsole.DebugWriteLine("ISO9600ToDateTime handler", "month = \"{0}\"", + StringHandlers.CToString(twocharvalue, Encoding.ASCII)); + if(!int.TryParse(StringHandlers.CToString(twocharvalue, Encoding.ASCII), out month)) month = 0; // month = Convert.ToInt32(StringHandlers.CToString(twocharvalue, Encoding.ASCII)); twocharvalue[0] = VDDateTime[6]; twocharvalue[1] = VDDateTime[7]; - DicConsole.DebugWriteLine("ISO9600ToDateTime handler", "day = \"{0}\"", StringHandlers.CToString(twocharvalue, Encoding.ASCII)); - if(!int.TryParse(StringHandlers.CToString(twocharvalue, Encoding.ASCII), out day)) - day = 0; + DicConsole.DebugWriteLine("ISO9600ToDateTime handler", "day = \"{0}\"", + StringHandlers.CToString(twocharvalue, Encoding.ASCII)); + if(!int.TryParse(StringHandlers.CToString(twocharvalue, Encoding.ASCII), out day)) day = 0; // day = Convert.ToInt32(StringHandlers.CToString(twocharvalue, Encoding.ASCII)); twocharvalue[0] = VDDateTime[8]; twocharvalue[1] = VDDateTime[9]; - DicConsole.DebugWriteLine("ISO9600ToDateTime handler", "hour = \"{0}\"", StringHandlers.CToString(twocharvalue, Encoding.ASCII)); - if(!int.TryParse(StringHandlers.CToString(twocharvalue, Encoding.ASCII), out hour)) - hour = 0; + DicConsole.DebugWriteLine("ISO9600ToDateTime handler", "hour = \"{0}\"", + StringHandlers.CToString(twocharvalue, Encoding.ASCII)); + if(!int.TryParse(StringHandlers.CToString(twocharvalue, Encoding.ASCII), out hour)) hour = 0; // hour = Convert.ToInt32(StringHandlers.CToString(twocharvalue, Encoding.ASCII)); twocharvalue[0] = VDDateTime[10]; twocharvalue[1] = VDDateTime[11]; - DicConsole.DebugWriteLine("ISO9600ToDateTime handler", "minute = \"{0}\"", StringHandlers.CToString(twocharvalue, Encoding.ASCII)); - if(!int.TryParse(StringHandlers.CToString(twocharvalue, Encoding.ASCII), out minute)) - minute = 0; + DicConsole.DebugWriteLine("ISO9600ToDateTime handler", "minute = \"{0}\"", + StringHandlers.CToString(twocharvalue, Encoding.ASCII)); + if(!int.TryParse(StringHandlers.CToString(twocharvalue, Encoding.ASCII), out minute)) minute = 0; // minute = Convert.ToInt32(StringHandlers.CToString(twocharvalue, Encoding.ASCII)); twocharvalue[0] = VDDateTime[12]; twocharvalue[1] = VDDateTime[13]; - DicConsole.DebugWriteLine("ISO9600ToDateTime handler", "second = \"{0}\"", StringHandlers.CToString(twocharvalue, Encoding.ASCII)); - if(!int.TryParse(StringHandlers.CToString(twocharvalue, Encoding.ASCII), out second)) - second = 0; + DicConsole.DebugWriteLine("ISO9600ToDateTime handler", "second = \"{0}\"", + StringHandlers.CToString(twocharvalue, Encoding.ASCII)); + if(!int.TryParse(StringHandlers.CToString(twocharvalue, Encoding.ASCII), out second)) second = 0; // second = Convert.ToInt32(StringHandlers.CToString(twocharvalue, Encoding.ASCII)); twocharvalue[0] = VDDateTime[14]; twocharvalue[1] = VDDateTime[15]; - DicConsole.DebugWriteLine("ISO9600ToDateTime handler", "hundredths = \"{0}\"", StringHandlers.CToString(twocharvalue, Encoding.ASCII)); - if(!int.TryParse(StringHandlers.CToString(twocharvalue, Encoding.ASCII), out hundredths)) - hundredths = 0; + DicConsole.DebugWriteLine("ISO9600ToDateTime handler", "hundredths = \"{0}\"", + StringHandlers.CToString(twocharvalue, Encoding.ASCII)); + if(!int.TryParse(StringHandlers.CToString(twocharvalue, Encoding.ASCII), out hundredths)) hundredths = 0; // hundredths = Convert.ToInt32(StringHandlers.CToString(twocharvalue, Encoding.ASCII)); - 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); + 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); return decodedDT; } @@ -172,7 +175,9 @@ namespace DiscImageChef int day = (dateRecord & 0x01F0) >> 4; int month = (dateRecord & 0x000F); - DicConsole.DebugWriteLine("UCSDPascalToDateTime handler", "dateRecord = 0x{0:X4}, year = {1}, month = {2}, day = {3}", dateRecord, year, month, day); + DicConsole.DebugWriteLine("UCSDPascalToDateTime handler", + "dateRecord = 0x{0:X4}, year = {1}, month = {2}, day = {3}", dateRecord, year, + month, day); return new DateTime(year, month, day); } @@ -185,18 +190,15 @@ namespace DiscImageChef int minute = (time & 0x7E0) >> 5; int second = (time & 0x1F) * 2; - DicConsole.DebugWriteLine("DOSToDateTime handler", "date = 0x{0:X4}, year = {1}, month = {2}, day = {3}", date, year, month, day); - DicConsole.DebugWriteLine("DOSToDateTime handler", "time = 0x{0:X4}, hour = {1}, minute = {2}, second = {3}", time, hour, minute, second); + DicConsole.DebugWriteLine("DOSToDateTime handler", "date = 0x{0:X4}, year = {1}, month = {2}, day = {3}", + date, year, month, day); + DicConsole.DebugWriteLine("DOSToDateTime handler", + "time = 0x{0:X4}, hour = {1}, minute = {2}, second = {3}", time, hour, minute, + second); DateTime dosdate; - try - { - dosdate = new DateTime(year, month, day, hour, minute, second); - } - catch(ArgumentOutOfRangeException) - { - dosdate = new DateTime(1980, 1, 1, 0, 0, 0); - } + try { dosdate = new DateTime(year, month, day, hour, minute, second); } + catch(ArgumentOutOfRangeException) { dosdate = new DateTime(1980, 1, 1, 0, 0, 0); } return dosdate; } @@ -219,7 +221,9 @@ namespace DiscImageChef return AppleDoubleEpoch.AddSeconds(AppleDoubleTimeStamp); } - 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; @@ -229,20 +233,16 @@ namespace DiscImageChef ushort preOffset = (ushort)(typeAndTimeZone & 0xFFF); short offset; - if((preOffset & 0x800) == 0x800) - { - offset = (short)(preOffset | 0xF000); - } - else - offset = (short)(preOffset & 0x7FF); + if((preOffset & 0x800) == 0x800) { offset = (short)(preOffset | 0xF000); } + else offset = (short)(preOffset & 0x7FF); if(offset == -2047) return new DateTime(year, month, day, hour, minute, second, DateTimeKind.Unspecified).AddTicks(ticks); - if(offset < -1440 || offset > 1440) - offset = 0; + if(offset < -1440 || offset > 1440) offset = 0; - return new DateTimeOffset(year, month, day, hour, minute, second, new TimeSpan(0, offset, 0)).AddTicks(ticks).DateTime; + return new DateTimeOffset(year, month, day, hour, minute, second, new TimeSpan(0, offset, 0)) + .AddTicks(ticks).DateTime; } public static DateTime UNIXHrTimeToDateTime(ulong HRTimeStamp) @@ -252,27 +252,24 @@ namespace DiscImageChef public static DateTime OS9ToDateTime(byte[] date) { - if(date == null || (date.Length != 3 && date.Length != 5)) - return DateTime.MinValue; + if(date == null || (date.Length != 3 && date.Length != 5)) return DateTime.MinValue; DateTime os9date; try { - 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); - } - catch(ArgumentOutOfRangeException) - { - os9date = new DateTime(1900, 0, 0, 0, 0, 0); + 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); } + catch(ArgumentOutOfRangeException) { os9date = new DateTime(1900, 0, 0, 0, 0, 0); } return os9date; } public static DateTime LifToDateTime(byte[] date) { - if(date == null || date.Length != 6) - return new DateTime(1970, 1, 1, 0, 0, 0); + if(date == null || date.Length != 6) return new DateTime(1970, 1, 1, 0, 0, 0); return LifToDateTime(date[0], date[1], date[2], date[3], date[4], date[5]); } @@ -288,18 +285,12 @@ namespace DiscImageChef int ihour = (hour >> 4) * 10 + (hour & 0xF); int isecond = (second >> 4) * 10 + (second & 0xF); - if(iyear >= 70) - iyear += 1900; - else - iyear += 2000; + if(iyear >= 70) iyear += 1900; + else iyear += 2000; return new DateTime(iyear, imonth, iday, ihour, iminute, isecond); } - catch(ArgumentOutOfRangeException) - { - return new DateTime(1970, 1, 1, 0, 0, 0); - } + catch(ArgumentOutOfRangeException) { return new DateTime(1970, 1, 1, 0, 0, 0); } } } -} - +} \ No newline at end of file diff --git a/EndianAwareBinaryReader.cs b/EndianAwareBinaryReader.cs index 194ad7f25..b0d6366ff 100644 --- a/EndianAwareBinaryReader.cs +++ b/EndianAwareBinaryReader.cs @@ -41,86 +41,76 @@ namespace DiscImageChef { readonly byte[] buffer = new byte[8]; - public EndianAwareBinaryReader(Stream input, Encoding encoding, bool isLittleEndian) - : base(input, encoding) + public EndianAwareBinaryReader(Stream input, Encoding encoding, bool isLittleEndian) : base(input, encoding) { IsLittleEndian = isLittleEndian; } - public EndianAwareBinaryReader(Stream input, bool isLittleEndian) - : this(input, Encoding.UTF8, isLittleEndian) - { - } + public EndianAwareBinaryReader(Stream input, bool isLittleEndian) : + this(input, Encoding.UTF8, isLittleEndian) { } - public bool IsLittleEndian - { - get; - set; - } + public bool IsLittleEndian { get; set; } public override double ReadDouble() { - if(IsLittleEndian) - return base.ReadDouble(); + if(IsLittleEndian) return base.ReadDouble(); + FillMyBuffer(8); return BitConverter.ToDouble(buffer.Take(8).Reverse().ToArray(), 0); } public override short ReadInt16() { - if(IsLittleEndian) - return base.ReadInt16(); + if(IsLittleEndian) return base.ReadInt16(); + FillMyBuffer(2); return BitConverter.ToInt16(buffer.Take(2).Reverse().ToArray(), 0); - } public override int ReadInt32() { - if(IsLittleEndian) - return base.ReadInt32(); + if(IsLittleEndian) return base.ReadInt32(); + FillMyBuffer(4); return BitConverter.ToInt32(buffer.Take(4).Reverse().ToArray(), 0); - } public override long ReadInt64() { - if(IsLittleEndian) - return base.ReadInt64(); + if(IsLittleEndian) return base.ReadInt64(); + FillMyBuffer(8); return BitConverter.ToInt64(buffer.Take(8).Reverse().ToArray(), 0); - } public override float ReadSingle() { - if(IsLittleEndian) - return base.ReadSingle(); + if(IsLittleEndian) return base.ReadSingle(); + FillMyBuffer(4); return BitConverter.ToSingle(buffer.Take(4).Reverse().ToArray(), 0); } public override ushort ReadUInt16() { - if(IsLittleEndian) - return base.ReadUInt16(); + if(IsLittleEndian) return base.ReadUInt16(); + FillMyBuffer(2); return BitConverter.ToUInt16(buffer.Take(2).Reverse().ToArray(), 0); } public override uint ReadUInt32() { - if(IsLittleEndian) - return base.ReadUInt32(); + if(IsLittleEndian) return base.ReadUInt32(); + FillMyBuffer(4); return BitConverter.ToUInt32(buffer.Take(4).Reverse().ToArray(), 0); } public override ulong ReadUInt64() { - if(IsLittleEndian) - return base.ReadUInt64(); + if(IsLittleEndian) return base.ReadUInt64(); + FillMyBuffer(8); return BitConverter.ToUInt64(buffer.Take(8).Reverse().ToArray(), 0); } @@ -132,10 +122,8 @@ namespace DiscImageChef if(numBytes == 1) { num2 = BaseStream.ReadByte(); - if(num2 == -1) - { - throw new EndOfStreamException("Attempted to read past the end of the stream."); - } + if(num2 == -1) { throw new EndOfStreamException("Attempted to read past the end of the stream."); } + buffer[0] = (byte)num2; } else @@ -143,10 +131,8 @@ namespace DiscImageChef do { num2 = BaseStream.Read(buffer, offset, numBytes - offset); - if(num2 == 0) - { - throw new EndOfStreamException("Attempted to read past the end of the stream."); - } + if(num2 == 0) { throw new EndOfStreamException("Attempted to read past the end of the stream."); } + offset += num2; } while(offset < numBytes); diff --git a/Extents/ExtentsByte.cs b/Extents/ExtentsByte.cs index 0d948ac52..59a38066c 100644 --- a/Extents/ExtentsByte.cs +++ b/Extents/ExtentsByte.cs @@ -50,7 +50,10 @@ namespace Extents backend = list.OrderBy(t => t.Item1).ToList(); } - public int Count { get { return backend.Count; } } + public int Count + { + get { return backend.Count; } + } public void Add(byte item) { @@ -61,8 +64,7 @@ namespace Extents for(int i = 0; i < backend.Count; i++) { // Already contained in an extent - if(item >= backend[i].Item1 && item <= backend[i].Item2) - return; + if(item >= backend[i].Item1 && item <= backend[i].Item2) return; // Expands existing extent start if(item == backend[i].Item1 - 1) @@ -74,8 +76,7 @@ namespace Extents removeTwo = backend[i - 1]; itemToAdd = new Tuple(backend[i - 1].Item1, backend[i].Item2); } - else - itemToAdd = new Tuple(item, backend[i].Item2); + else itemToAdd = new Tuple(item, backend[i].Item2); break; } @@ -90,8 +91,7 @@ namespace Extents removeTwo = backend[i + 1]; itemToAdd = new Tuple(backend[i].Item1, backend[i + 1].Item2); } - else - itemToAdd = new Tuple(backend[i].Item1, item); + else itemToAdd = new Tuple(backend[i].Item1, item); break; } @@ -103,8 +103,7 @@ namespace Extents backend.Remove(removeTwo); backend.Add(itemToAdd); } - else - backend.Add(new Tuple(item, item)); + else backend.Add(new Tuple(item, item)); // Sort backend = backend.OrderBy(t => t.Item1).ToList(); @@ -118,21 +117,17 @@ namespace Extents public void Add(byte start, byte end, bool run) { byte realEnd; - if(run) - realEnd = (byte)(start + end - 1); - else - realEnd = end; + if(run) realEnd = (byte)(start + end - 1); + else realEnd = end; // TODO: Optimize this - for(byte t = start; t <= realEnd; t++) - Add(t); + for(byte t = start; t <= realEnd; t++) Add(t); } public bool Contains(byte item) { - foreach(Tuple extent in backend) - if(item >= extent.Item1 && item <= extent.Item2) - return true; + foreach(Tuple extent in backend) if(item >= extent.Item1 && item <= extent.Item2) return true; + return false; } @@ -183,14 +178,11 @@ namespace Extents } // Item not found - if(toRemove == null) - return false; + if(toRemove == null) return false; backend.Remove(toRemove); - if(toAddOne != null) - backend.Add(toAddOne); - if(toAddTwo != null) - backend.Add(toAddTwo); + if(toAddOne != null) backend.Add(toAddOne); + if(toAddTwo != null) backend.Add(toAddTwo); // Sort backend = backend.OrderBy(t => t.Item1).ToList(); @@ -214,7 +206,8 @@ namespace Extents return true; } } + return false; } } -} +} \ No newline at end of file diff --git a/Extents/ExtentsInt.cs b/Extents/ExtentsInt.cs index 6e6842f30..bbdab8ab9 100644 --- a/Extents/ExtentsInt.cs +++ b/Extents/ExtentsInt.cs @@ -50,7 +50,10 @@ namespace Extents backend = list.OrderBy(t => t.Item1).ToList(); } - public int Count { get { return backend.Count; } } + public int Count + { + get { return backend.Count; } + } public void Add(int item) { @@ -61,8 +64,7 @@ namespace Extents for(int i = 0; i < backend.Count; i++) { // Already contained in an extent - if(item >= backend[i].Item1 && item <= backend[i].Item2) - return; + if(item >= backend[i].Item1 && item <= backend[i].Item2) return; // Expands existing extent start if(item == backend[i].Item1 - 1) @@ -74,8 +76,7 @@ namespace Extents removeTwo = backend[i - 1]; itemToAdd = new Tuple(backend[i - 1].Item1, backend[i].Item2); } - else - itemToAdd = new Tuple(item, backend[i].Item2); + else itemToAdd = new Tuple(item, backend[i].Item2); break; } @@ -90,8 +91,7 @@ namespace Extents removeTwo = backend[i + 1]; itemToAdd = new Tuple(backend[i].Item1, backend[i + 1].Item2); } - else - itemToAdd = new Tuple(backend[i].Item1, item); + else itemToAdd = new Tuple(backend[i].Item1, item); break; } @@ -103,8 +103,7 @@ namespace Extents backend.Remove(removeTwo); backend.Add(itemToAdd); } - else - backend.Add(new Tuple(item, item)); + else backend.Add(new Tuple(item, item)); // Sort backend = backend.OrderBy(t => t.Item1).ToList(); @@ -118,21 +117,17 @@ namespace Extents public void Add(int start, int end, bool run) { int realEnd; - if(run) - realEnd = start + end - 1; - else - realEnd = end; + if(run) realEnd = start + end - 1; + else realEnd = end; // TODO: Optimize this - for(int t = start; t <= realEnd; t++) - Add(t); + for(int t = start; t <= realEnd; t++) Add(t); } public bool Contains(int item) { - foreach(Tuple extent in backend) - if(item >= extent.Item1 && item <= extent.Item2) - return true; + foreach(Tuple extent in backend) if(item >= extent.Item1 && item <= extent.Item2) return true; + return false; } @@ -183,14 +178,11 @@ namespace Extents } // Item not found - if(toRemove == null) - return false; + if(toRemove == null) return false; backend.Remove(toRemove); - if(toAddOne != null) - backend.Add(toAddOne); - if(toAddTwo != null) - backend.Add(toAddTwo); + if(toAddOne != null) backend.Add(toAddOne); + if(toAddTwo != null) backend.Add(toAddTwo); // Sort backend = backend.OrderBy(t => t.Item1).ToList(); @@ -214,7 +206,8 @@ namespace Extents return true; } } + return false; } } -} +} \ No newline at end of file diff --git a/Extents/ExtentsLong.cs b/Extents/ExtentsLong.cs index c139ee24e..b29e53639 100644 --- a/Extents/ExtentsLong.cs +++ b/Extents/ExtentsLong.cs @@ -50,7 +50,10 @@ namespace Extents backend = list.OrderBy(t => t.Item1).ToList(); } - public int Count { get { return backend.Count; } } + public int Count + { + get { return backend.Count; } + } public void Add(long item) { @@ -61,8 +64,7 @@ namespace Extents for(int i = 0; i < backend.Count; i++) { // Already contained in an extent - if(item >= backend[i].Item1 && item <= backend[i].Item2) - return; + if(item >= backend[i].Item1 && item <= backend[i].Item2) return; // Expands existing extent start if(item == backend[i].Item1 - 1) @@ -74,8 +76,7 @@ namespace Extents removeTwo = backend[i - 1]; itemToAdd = new Tuple(backend[i - 1].Item1, backend[i].Item2); } - else - itemToAdd = new Tuple(item, backend[i].Item2); + else itemToAdd = new Tuple(item, backend[i].Item2); break; } @@ -90,8 +91,7 @@ namespace Extents removeTwo = backend[i + 1]; itemToAdd = new Tuple(backend[i].Item1, backend[i + 1].Item2); } - else - itemToAdd = new Tuple(backend[i].Item1, item); + else itemToAdd = new Tuple(backend[i].Item1, item); break; } @@ -103,8 +103,7 @@ namespace Extents backend.Remove(removeTwo); backend.Add(itemToAdd); } - else - backend.Add(new Tuple(item, item)); + else backend.Add(new Tuple(item, item)); // Sort backend = backend.OrderBy(t => t.Item1).ToList(); @@ -118,21 +117,17 @@ namespace Extents public void Add(long start, long end, bool run) { long realEnd; - if(run) - realEnd = start + end - 1; - else - realEnd = end; + if(run) realEnd = start + end - 1; + else realEnd = end; // TODO: Optimize this - for(long t = start; t <= realEnd; t++) - Add(t); + for(long t = start; t <= realEnd; t++) Add(t); } public bool Contains(long item) { - foreach(Tuple extent in backend) - if(item >= extent.Item1 && item <= extent.Item2) - return true; + foreach(Tuple extent in backend) if(item >= extent.Item1 && item <= extent.Item2) return true; + return false; } @@ -183,14 +178,11 @@ namespace Extents } // Item not found - if(toRemove == null) - return false; + if(toRemove == null) return false; backend.Remove(toRemove); - if(toAddOne != null) - backend.Add(toAddOne); - if(toAddTwo != null) - backend.Add(toAddTwo); + if(toAddOne != null) backend.Add(toAddOne); + if(toAddTwo != null) backend.Add(toAddTwo); // Sort backend = backend.OrderBy(t => t.Item1).ToList(); @@ -214,7 +206,8 @@ namespace Extents return true; } } + return false; } } -} +} \ No newline at end of file diff --git a/Extents/ExtentsSByte.cs b/Extents/ExtentsSByte.cs index b67a2c3c6..df33ce34f 100644 --- a/Extents/ExtentsSByte.cs +++ b/Extents/ExtentsSByte.cs @@ -50,7 +50,10 @@ namespace Extents backend = list.OrderBy(t => t.Item1).ToList(); } - public int Count { get { return backend.Count; } } + public int Count + { + get { return backend.Count; } + } public void Add(sbyte item) { @@ -61,8 +64,7 @@ namespace Extents for(int i = 0; i < backend.Count; i++) { // Already contained in an extent - if(item >= backend[i].Item1 && item <= backend[i].Item2) - return; + if(item >= backend[i].Item1 && item <= backend[i].Item2) return; // Expands existing extent start if(item == backend[i].Item1 - 1) @@ -74,8 +76,7 @@ namespace Extents removeTwo = backend[i - 1]; itemToAdd = new Tuple(backend[i - 1].Item1, backend[i].Item2); } - else - itemToAdd = new Tuple(item, backend[i].Item2); + else itemToAdd = new Tuple(item, backend[i].Item2); break; } @@ -90,8 +91,7 @@ namespace Extents removeTwo = backend[i + 1]; itemToAdd = new Tuple(backend[i].Item1, backend[i + 1].Item2); } - else - itemToAdd = new Tuple(backend[i].Item1, item); + else itemToAdd = new Tuple(backend[i].Item1, item); break; } @@ -103,8 +103,7 @@ namespace Extents backend.Remove(removeTwo); backend.Add(itemToAdd); } - else - backend.Add(new Tuple(item, item)); + else backend.Add(new Tuple(item, item)); // Sort backend = backend.OrderBy(t => t.Item1).ToList(); @@ -118,21 +117,17 @@ namespace Extents public void Add(sbyte start, sbyte end, bool run) { sbyte realEnd; - if(run) - realEnd = (sbyte)(start + end - 1); - else - realEnd = end; + if(run) realEnd = (sbyte)(start + end - 1); + else realEnd = end; // TODO: Optimize this - for(sbyte t = start; t <= realEnd; t++) - Add(t); + for(sbyte t = start; t <= realEnd; t++) Add(t); } public bool Contains(sbyte item) { - foreach(Tuple extent in backend) - if(item >= extent.Item1 && item <= extent.Item2) - return true; + foreach(Tuple extent in backend) if(item >= extent.Item1 && item <= extent.Item2) return true; + return false; } @@ -183,14 +178,11 @@ namespace Extents } // Item not found - if(toRemove == null) - return false; + if(toRemove == null) return false; backend.Remove(toRemove); - if(toAddOne != null) - backend.Add(toAddOne); - if(toAddTwo != null) - backend.Add(toAddTwo); + if(toAddOne != null) backend.Add(toAddOne); + if(toAddTwo != null) backend.Add(toAddTwo); // Sort backend = backend.OrderBy(t => t.Item1).ToList(); @@ -214,7 +206,8 @@ namespace Extents return true; } } + return false; } } -} +} \ No newline at end of file diff --git a/Extents/ExtentsShort.cs b/Extents/ExtentsShort.cs index 62065c87a..943e4a55b 100644 --- a/Extents/ExtentsShort.cs +++ b/Extents/ExtentsShort.cs @@ -50,7 +50,10 @@ namespace Extents backend = list.OrderBy(t => t.Item1).ToList(); } - public int Count { get { return backend.Count; } } + public int Count + { + get { return backend.Count; } + } public void Add(short item) { @@ -61,8 +64,7 @@ namespace Extents for(int i = 0; i < backend.Count; i++) { // Already contained in an extent - if(item >= backend[i].Item1 && item <= backend[i].Item2) - return; + if(item >= backend[i].Item1 && item <= backend[i].Item2) return; // Expands existing extent start if(item == backend[i].Item1 - 1) @@ -74,8 +76,7 @@ namespace Extents removeTwo = backend[i - 1]; itemToAdd = new Tuple(backend[i - 1].Item1, backend[i].Item2); } - else - itemToAdd = new Tuple(item, backend[i].Item2); + else itemToAdd = new Tuple(item, backend[i].Item2); break; } @@ -90,8 +91,7 @@ namespace Extents removeTwo = backend[i + 1]; itemToAdd = new Tuple(backend[i].Item1, backend[i + 1].Item2); } - else - itemToAdd = new Tuple(backend[i].Item1, item); + else itemToAdd = new Tuple(backend[i].Item1, item); break; } @@ -103,8 +103,7 @@ namespace Extents backend.Remove(removeTwo); backend.Add(itemToAdd); } - else - backend.Add(new Tuple(item, item)); + else backend.Add(new Tuple(item, item)); // Sort backend = backend.OrderBy(t => t.Item1).ToList(); @@ -118,21 +117,17 @@ namespace Extents public void Add(short start, short end, bool run) { short realEnd; - if(run) - realEnd = (short)(start + end - 1); - else - realEnd = end; + if(run) realEnd = (short)(start + end - 1); + else realEnd = end; // TODO: Optimize this - for(short t = start; t <= realEnd; t++) - Add(t); + for(short t = start; t <= realEnd; t++) Add(t); } public bool Contains(short item) { - foreach(Tuple extent in backend) - if(item >= extent.Item1 && item <= extent.Item2) - return true; + foreach(Tuple extent in backend) if(item >= extent.Item1 && item <= extent.Item2) return true; + return false; } @@ -183,14 +178,11 @@ namespace Extents } // Item not found - if(toRemove == null) - return false; + if(toRemove == null) return false; backend.Remove(toRemove); - if(toAddOne != null) - backend.Add(toAddOne); - if(toAddTwo != null) - backend.Add(toAddTwo); + if(toAddOne != null) backend.Add(toAddOne); + if(toAddTwo != null) backend.Add(toAddTwo); // Sort backend = backend.OrderBy(t => t.Item1).ToList(); @@ -214,7 +206,8 @@ namespace Extents return true; } } + return false; } } -} +} \ No newline at end of file diff --git a/Extents/ExtentsUInt.cs b/Extents/ExtentsUInt.cs index 197eadfc7..ccda61f8e 100644 --- a/Extents/ExtentsUInt.cs +++ b/Extents/ExtentsUInt.cs @@ -50,7 +50,10 @@ namespace Extents backend = list.OrderBy(t => t.Item1).ToList(); } - public int Count { get { return backend.Count; } } + public int Count + { + get { return backend.Count; } + } public void Add(uint item) { @@ -61,8 +64,7 @@ namespace Extents for(int i = 0; i < backend.Count; i++) { // Already contained in an extent - if(item >= backend[i].Item1 && item <= backend[i].Item2) - return; + if(item >= backend[i].Item1 && item <= backend[i].Item2) return; // Expands existing extent start if(item == backend[i].Item1 - 1) @@ -74,8 +76,7 @@ namespace Extents removeTwo = backend[i - 1]; itemToAdd = new Tuple(backend[i - 1].Item1, backend[i].Item2); } - else - itemToAdd = new Tuple(item, backend[i].Item2); + else itemToAdd = new Tuple(item, backend[i].Item2); break; } @@ -90,8 +91,7 @@ namespace Extents removeTwo = backend[i + 1]; itemToAdd = new Tuple(backend[i].Item1, backend[i + 1].Item2); } - else - itemToAdd = new Tuple(backend[i].Item1, item); + else itemToAdd = new Tuple(backend[i].Item1, item); break; } @@ -103,8 +103,7 @@ namespace Extents backend.Remove(removeTwo); backend.Add(itemToAdd); } - else - backend.Add(new Tuple(item, item)); + else backend.Add(new Tuple(item, item)); // Sort backend = backend.OrderBy(t => t.Item1).ToList(); @@ -118,21 +117,17 @@ namespace Extents public void Add(uint start, uint end, bool run) { uint realEnd; - if(run) - realEnd = start + end - 1; - else - realEnd = end; + if(run) realEnd = start + end - 1; + else realEnd = end; // TODO: Optimize this - for(uint t = start; t <= realEnd; t++) - Add(t); + for(uint t = start; t <= realEnd; t++) Add(t); } public bool Contains(uint item) { - foreach(Tuple extent in backend) - if(item >= extent.Item1 && item <= extent.Item2) - return true; + foreach(Tuple extent in backend) if(item >= extent.Item1 && item <= extent.Item2) return true; + return false; } @@ -183,14 +178,11 @@ namespace Extents } // Item not found - if(toRemove == null) - return false; + if(toRemove == null) return false; backend.Remove(toRemove); - if(toAddOne != null) - backend.Add(toAddOne); - if(toAddTwo != null) - backend.Add(toAddTwo); + if(toAddOne != null) backend.Add(toAddOne); + if(toAddTwo != null) backend.Add(toAddTwo); // Sort backend = backend.OrderBy(t => t.Item1).ToList(); @@ -214,7 +206,8 @@ namespace Extents return true; } } + return false; } } -} +} \ No newline at end of file diff --git a/Extents/ExtentsULong.cs b/Extents/ExtentsULong.cs index f8aa06851..76a242ace 100644 --- a/Extents/ExtentsULong.cs +++ b/Extents/ExtentsULong.cs @@ -50,7 +50,10 @@ namespace Extents backend = list.OrderBy(t => t.Item1).ToList(); } - public int Count { get { return backend.Count; } } + public int Count + { + get { return backend.Count; } + } public void Add(ulong item) { @@ -61,8 +64,7 @@ namespace Extents for(int i = 0; i < backend.Count; i++) { // Already contained in an extent - if(item >= backend[i].Item1 && item <= backend[i].Item2) - return; + if(item >= backend[i].Item1 && item <= backend[i].Item2) return; // Expands existing extent start if(item == backend[i].Item1 - 1) @@ -74,8 +76,7 @@ namespace Extents removeTwo = backend[i - 1]; itemToAdd = new Tuple(backend[i - 1].Item1, backend[i].Item2); } - else - itemToAdd = new Tuple(item, backend[i].Item2); + else itemToAdd = new Tuple(item, backend[i].Item2); break; } @@ -90,8 +91,7 @@ namespace Extents removeTwo = backend[i + 1]; itemToAdd = new Tuple(backend[i].Item1, backend[i + 1].Item2); } - else - itemToAdd = new Tuple(backend[i].Item1, item); + else itemToAdd = new Tuple(backend[i].Item1, item); break; } @@ -103,8 +103,7 @@ namespace Extents backend.Remove(removeTwo); backend.Add(itemToAdd); } - else - backend.Add(new Tuple(item, item)); + else backend.Add(new Tuple(item, item)); // Sort backend = backend.OrderBy(t => t.Item1).ToList(); @@ -118,21 +117,17 @@ namespace Extents public void Add(ulong start, ulong end, bool run) { ulong realEnd; - if(run) - realEnd = start + end - 1; - else - realEnd = end; + if(run) realEnd = start + end - 1; + else realEnd = end; // TODO: Optimize this - for(ulong t = start; t <= realEnd; t++) - Add(t); + for(ulong t = start; t <= realEnd; t++) Add(t); } public bool Contains(ulong item) { - foreach(Tuple extent in backend) - if(item >= extent.Item1 && item <= extent.Item2) - return true; + foreach(Tuple extent in backend) if(item >= extent.Item1 && item <= extent.Item2) return true; + return false; } @@ -183,14 +178,11 @@ namespace Extents } // Item not found - if(toRemove == null) - return false; + if(toRemove == null) return false; backend.Remove(toRemove); - if(toAddOne != null) - backend.Add(toAddOne); - if(toAddTwo != null) - backend.Add(toAddTwo); + if(toAddOne != null) backend.Add(toAddOne); + if(toAddTwo != null) backend.Add(toAddTwo); // Sort backend = backend.OrderBy(t => t.Item1).ToList(); @@ -214,7 +206,8 @@ namespace Extents return true; } } + return false; } } -} +} \ No newline at end of file diff --git a/Extents/ExtentsUShort.cs b/Extents/ExtentsUShort.cs index 27b936f66..d8720d392 100644 --- a/Extents/ExtentsUShort.cs +++ b/Extents/ExtentsUShort.cs @@ -50,7 +50,10 @@ namespace Extents backend = list.OrderBy(t => t.Item1).ToList(); } - public int Count { get { return backend.Count; } } + public int Count + { + get { return backend.Count; } + } public void Add(ushort item) { @@ -61,8 +64,7 @@ namespace Extents for(int i = 0; i < backend.Count; i++) { // Already contained in an extent - if(item >= backend[i].Item1 && item <= backend[i].Item2) - return; + if(item >= backend[i].Item1 && item <= backend[i].Item2) return; // Expands existing extent start if(item == backend[i].Item1 - 1) @@ -74,8 +76,7 @@ namespace Extents removeTwo = backend[i - 1]; itemToAdd = new Tuple(backend[i - 1].Item1, backend[i].Item2); } - else - itemToAdd = new Tuple(item, backend[i].Item2); + else itemToAdd = new Tuple(item, backend[i].Item2); break; } @@ -90,8 +91,7 @@ namespace Extents removeTwo = backend[i + 1]; itemToAdd = new Tuple(backend[i].Item1, backend[i + 1].Item2); } - else - itemToAdd = new Tuple(backend[i].Item1, item); + else itemToAdd = new Tuple(backend[i].Item1, item); break; } @@ -103,8 +103,7 @@ namespace Extents backend.Remove(removeTwo); backend.Add(itemToAdd); } - else - backend.Add(new Tuple(item, item)); + else backend.Add(new Tuple(item, item)); // Sort backend = backend.OrderBy(t => t.Item1).ToList(); @@ -118,21 +117,18 @@ namespace Extents public void Add(ushort start, ushort end, bool run) { ushort realEnd; - if(run) - realEnd = (ushort)(start + end - 1); - else - realEnd = end; + if(run) realEnd = (ushort)(start + end - 1); + else realEnd = end; // TODO: Optimize this - for(ushort t = start; t <= realEnd; t++) - Add(t); + for(ushort t = start; t <= realEnd; t++) Add(t); } public bool Contains(ushort item) { foreach(Tuple extent in backend) - if(item >= extent.Item1 && item <= extent.Item2) - return true; + if(item >= extent.Item1 && item <= extent.Item2) return true; + return false; } @@ -183,14 +179,11 @@ namespace Extents } // Item not found - if(toRemove == null) - return false; + if(toRemove == null) return false; backend.Remove(toRemove); - if(toAddOne != null) - backend.Add(toAddOne); - if(toAddTwo != null) - backend.Add(toAddTwo); + if(toAddOne != null) backend.Add(toAddOne); + if(toAddTwo != null) backend.Add(toAddTwo); // Sort backend = backend.OrderBy(t => t.Item1).ToList(); @@ -214,7 +207,8 @@ namespace Extents return true; } } + return false; } } -} +} \ No newline at end of file diff --git a/PrintHex.cs b/PrintHex.cs index 01ffed386..e5e8046a7 100644 --- a/PrintHex.cs +++ b/PrintHex.cs @@ -75,14 +75,13 @@ namespace DiscImageChef counter = 0; subcounter = 0; } - else - counter++; + else counter++; } + sb.AppendLine(); sb.AppendLine(); return sb.ToString(); } } -} - +} \ No newline at end of file diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs index c93539f7d..c6eb046fa 100644 --- a/Properties/AssemblyInfo.cs +++ b/Properties/AssemblyInfo.cs @@ -54,5 +54,4 @@ using System.Reflection; // if desired. See the Mono documentation for more information about signing. //[assembly: AssemblyDelaySign(false)] -//[assembly: AssemblyKeyFile("")] - +//[assembly: AssemblyKeyFile("")] \ No newline at end of file diff --git a/StringHandlers.cs b/StringHandlers.cs index d2bebcda7..09e42989d 100644 --- a/StringHandlers.cs +++ b/StringHandlers.cs @@ -55,8 +55,7 @@ namespace DiscImageChef /// Encoding. public static string CToString(byte[] CString, Encoding encoding, bool twoBytes = false, int start = 0) { - if(CString == null) - return null; + if(CString == null) return null; int len = 0; @@ -71,11 +70,10 @@ namespace DiscImageChef len++; break; } - // if((i + 1) == CString.Length) -// break; + // if((i + 1) == CString.Length) + // break; } - else - break; + else break; } len++; @@ -105,17 +103,15 @@ namespace DiscImageChef /// Encoding. public static string PascalToString(byte[] PascalString, Encoding encoding, int start = 0) { - if(PascalString == null) - return null; + if(PascalString == null) return null; byte length = PascalString[start]; int len = 0; for(int i = start + 1; i < length + 1 && i < PascalString.Length; i++) { - if(PascalString[i] == 0) - break; - + if(PascalString[i] == 0) break; + len++; } @@ -143,15 +139,13 @@ namespace DiscImageChef /// Encoding. public static string SpacePaddedToString(byte[] SpacePaddedString, Encoding encoding, int start = 0) { - if(SpacePaddedString == null) - return null; + if(SpacePaddedString == null) return null; int len = start; for(int i = SpacePaddedString.Length; i >= start; i--) { - if(i == start) - return ""; + if(i == start) return ""; if(SpacePaddedString[i - 1] != 0x20) { @@ -174,21 +168,16 @@ namespace DiscImageChef byte compId = dstring[0]; string temp = ""; - if(compId != 8 && compId != 16) - return null; + 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; + if(compId == 16) unicode = (ushort)(dstring[byteIndex++] << 8); + else unicode = 0; - if(byteIndex < dstring.Length) - unicode |= dstring[byteIndex++]; + if(byteIndex < dstring.Length) unicode |= dstring[byteIndex++]; - if(unicode == 0) - break; + if(unicode == 0) break; temp += Encoding.Unicode.GetString(System.BitConverter.GetBytes(unicode)); } @@ -196,5 +185,4 @@ namespace DiscImageChef return temp; } } -} - +} \ No newline at end of file diff --git a/Swapping.cs b/Swapping.cs index da3a9f44d..cfca315bc 100644 --- a/Swapping.cs +++ b/Swapping.cs @@ -138,4 +138,4 @@ namespace DiscImageChef return (x << 16) | ((x >> 16) & 0xFFFF); } } -} +} \ No newline at end of file