diff --git a/ArrayFill.cs b/ArrayFill.cs index d08b4b0b5..811b33761 100644 --- a/ArrayFill.cs +++ b/ArrayFill.cs @@ -31,12 +31,24 @@ namespace DiscImageChef { public static partial class ArrayHelpers { + /// + /// Fills an array with the specified value + /// + /// Array + /// Value + /// Array type 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[] {value}); } + /// + /// Fills an array with the contents of the specified array + /// + /// Array + /// Value + /// Array type public static void ArrayFill(T[] destinationArray, T[] value) { if(destinationArray == null) throw new ArgumentNullException(nameof(destinationArray)); @@ -54,6 +66,12 @@ namespace DiscImageChef Array.Copy(destinationArray, 0, destinationArray, copyLength, destinationArray.Length - copyLength); } + /// + /// Converts a byte array to its hexadecimal representation + /// + /// Byte array + /// true to use uppercase + /// public static string ByteArrayToHex(byte[] array, bool upper = false) { StringBuilder sb = new StringBuilder(); diff --git a/ArrayIsEmpty.cs b/ArrayIsEmpty.cs index 94c466c00..cec1d9cb8 100644 --- a/ArrayIsEmpty.cs +++ b/ArrayIsEmpty.cs @@ -36,11 +36,21 @@ namespace DiscImageChef { public static partial class ArrayHelpers { + /// + /// Checks if an array is null, filled with the NULL byte (0x00) or ASCII whitespace (0x20) + /// + /// Array + /// True if null or whitespace public static bool ArrayIsNullOrWhiteSpace(byte[] array) { return array == null || array.All(b => b == 0x00 || b == 0x20); } + /// + /// Checks if an array is null or filled with the NULL byte (0x00) + /// + /// Array + /// True if null public static bool ArrayIsNullOrEmpty(byte[] array) { return array == null || array.All(b => b == 0x00); diff --git a/BigEndianBitConverter.cs b/BigEndianBitConverter.cs index 46d0706f1..53064d00d 100644 --- a/BigEndianBitConverter.cs +++ b/BigEndianBitConverter.cs @@ -40,327 +40,186 @@ namespace DiscImageChef /// data types. /// All info taken from the meta data of System.BitConverter. This implementation /// allows for Endianness consideration. - /// + /// public static class BigEndianBitConverter { /// /// Indicates the byte order ("endianess") in which data is stored in this computer /// 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 - /// signed integer. - /// - /// Parameters: - /// value: - /// The number to convert. - /// - /// Returns: - /// A 64-bit signed integer whose value is equivalent to value. - /// + /// Converts the specified double-precision floating point number to a 64-bit signed integer. + /// + /// The number to convert. + /// A 64-bit signed integer whose value is equivalent to value. + /// It is not currently implemented public static long DoubleToInt64Bits(double value) { throw new NotImplementedException(); } - /// /// /// Returns the specified Boolean value as an array of bytes. - /// - /// Parameters: - /// value: - /// A Boolean value. - /// - /// Returns: - /// An array of bytes with length 1. - /// + /// + /// A Boolean value. + /// An array of bytes with length 1. public static byte[] GetBytes(bool value) { return !IsLittleEndian ? BitConverter.GetBytes(value) : BitConverter.GetBytes(value).Reverse().ToArray(); } - /// /// /// Returns the specified Unicode character value as an array of bytes. - /// - /// Parameters: - /// value: - /// A character to convert. - /// - /// Returns: - /// An array of bytes with length 2. - /// + /// + /// A character to convert. + /// An array of bytes with length 2. public static byte[] GetBytes(char value) { return !IsLittleEndian ? BitConverter.GetBytes(value) : BitConverter.GetBytes(value).Reverse().ToArray(); } - /// /// - /// Returns the specified double-precision floating point value as an array of - /// bytes. - /// - /// Parameters: - /// value: - /// The number to convert. - /// - /// Returns: - /// An array of bytes with length 8. - /// + /// Returns the specified double-precision floating point value as an array of bytes. + /// + /// The number to convert. + /// An array of bytes with length 8. public static byte[] GetBytes(double value) { return !IsLittleEndian ? BitConverter.GetBytes(value) : BitConverter.GetBytes(value).Reverse().ToArray(); } - /// /// - /// Returns the specified single-precision floating point value as an array of - /// bytes. - /// - /// Parameters: - /// value: - /// The number to convert. - /// - /// Returns: - /// An array of bytes with length 4. - /// + /// Returns the specified single-precision floating point value as an array of bytes. + /// + /// The number to convert. + /// An array of bytes with length 4. public static byte[] GetBytes(float value) { return !IsLittleEndian ? BitConverter.GetBytes(value) : BitConverter.GetBytes(value).Reverse().ToArray(); } - /// /// /// Returns the specified 32-bit signed integer value as an array of bytes. - /// - /// Parameters: - /// value: - /// The number to convert. - /// - /// Returns: - /// An array of bytes with length 4. - /// + /// + /// The number to convert. + /// An array of bytes with length 4. public static byte[] GetBytes(int value) { return !IsLittleEndian ? BitConverter.GetBytes(value) : BitConverter.GetBytes(value).Reverse().ToArray(); } - /// /// /// Returns the specified 64-bit signed integer value as an array of bytes. - /// - /// Parameters: - /// value: - /// The number to convert. - /// - /// Returns: - /// An array of bytes with length 8. - /// + /// + /// The number to convert. + /// An array of bytes with length 8. public static byte[] GetBytes(long value) { return !IsLittleEndian ? BitConverter.GetBytes(value) : BitConverter.GetBytes(value).Reverse().ToArray(); } - /// /// /// Returns the specified 16-bit signed integer value as an array of bytes. - /// - /// Parameters: - /// value: - /// The number to convert. - /// - /// Returns: - /// An array of bytes with length 2. - /// + /// + /// The number to convert. + /// An array of bytes with length 2. public static byte[] GetBytes(short value) { return !IsLittleEndian ? BitConverter.GetBytes(value) : BitConverter.GetBytes(value).Reverse().ToArray(); } - /// /// /// Returns the specified 32-bit unsigned integer value as an array of bytes. - /// - /// Parameters: - /// value: - /// The number to convert. - /// - /// Returns: - /// An array of bytes with length 4. - /// - //[CLSCompliant(false)] + /// + /// The number to convert. + /// An array of bytes with length 4. public static byte[] GetBytes(uint value) { return !IsLittleEndian ? BitConverter.GetBytes(value) : BitConverter.GetBytes(value).Reverse().ToArray(); } - /// /// /// Returns the specified 64-bit unsigned integer value as an array of bytes. - /// - /// Parameters: - /// value: - /// The number to convert. - /// - /// Returns: - /// An array of bytes with length 8. - /// - //[CLSCompliant(false)] + /// + /// The number to convert. + /// An array of bytes with length 8. public static byte[] GetBytes(ulong value) { return !IsLittleEndian ? BitConverter.GetBytes(value) : BitConverter.GetBytes(value).Reverse().ToArray(); } - /// /// /// Returns the specified 16-bit unsigned integer value as an array of bytes. - /// - /// Parameters: - /// value: - /// The number to convert. - /// - /// Returns: - /// An array of bytes with length 2. - /// + /// + /// The number to convert. + /// An array of bytes with length 2. public static byte[] GetBytes(ushort value) { return !IsLittleEndian ? BitConverter.GetBytes(value) : BitConverter.GetBytes(value).Reverse().ToArray(); } - /// /// - /// Converts the specified 64-bit signed integer to a double-precision floating - /// point number. - /// - /// Parameters: - /// value: - /// The number to convert. - /// - /// Returns: - /// A double-precision floating point number whose value is equivalent to value. - /// + /// Converts the specified 64-bit signed integer to a double-precision floating point number. + /// + /// The number to convert. + /// A double-precision floating point number whose value is equivalent to value. public static double Int64BitsToDouble(long value) { throw new NotImplementedException(); } - /// /// - /// Returns a Boolean value converted from one byte at a specified position in - /// a byte array. - /// - /// Parameters: - /// value: - /// An array of bytes. - /// - /// startIndex: - /// The starting position within value. - /// - /// Returns: - /// true if the byte at startIndex in value is nonzero; otherwise, false. - /// - /// Exceptions: - /// System.ArgumentNullException: - /// value is null. - /// - /// System.ArgumentOutOfRangeException: - /// startIndex is less than zero or greater than the length of value minus 1. - /// + /// Returns a Boolean value converted from one byte at a specified position in a byte array. + /// + /// An array of bytes. + /// The starting position within value. + /// true if the byte at in value is nonzero; otherwise, false. + /// value is null. + /// is less than zero or greater than the length of value minus 1. public static bool ToBoolean(byte[] value, int startIndex) { throw new NotImplementedException(); } - /// /// - /// Returns a Unicode character converted from two bytes at a specified position - /// in a byte array. - /// - /// Parameters: - /// value: - /// An array. - /// - /// startIndex: - /// The starting position within value. - /// - /// Returns: - /// A character formed by two bytes beginning at startIndex. - /// - /// Exceptions: - /// System.ArgumentException: - /// startIndex equals the length of value minus 1. - /// - /// System.ArgumentNullException: - /// value is null. - /// - /// System.ArgumentOutOfRangeException: - /// startIndex is less than zero or greater than the length of value minus 1. - /// + /// Returns a Unicode character converted from two bytes at a specified position in a byte array. + /// + /// An array. + /// The starting position within value. + /// A character formed by two bytes beginning at . + /// equals the length of value minus 1. + /// value is null. + /// is less than zero or greater than the length of value minus 1. public static char ToChar(byte[] value, int startIndex) { throw new NotImplementedException(); } - /// /// - /// Returns a double-precision floating point number converted from eight bytes - /// at a specified position in a byte array. - /// - /// Parameters: - /// value: - /// An array of bytes. - /// - /// startIndex: - /// The starting position within value. - /// - /// Returns: - /// A double precision floating point number formed by eight bytes beginning - /// at startIndex. - /// - /// Exceptions: - /// System.ArgumentException: - /// startIndex is greater than or equal to the length of value minus 7, and is - /// less than or equal to the length of value minus 1. - /// - /// System.ArgumentNullException: - /// value is null. - /// - /// System.ArgumentOutOfRangeException: - /// startIndex is less than zero or greater than the length of value minus 1. - /// + /// Returns a double-precision floating point number converted from eight bytes at a specified position in a byte array. + /// + /// An array of bytes. + /// The starting position within value. + /// A double precision floating point number formed by eight bytes beginning at . + /// is greater than or equal to the length of value minus 7, and is less than or equal to the length of value minus 1. + /// value is null. + /// is less than zero or greater than the length of value minus 1. public static double ToDouble(byte[] value, int startIndex) { throw new NotImplementedException(); } - /// /// - /// Returns a 16-bit signed integer converted from two bytes at a specified position - /// in a byte array. - /// - /// Parameters: - /// value: - /// An array of bytes. - /// - /// startIndex: - /// The starting position within value. - /// - /// Returns: - /// A 16-bit signed integer formed by two bytes beginning at startIndex. - /// - /// Exceptions: - /// System.ArgumentException: - /// startIndex equals the length of value minus 1. - /// - /// System.ArgumentNullException: - /// value is null. - /// - /// System.ArgumentOutOfRangeException: - /// startIndex is less than zero or greater than the length of value minus 1. - /// + /// Returns a 16-bit signed integer converted from two bytes at a specified position in a byte array. + /// + /// An array of bytes. + /// The starting position within value. + /// A 16-bit signed integer formed by two bytes beginning at . + /// equals the length of value minus 1. + /// value is null. + /// startIndex is less than zero or greater than the length of value minus 1. public static short ToInt16(byte[] value, int startIndex) { return !IsLittleEndian @@ -368,32 +227,15 @@ namespace DiscImageChef : BitConverter.ToInt16(value.Reverse().ToArray(), value.Length - sizeof(short) - startIndex); } - /// /// - /// Returns a 32-bit signed integer converted from four bytes at a specified - /// position in a byte array. - /// - /// Parameters: - /// value: - /// An array of bytes. - /// - /// startIndex: - /// The starting position within value. - /// - /// Returns: - /// A 32-bit signed integer formed by four bytes beginning at startIndex. - /// - /// Exceptions: - /// System.ArgumentException: - /// startIndex is greater than or equal to the length of value minus 3, and is - /// less than or equal to the length of value minus 1. - /// - /// System.ArgumentNullException: - /// value is null. - /// - /// System.ArgumentOutOfRangeException: - /// startIndex is less than zero or greater than the length of value minus 1. - /// + /// Returns a 32-bit signed integer converted from four bytes at a specified position in a byte array. + /// + /// An array of bytes. + /// The starting position within value. + /// A 32-bit signed integer formed by four bytes beginning at . + /// is greater than or equal to the length of value minus 3, and is less than or equal to the length of value minus 1. + /// value is null. + /// startIndex is less than zero or greater than the length of value minus 1. public static int ToInt32(byte[] value, int startIndex) { return !IsLittleEndian @@ -401,32 +243,15 @@ namespace DiscImageChef : BitConverter.ToInt32(value.Reverse().ToArray(), value.Length - sizeof(int) - startIndex); } - /// /// - /// Returns a 64-bit signed integer converted from eight bytes at a specified - /// position in a byte array. - /// - /// Parameters: - /// value: - /// An array of bytes. - /// - /// startIndex: - /// The starting position within value. - /// - /// Returns: - /// A 64-bit signed integer formed by eight bytes beginning at startIndex. - /// - /// Exceptions: - /// System.ArgumentException: - /// startIndex is greater than or equal to the length of value minus 7, and is - /// less than or equal to the length of value minus 1. - /// - /// System.ArgumentNullException: - /// value is null. - /// - /// System.ArgumentOutOfRangeException: - /// startIndex is less than zero or greater than the length of value minus 1. - /// + /// Returns a 64-bit signed integer converted from eight bytes at a specified position in a byte array. + /// + /// An array of bytes. + /// The starting position within value. + /// A 64-bit signed integer formed by eight bytes beginning at . + /// is greater than or equal to the length of value minus 7, and is less than or equal to the length of value minus 1. + /// value is null. + /// is less than zero or greater than the length of value minus 1. public static long ToInt64(byte[] value, int startIndex) { return !IsLittleEndian @@ -434,33 +259,15 @@ namespace DiscImageChef : BitConverter.ToInt64(value.Reverse().ToArray(), value.Length - sizeof(long) - startIndex); } - /// /// - /// Returns a single-precision floating point number converted from four bytes - /// at a specified position in a byte array. - /// - /// Parameters: - /// value: - /// An array of bytes. - /// - /// startIndex: - /// The starting position within value. - /// - /// Returns: - /// A single-precision floating point number formed by four bytes beginning at - /// startIndex. - /// - /// Exceptions: - /// System.ArgumentException: - /// startIndex is greater than or equal to the length of value minus 3, and is - /// less than or equal to the length of value minus 1. - /// - /// System.ArgumentNullException: - /// value is null. - /// - /// System.ArgumentOutOfRangeException: - /// startIndex is less than zero or greater than the length of value minus 1. - /// + /// Returns a single-precision floating point number converted from four bytes at a specified position in a byte array. + /// + /// An array of bytes. + /// The starting position within value. + /// A single-precision floating point number formed by four bytes beginning at . + /// is greater than or equal to the length of value minus 3, and is less than or equal to the length of value minus 1. + /// value is null. + /// is less than zero or greater than the length of value minus 1. public static float ToSingle(byte[] value, int startIndex) { return !IsLittleEndian @@ -468,52 +275,25 @@ namespace DiscImageChef : BitConverter.ToSingle(value.Reverse().ToArray(), value.Length - sizeof(float) - startIndex); } - /// /// - /// Converts the numeric value of each element of a specified array of bytes - /// to its equivalent hexadecimal string representation. - /// - /// Parameters: - /// value: - /// An array of bytes. - /// - /// Returns: - /// A System.String of hexadecimal pairs separated by hyphens, where each pair - /// represents the corresponding element in value; for example, "7F-2C-4A". - /// - /// Exceptions: - /// System.ArgumentNullException: - /// value is null. - /// + /// Converts the numeric value of each element of a specified array of bytes to its equivalent hexadecimal string representation. + /// + /// An array of bytes. + /// A System.String of hexadecimal pairs separated by hyphens, where each pair represents the corresponding element in value; for example, "7F-2C-4A". + /// value is null. public static string ToString(byte[] value) { return !IsLittleEndian ? BitConverter.ToString(value) : BitConverter.ToString(value.Reverse().ToArray()); } - /// /// - /// Converts the numeric value of each element of a specified subarray of bytes - /// to its equivalent hexadecimal string representation. - /// - /// Parameters: - /// value: - /// An array of bytes. - /// - /// startIndex: - /// The starting position within value. - /// - /// Returns: - /// A System.String of hexadecimal pairs separated by hyphens, where each pair - /// represents the corresponding element in a subarray of value; for example, - /// "7F-2C-4A". - /// - /// Exceptions: - /// System.ArgumentNullException: - /// value is null. - /// - /// System.ArgumentOutOfRangeException: - /// startIndex is less than zero or greater than the length of value minus 1. - /// + /// Converts the numeric value of each element of a specified subarray of bytes to its equivalent hexadecimal string representation. + /// + /// An array of bytes. + /// The starting position within value. + /// A System.String of hexadecimal pairs separated by hyphens, where each pair represents the corresponding element in a subarray of value; for example, "7F-2C-4A". + /// value is null. + /// startIndex is less than zero or greater than the length of value minus 1. public static string ToString(byte[] value, int startIndex) { return !IsLittleEndian @@ -521,39 +301,16 @@ namespace DiscImageChef : BitConverter.ToString(value.Reverse().ToArray(), startIndex); } - /// /// - /// Converts the numeric value of each element of a specified subarray of bytes - /// to its equivalent hexadecimal string representation. - /// - /// Parameters: - /// value: - /// An array of bytes. - /// - /// startIndex: - /// The starting position within value. - /// - /// length: - /// The number of array elements in value to convert. - /// - /// Returns: - /// A System.String of hexadecimal pairs separated by hyphens, where each pair - /// represents the corresponding element in a subarray of value; for example, - /// "7F-2C-4A". - /// - /// Exceptions: - /// System.ArgumentNullException: - /// value is null. - /// - /// System.ArgumentOutOfRangeException: - /// startIndex or length is less than zero. -or- startIndex is greater than - /// zero and is greater than or equal to the length of value. - /// - /// System.ArgumentException: - /// The combination of startIndex and length does not specify a position within - /// value; that is, the startIndex parameter is greater than the length of value - /// minus the length parameter. - /// + /// Converts the numeric value of each element of a specified subarray of bytes to its equivalent hexadecimal string representation. + /// + /// An array of bytes. + /// The starting position within value. + /// The number of array elements in value to convert. + /// A System.String of hexadecimal pairs separated by hyphens, where each pair represents the corresponding element in a subarray of value; for example, "7F-2C-4A". + /// value is null. + /// startIndex or length is less than zero. -or- startIndex is greater than zero and is greater than or equal to the length of value. + /// The combination of startIndex and length does not specify a position within value; that is, the startIndex parameter is greater than the length of value minus the length parameter. public static string ToString(byte[] value, int startIndex, int length) { return !IsLittleEndian @@ -561,31 +318,15 @@ namespace DiscImageChef : BitConverter.ToString(value.Reverse().ToArray(), startIndex, length); } - /// /// - /// Returns a 16-bit unsigned integer converted from two bytes at a specified - /// position in a byte array. - /// - /// Parameters: - /// value: - /// The array of bytes. - /// - /// startIndex: - /// The starting position within value. - /// - /// Returns: - /// A 16-bit unsigned integer formed by two bytes beginning at startIndex. - /// - /// Exceptions: - /// System.ArgumentException: - /// startIndex equals the length of value minus 1. - /// - /// System.ArgumentNullException: - /// value is null. - /// - /// System.ArgumentOutOfRangeException: - /// startIndex is less than zero or greater than the length of value minus 1. - /// + /// Returns a 16-bit unsigned integer converted from two bytes at a specified position in a byte array. + /// + /// The array of bytes. + /// The starting position within value. + /// A 16-bit unsigned integer formed by two bytes beginning at startIndex. + /// startIndex equals the length of value minus 1. + /// value is null. + /// startIndex is less than zero or greater than the length of value minus 1. public static ushort ToUInt16(byte[] value, int startIndex) { return !IsLittleEndian @@ -593,32 +334,15 @@ namespace DiscImageChef : BitConverter.ToUInt16(value.Reverse().ToArray(), value.Length - sizeof(ushort) - startIndex); } - /// /// - /// Returns a 32-bit unsigned integer converted from four bytes at a specified - /// position in a byte array. - /// - /// Parameters: - /// value: - /// An array of bytes. - /// - /// startIndex: - /// The starting position within value. - /// - /// Returns: - /// A 32-bit unsigned integer formed by four bytes beginning at startIndex. - /// - /// Exceptions: - /// System.ArgumentException: - /// startIndex is greater than or equal to the length of value minus 3, and is - /// less than or equal to the length of value minus 1. - /// - /// System.ArgumentNullException: - /// value is null. - /// - /// System.ArgumentOutOfRangeException: - /// startIndex is less than zero or greater than the length of value minus 1. - /// + /// Returns a 32-bit unsigned integer converted from four bytes at a specified position in a byte array. + /// + /// An array of bytes. + /// The starting position within value. + /// A 32-bit unsigned integer formed by four bytes beginning at startIndex. + /// startIndex is greater than or equal to the length of value minus 3, and is less than or equal to the length of value minus 1. + /// value is null. + /// startIndex is less than zero or greater than the length of value minus 1. public static uint ToUInt32(byte[] value, int startIndex) { return !IsLittleEndian @@ -626,32 +350,15 @@ namespace DiscImageChef : BitConverter.ToUInt32(value.Reverse().ToArray(), value.Length - sizeof(uint) - startIndex); } - /// /// - /// Returns a 64-bit unsigned integer converted from eight bytes at a specified - /// position in a byte array. - /// - /// Parameters: - /// value: - /// An array of bytes. - /// - /// startIndex: - /// The starting position within value. - /// - /// Returns: - /// A 64-bit unsigned integer formed by the eight bytes beginning at startIndex. - /// - /// Exceptions: - /// System.ArgumentException: - /// startIndex is greater than or equal to the length of value minus 7, and is - /// less than or equal to the length of value minus 1. - /// - /// System.ArgumentNullException: - /// value is null. - /// - /// System.ArgumentOutOfRangeException: - /// startIndex is less than zero or greater than the length of value minus 1. - /// + /// Returns a 64-bit unsigned integer converted from eight bytes at a specified position in a byte array. + /// + /// An array of bytes. + /// The starting position within value. + /// A 64-bit unsigned integer formed by the eight bytes beginning at startIndex. + /// startIndex is greater than or equal to the length of value minus 7, and is less than or equal to the length of value minus 1. + /// value is null. + /// startIndex is less than zero or greater than the length of value minus 1. public static ulong ToUInt64(byte[] value, int startIndex) { return !IsLittleEndian diff --git a/CHS.cs b/CHS.cs index 869669143..5d696ad67 100644 --- a/CHS.cs +++ b/CHS.cs @@ -34,6 +34,15 @@ namespace DiscImageChef.Helpers { public static class CHS { + /// + /// Converts a CHS position to a LBA one + /// + /// Cylinder + /// Head + /// Sector + /// Number of heads + /// Number of sectors per track + /// public static uint ToLBA(uint cyl, uint head, uint sector, uint maxHead, uint maxSector) { return maxHead == 0 || maxSector == 0 diff --git a/CompareBytes.cs b/CompareBytes.cs index 5eb96857e..f10cf41d6 100644 --- a/CompareBytes.cs +++ b/CompareBytes.cs @@ -34,6 +34,13 @@ namespace DiscImageChef { public static partial class ArrayHelpers { + /// + /// Compares two byte arrays + /// + /// true if they are different in any way + /// true if they have the same size + /// Left array + /// Right array public static void CompareBytes(out bool different, out bool sameSize, byte[] compareArray1, byte[] compareArray2) { diff --git a/CountBits.cs b/CountBits.cs index 29a153fb4..7c899f9ff 100644 --- a/CountBits.cs +++ b/CountBits.cs @@ -34,6 +34,11 @@ namespace DiscImageChef.Helpers { public static class CountBits { + /// + /// Counts the number of bits set to true in a number + /// + /// Number + /// Bits set to true public static int Count(uint number) { number = number - ((number >> 1) & 0x55555555); diff --git a/DateHandlers.cs b/DateHandlers.cs index 9d394fb0c..56dda5f56 100644 --- a/DateHandlers.cs +++ b/DateHandlers.cs @@ -46,41 +46,82 @@ namespace DiscImageChef static readonly DateTime AmigaEpoch = new DateTime(1978, 1, 1, 0, 0, 0); static readonly DateTime AppleDoubleEpoch = new DateTime(1970, 1, 1, 0, 0, 0); + /// + /// Converts a Macintosh timestamp to a .NET DateTime + /// + /// Macintosh timestamp (seconds since 1st Jan. 1904) + /// .NET DateTime public static DateTime MacToDateTime(ulong MacTimeStamp) { return MacEpoch.AddTicks((long)(MacTimeStamp * 10000000)); } + /// + /// Converts a Lisa timestamp to a .NET DateTime + /// + /// Lisa timestamp (seconds since 1st Jan. 1901) + /// .NET DateTime public static DateTime LisaToDateTime(uint LisaTimeStamp) { return LisaEpoch.AddSeconds(LisaTimeStamp); } + /// + /// Converts a UNIX timestamp to a .NET DateTime + /// + /// UNIX timestamp (seconds since 1st Jan. 1970) + /// .NET DateTime public static DateTime UNIXToDateTime(int UNIXTimeStamp) { return UNIXEpoch.AddSeconds(UNIXTimeStamp); } + /// + /// Converts a UNIX timestamp to a .NET DateTime + /// + /// UNIX timestamp (seconds since 1st Jan. 1970) + /// .NET DateTime public static DateTime UNIXToDateTime(long UNIXTimeStamp) { return UNIXEpoch.AddSeconds(UNIXTimeStamp); } + /// + /// Converts a UNIX timestamp to a .NET DateTime + /// + /// UNIX timestamp (seconds since 1st Jan. 1970) + /// .NET DateTime public static DateTime UNIXUnsignedToDateTime(uint UNIXTimeStamp) { return UNIXEpoch.AddSeconds(UNIXTimeStamp); } + /// + /// Converts a UNIX timestamp to a .NET DateTime + /// + /// Seconds since 1st Jan. 1970) + /// Nanoseconds + /// .NET DateTime public static DateTime UNIXUnsignedToDateTime(uint seconds, uint nanoseconds) { return UNIXEpoch.AddSeconds(seconds).AddTicks((long)nanoseconds / 100); } + /// + /// Converts a UNIX timestamp to a .NET DateTime + /// + /// UNIX timestamp (seconds since 1st Jan. 1970) + /// .NET DateTime public static DateTime UNIXUnsignedToDateTime(ulong UNIXTimeStamp) { return UNIXEpoch.AddSeconds(UNIXTimeStamp); } + /// + /// Converts a High Sierra Format timestamp to a .NET DateTime + /// + /// High Sierra Format timestamp + /// .NET DateTime public static DateTime HighSierraToDateTime(byte[] VDDateTime) { byte[] isotime = new byte[17]; @@ -89,6 +130,11 @@ namespace DiscImageChef } // TODO: Timezone + /// + /// Converts an ISO9660 timestamp to a .NET DateTime + /// + /// ISO9660 timestamp + /// .NET DateTime public static DateTime ISO9660ToDateTime(byte[] VDDateTime) { int year, month, day, hour, minute, second, hundredths; @@ -155,13 +201,25 @@ namespace DiscImageChef return decodedDT; } - // C# works in UTC, VMS on Julian Date, some displacement may occur on disks created outside UTC + /// + /// Converts a VMS timestamp to a .NET DateTime + /// + /// VMS timestamp (tenths of microseconds since day 0 of the Julian Date) + /// .NET DateTime + /// C# works in UTC, VMS on Julian Date, some displacement may occur on disks created outside UTC public static DateTime VMSToDateTime(ulong vmsDate) { double delta = vmsDate * 0.0001; // Tenths of microseconds to milliseconds, will lose some detail return JulianEpoch.AddMilliseconds(delta); } + /// + /// Converts an Amiga timestamp to a .NET DateTime + /// + /// Days since the 1st Jan. 1978 + /// Minutes since o'clock + /// Ticks + /// .NET DateTime public static DateTime AmigaToDateTime(uint days, uint minutes, uint ticks) { DateTime temp = AmigaEpoch.AddDays(days); @@ -169,6 +227,11 @@ namespace DiscImageChef return temp.AddMilliseconds(ticks * 20); } + /// + /// Converts an UCSD Pascal timestamp to a .NET DateTime + /// + /// UCSD Pascal timestamp + /// .NET DateTime public static DateTime UCSDPascalToDateTime(short dateRecord) { int year = ((dateRecord & 0xFE00) >> 9) + 1900; @@ -181,6 +244,12 @@ namespace DiscImageChef return new DateTime(year, month, day); } + /// + /// Converts a DOS timestamp to a .NET DateTime + /// + /// Date + /// Time + /// .NET DateTime public static DateTime DOSToDateTime(ushort date, ushort time) { int year = ((date & 0xFE00) >> 9) + 1980; @@ -203,6 +272,11 @@ namespace DiscImageChef return dosdate; } + /// + /// Converts a CP/M timestamp to .NET DateTime + /// + /// CP/M timestamp + /// .NET DateTime public static DateTime CPMToDateTime(byte[] timestamp) { ushort days = BitConverter.ToUInt16(timestamp, 0); @@ -216,11 +290,26 @@ namespace DiscImageChef return temp; } + // TODO: This is unix public static DateTime AppleDoubleToDateTime(ulong AppleDoubleTimeStamp) { return AppleDoubleEpoch.AddSeconds(AppleDoubleTimeStamp); } + /// + /// Converts an ECMA timestamp to a .NET DateTime + /// + /// Timezone + /// Year + /// Month + /// Day + /// Hour + /// Minute + /// Second + /// Centiseconds + /// 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) @@ -245,11 +334,21 @@ namespace DiscImageChef .AddTicks(ticks).DateTime; } + /// + /// Convers a Solaris high resolution timestamp to .NET DateTime + /// + /// Solaris high resolution timestamp + /// .NET DateTime public static DateTime UNIXHrTimeToDateTime(ulong HRTimeStamp) { return UNIXEpoch.AddTicks((long)(HRTimeStamp / 100)); } + /// + /// Converts an OS-9 timestamp to .NET DateTime + /// + /// OS-9 timestamp + /// .NET DateTime public static DateTime OS9ToDateTime(byte[] date) { if(date == null || date.Length != 3 && date.Length != 5) return DateTime.MinValue; @@ -267,6 +366,11 @@ namespace DiscImageChef return os9date; } + /// + /// Converts a LIF timestamp to .NET DateTime + /// + /// LIF timestamp + /// .NET DateTime public static DateTime LifToDateTime(byte[] date) { if(date == null || date.Length != 6) return new DateTime(1970, 1, 1, 0, 0, 0); @@ -274,6 +378,16 @@ namespace DiscImageChef return LifToDateTime(date[0], date[1], date[2], date[3], date[4], date[5]); } + /// + /// Converts a LIF timestamp to .NET DateTime + /// + /// Yer + /// Month + /// Day + /// Hour + /// Minute + /// Second + /// .NET DateTime public static DateTime LifToDateTime(byte year, byte month, byte day, byte hour, byte minute, byte second) { try diff --git a/EndianAwareBinaryReader.cs b/EndianAwareBinaryReader.cs index b47316903..a108895f7 100644 --- a/EndianAwareBinaryReader.cs +++ b/EndianAwareBinaryReader.cs @@ -30,6 +30,7 @@ // Copyright © 2011-2018 Natalia Portillo // ****************************************************************************/ +// TODO: Just remove using System; using System.IO; using System.Linq; diff --git a/Extents/ExtentsByte.cs b/Extents/ExtentsByte.cs index 13c9ffa15..bd0e7b188 100644 --- a/Extents/ExtentsByte.cs +++ b/Extents/ExtentsByte.cs @@ -36,22 +36,39 @@ using System.Linq; namespace Extents { + /// + /// Implements extents for + /// public class ExtentsByte { List> backend; + /// + /// Initialize an empty list of extents + /// public ExtentsByte() { backend = new List>(); } + /// + /// Initializes extents with an specific list + /// + /// List of extents as tuples "start, end" public ExtentsByte(IEnumerable> list) { backend = list.OrderBy(t => t.Item1).ToList(); } + /// + /// Gets a count of how many extents are stored + /// public int Count => backend.Count; + /// + /// Adds the specified number to the corresponding extent, or creates a new one + /// + /// public void Add(byte item) { Tuple removeOne = null; @@ -105,6 +122,12 @@ namespace Extents backend = backend.OrderBy(t => t.Item1).ToList(); } + /// + /// Adds a new extent + /// + /// First element of the extent + /// Last element of the extent or if is true how many elements the extent runs for + /// If set to true, indicates how many elements the extent runs for public void Add(byte start, byte end, bool run = false) { byte realEnd; @@ -115,16 +138,29 @@ namespace Extents for(byte t = start; t <= realEnd; t++) Add(t); } + /// + /// Checks if the specified item is contained by an extent on this instance + /// + /// Item to seach for + /// true if any of the extents on this instance contains the item public bool Contains(byte item) { return backend.Any(extent => item >= extent.Item1 && item <= extent.Item2); } + /// + /// Removes all extents from this instance + /// public void Clear() { backend.Clear(); } + /// + /// Removes an item from the extents in this instance + /// + /// Item to remove + /// true if the item was contained in a known extent and removed, false otherwise public bool Remove(byte item) { Tuple toRemove = null; @@ -178,11 +214,21 @@ namespace Extents return true; } + /// + /// Converts the list of extents to an array of where T1 is first element of the extent and T2 is last element + /// + /// Array of public Tuple[] ToArray() { return backend.ToArray(); } + /// + /// Gets the first element of the extent that contains the specified item + /// + /// Item + /// First element of extent + /// true if item was found in an extent, false otherwise public bool GetStart(byte item, out byte start) { start = 0; diff --git a/Extents/ExtentsInt.cs b/Extents/ExtentsInt.cs index ce631c8b2..d41300106 100644 --- a/Extents/ExtentsInt.cs +++ b/Extents/ExtentsInt.cs @@ -36,22 +36,39 @@ using System.Linq; namespace Extents { + /// + /// Implements extents for + /// public class ExtentsInt { List> backend; + /// + /// Initialize an empty list of extents + /// public ExtentsInt() { backend = new List>(); } + /// + /// Initializes extents with an specific list + /// + /// List of extents as tuples "start, end" public ExtentsInt(IEnumerable> list) { backend = list.OrderBy(t => t.Item1).ToList(); } + /// + /// Gets a count of how many extents are stored + /// public int Count => backend.Count; + /// + /// Adds the specified number to the corresponding extent, or creates a new one + /// + /// public void Add(int item) { Tuple removeOne = null; @@ -105,6 +122,12 @@ namespace Extents backend = backend.OrderBy(t => t.Item1).ToList(); } + /// + /// Adds a new extent + /// + /// First element of the extent + /// Last element of the extent or if is true how many elements the extent runs for + /// If set to true, indicates how many elements the extent runs for public void Add(int start, int end, bool run = false) { int realEnd; @@ -115,16 +138,29 @@ namespace Extents for(int t = start; t <= realEnd; t++) Add(t); } + /// + /// Checks if the specified item is contained by an extent on this instance + /// + /// Item to seach for + /// true if any of the extents on this instance contains the item public bool Contains(int item) { return backend.Any(extent => item >= extent.Item1 && item <= extent.Item2); } + /// + /// Removes all extents from this instance + /// public void Clear() { backend.Clear(); } + /// + /// Removes an item from the extents in this instance + /// + /// Item to remove + /// true if the item was contained in a known extent and removed, false otherwise public bool Remove(int item) { Tuple toRemove = null; @@ -178,11 +214,21 @@ namespace Extents return true; } + /// + /// Converts the list of extents to an array of where T1 is first element of the extent and T2 is last element + /// + /// Array of public Tuple[] ToArray() { return backend.ToArray(); } + /// + /// Gets the first element of the extent that contains the specified item + /// + /// Item + /// First element of extent + /// true if item was found in an extent, false otherwise public bool GetStart(int item, out int start) { start = 0; diff --git a/Extents/ExtentsLong.cs b/Extents/ExtentsLong.cs index 68a9faf15..b293e822f 100644 --- a/Extents/ExtentsLong.cs +++ b/Extents/ExtentsLong.cs @@ -36,22 +36,39 @@ using System.Linq; namespace Extents { + /// + /// Implements extents for + /// public class ExtentsLong { List> backend; + /// + /// Initialize an empty list of extents + /// public ExtentsLong() { backend = new List>(); } + /// + /// Initializes extents with an specific list + /// + /// List of extents as tuples "start, end" public ExtentsLong(IEnumerable> list) { backend = list.OrderBy(t => t.Item1).ToList(); } + /// + /// Gets a count of how many extents are stored + /// public int Count => backend.Count; + /// + /// Adds the specified number to the corresponding extent, or creates a new one + /// + /// public void Add(long item) { Tuple removeOne = null; @@ -105,6 +122,12 @@ namespace Extents backend = backend.OrderBy(t => t.Item1).ToList(); } + /// + /// Adds a new extent + /// + /// First element of the extent + /// Last element of the extent or if is true how many elements the extent runs for + /// If set to true, indicates how many elements the extent runs for public void Add(long start, long end, bool run = false) { long realEnd; @@ -115,16 +138,29 @@ namespace Extents for(long t = start; t <= realEnd; t++) Add(t); } + /// + /// Checks if the specified item is contained by an extent on this instance + /// + /// Item to seach for + /// true if any of the extents on this instance contains the item public bool Contains(long item) { return backend.Any(extent => item >= extent.Item1 && item <= extent.Item2); } + /// + /// Removes all extents from this instance + /// public void Clear() { backend.Clear(); } + /// + /// Removes an item from the extents in this instance + /// + /// Item to remove + /// true if the item was contained in a known extent and removed, false otherwise public bool Remove(long item) { Tuple toRemove = null; @@ -178,11 +214,21 @@ namespace Extents return true; } + /// + /// Converts the list of extents to an array of where T1 is first element of the extent and T2 is last element + /// + /// Array of public Tuple[] ToArray() { return backend.ToArray(); } + /// + /// Gets the first element of the extent that contains the specified item + /// + /// Item + /// First element of extent + /// true if item was found in an extent, false otherwise public bool GetStart(long item, out long start) { start = 0; diff --git a/Extents/ExtentsSByte.cs b/Extents/ExtentsSByte.cs index df5b0d151..ef52740df 100644 --- a/Extents/ExtentsSByte.cs +++ b/Extents/ExtentsSByte.cs @@ -36,22 +36,39 @@ using System.Linq; namespace Extents { + /// + /// Implements extents for + /// public class ExtentsSByte { List> backend; + /// + /// Initialize an empty list of extents + /// public ExtentsSByte() { backend = new List>(); } + /// + /// Initializes extents with an specific list + /// + /// List of extents as tuples "start, end" public ExtentsSByte(IEnumerable> list) { backend = list.OrderBy(t => t.Item1).ToList(); } + /// + /// Gets a count of how many extents are stored + /// public int Count => backend.Count; + /// + /// Adds the specified number to the corresponding extent, or creates a new one + /// + /// public void Add(sbyte item) { Tuple removeOne = null; @@ -105,6 +122,12 @@ namespace Extents backend = backend.OrderBy(t => t.Item1).ToList(); } + /// + /// Adds a new extent + /// + /// First element of the extent + /// Last element of the extent or if is true how many elements the extent runs for + /// If set to true, indicates how many elements the extent runs for public void Add(sbyte start, sbyte end, bool run = false) { sbyte realEnd; @@ -115,16 +138,29 @@ namespace Extents for(sbyte t = start; t <= realEnd; t++) Add(t); } + /// + /// Checks if the specified item is contained by an extent on this instance + /// + /// Item to seach for + /// true if any of the extents on this instance contains the item public bool Contains(sbyte item) { return backend.Any(extent => item >= extent.Item1 && item <= extent.Item2); } + /// + /// Removes all extents from this instance + /// public void Clear() { backend.Clear(); } + /// + /// Removes an item from the extents in this instance + /// + /// Item to remove + /// true if the item was contained in a known extent and removed, false otherwise public bool Remove(sbyte item) { Tuple toRemove = null; @@ -178,11 +214,21 @@ namespace Extents return true; } + /// + /// Converts the list of extents to an array of where T1 is first element of the extent and T2 is last element + /// + /// Array of public Tuple[] ToArray() { return backend.ToArray(); } + /// + /// Gets the first element of the extent that contains the specified item + /// + /// Item + /// First element of extent + /// true if item was found in an extent, false otherwise public bool GetStart(sbyte item, out sbyte start) { start = 0; diff --git a/Extents/ExtentsShort.cs b/Extents/ExtentsShort.cs index 505a4fcba..7c47deeb8 100644 --- a/Extents/ExtentsShort.cs +++ b/Extents/ExtentsShort.cs @@ -36,22 +36,39 @@ using System.Linq; namespace Extents { + /// + /// Implements extents for + /// public class ExtentsShort { List> backend; + /// + /// Initialize an empty list of extents + /// public ExtentsShort() { backend = new List>(); } + /// + /// Initializes extents with an specific list + /// + /// List of extents as tuples "start, end" public ExtentsShort(IEnumerable> list) { backend = list.OrderBy(t => t.Item1).ToList(); } + /// + /// Gets a count of how many extents are stored + /// public int Count => backend.Count; + /// + /// Adds the specified number to the corresponding extent, or creates a new one + /// + /// public void Add(short item) { Tuple removeOne = null; @@ -105,6 +122,12 @@ namespace Extents backend = backend.OrderBy(t => t.Item1).ToList(); } + /// + /// Adds a new extent + /// + /// First element of the extent + /// Last element of the extent or if is true how many elements the extent runs for + /// If set to true, indicates how many elements the extent runs for public void Add(short start, short end, bool run = false) { short realEnd; @@ -115,16 +138,29 @@ namespace Extents for(short t = start; t <= realEnd; t++) Add(t); } + /// + /// Checks if the specified item is contained by an extent on this instance + /// + /// Item to seach for + /// true if any of the extents on this instance contains the item public bool Contains(short item) { return backend.Any(extent => item >= extent.Item1 && item <= extent.Item2); } + /// + /// Removes all extents from this instance + /// public void Clear() { backend.Clear(); } + /// + /// Removes an item from the extents in this instance + /// + /// Item to remove + /// true if the item was contained in a known extent and removed, false otherwise public bool Remove(short item) { Tuple toRemove = null; @@ -178,11 +214,21 @@ namespace Extents return true; } + /// + /// Converts the list of extents to an array of where T1 is first element of the extent and T2 is last element + /// + /// Array of public Tuple[] ToArray() { return backend.ToArray(); } + /// + /// Gets the first element of the extent that contains the specified item + /// + /// Item + /// First element of extent + /// true if item was found in an extent, false otherwise public bool GetStart(short item, out short start) { start = 0; diff --git a/Extents/ExtentsUInt.cs b/Extents/ExtentsUInt.cs index 5768ba1ec..6ba26e927 100644 --- a/Extents/ExtentsUInt.cs +++ b/Extents/ExtentsUInt.cs @@ -36,22 +36,39 @@ using System.Linq; namespace Extents { + /// + /// Implements extents for + /// public class ExtentsUInt { List> backend; + /// + /// Initialize an empty list of extents + /// public ExtentsUInt() { backend = new List>(); } + /// + /// Initializes extents with an specific list + /// + /// List of extents as tuples "start, end" public ExtentsUInt(IEnumerable> list) { backend = list.OrderBy(t => t.Item1).ToList(); } + /// + /// Gets a count of how many extents are stored + /// public int Count => backend.Count; + /// + /// Adds the specified number to the corresponding extent, or creates a new one + /// + /// public void Add(uint item) { Tuple removeOne = null; @@ -105,6 +122,12 @@ namespace Extents backend = backend.OrderBy(t => t.Item1).ToList(); } + /// + /// Adds a new extent + /// + /// First element of the extent + /// Last element of the extent or if is true how many elements the extent runs for + /// If set to true, indicates how many elements the extent runs for public void Add(uint start, uint end, bool run = false) { uint realEnd; @@ -115,16 +138,29 @@ namespace Extents for(uint t = start; t <= realEnd; t++) Add(t); } + /// + /// Checks if the specified item is contained by an extent on this instance + /// + /// Item to seach for + /// true if any of the extents on this instance contains the item public bool Contains(uint item) { return backend.Any(extent => item >= extent.Item1 && item <= extent.Item2); } + /// + /// Removes all extents from this instance + /// public void Clear() { backend.Clear(); } + /// + /// Removes an item from the extents in this instance + /// + /// Item to remove + /// true if the item was contained in a known extent and removed, false otherwise public bool Remove(uint item) { Tuple toRemove = null; @@ -178,11 +214,21 @@ namespace Extents return true; } + /// + /// Converts the list of extents to an array of where T1 is first element of the extent and T2 is last element + /// + /// Array of public Tuple[] ToArray() { return backend.ToArray(); } + /// + /// Gets the first element of the extent that contains the specified item + /// + /// Item + /// First element of extent + /// true if item was found in an extent, false otherwise public bool GetStart(uint item, out uint start) { start = 0; diff --git a/Extents/ExtentsULong.cs b/Extents/ExtentsULong.cs index f5cc9eb9c..60e5813a7 100644 --- a/Extents/ExtentsULong.cs +++ b/Extents/ExtentsULong.cs @@ -36,22 +36,39 @@ using System.Linq; namespace Extents { + /// + /// Implements extents for + /// public class ExtentsULong { List> backend; + /// + /// Initialize an empty list of extents + /// public ExtentsULong() { backend = new List>(); } + /// + /// Initializes extents with an specific list + /// + /// List of extents as tuples "start, end" public ExtentsULong(IEnumerable> list) { backend = list.OrderBy(t => t.Item1).ToList(); } + /// + /// Gets a count of how many extents are stored + /// public int Count => backend.Count; + /// + /// Adds the specified number to the corresponding extent, or creates a new one + /// + /// public void Add(ulong item) { Tuple removeOne = null; @@ -105,6 +122,12 @@ namespace Extents backend = backend.OrderBy(t => t.Item1).ToList(); } + /// + /// Adds a new extent + /// + /// First element of the extent + /// Last element of the extent or if is true how many elements the extent runs for + /// If set to true, indicates how many elements the extent runs for public void Add(ulong start, ulong end, bool run = false) { ulong realEnd; @@ -115,16 +138,29 @@ namespace Extents for(ulong t = start; t <= realEnd; t++) Add(t); } + /// + /// Checks if the specified item is contained by an extent on this instance + /// + /// Item to seach for + /// true if any of the extents on this instance contains the item public bool Contains(ulong item) { return backend.Any(extent => item >= extent.Item1 && item <= extent.Item2); } + /// + /// Removes all extents from this instance + /// public void Clear() { backend.Clear(); } + /// + /// Removes an item from the extents in this instance + /// + /// Item to remove + /// true if the item was contained in a known extent and removed, false otherwise public bool Remove(ulong item) { Tuple toRemove = null; @@ -178,11 +214,21 @@ namespace Extents return true; } + /// + /// Converts the list of extents to an array of where T1 is first element of the extent and T2 is last element + /// + /// Array of public Tuple[] ToArray() { return backend.ToArray(); } + /// + /// Gets the first element of the extent that contains the specified item + /// + /// Item + /// First element of extent + /// true if item was found in an extent, false otherwise public bool GetStart(ulong item, out ulong start) { start = 0; diff --git a/Extents/ExtentsUShort.cs b/Extents/ExtentsUShort.cs index 530f7951f..bf01658a9 100644 --- a/Extents/ExtentsUShort.cs +++ b/Extents/ExtentsUShort.cs @@ -36,22 +36,39 @@ using System.Linq; namespace Extents { + /// + /// Implements extents for + /// public class ExtentsUShort { List> backend; + /// + /// Initialize an empty list of extents + /// public ExtentsUShort() { backend = new List>(); } + /// + /// Initializes extents with an specific list + /// + /// List of extents as tuples "start, end" public ExtentsUShort(IEnumerable> list) { backend = list.OrderBy(t => t.Item1).ToList(); } + /// + /// Gets a count of how many extents are stored + /// public int Count => backend.Count; + /// + /// Adds the specified number to the corresponding extent, or creates a new one + /// + /// public void Add(ushort item) { Tuple removeOne = null; @@ -105,6 +122,12 @@ namespace Extents backend = backend.OrderBy(t => t.Item1).ToList(); } + /// + /// Adds a new extent + /// + /// First element of the extent + /// Last element of the extent or if is true how many elements the extent runs for + /// If set to true, indicates how many elements the extent runs for public void Add(ushort start, ushort end, bool run = false) { ushort realEnd; @@ -115,16 +138,29 @@ namespace Extents for(ushort t = start; t <= realEnd; t++) Add(t); } + /// + /// Checks if the specified item is contained by an extent on this instance + /// + /// Item to seach for + /// true if any of the extents on this instance contains the item public bool Contains(ushort item) { return backend.Any(extent => item >= extent.Item1 && item <= extent.Item2); } + /// + /// Removes all extents from this instance + /// public void Clear() { backend.Clear(); } + /// + /// Removes an item from the extents in this instance + /// + /// Item to remove + /// true if the item was contained in a known extent and removed, false otherwise public bool Remove(ushort item) { Tuple toRemove = null; @@ -178,11 +214,21 @@ namespace Extents return true; } + /// + /// Converts the list of extents to an array of where T1 is first element of the extent and T2 is last element + /// + /// Array of public Tuple[] ToArray() { return backend.ToArray(); } + /// + /// Gets the first element of the extent that contains the specified item + /// + /// Item + /// First element of extent + /// true if item was found in an extent, false otherwise public bool GetStart(ushort item, out ushort start) { start = 0; diff --git a/PrintHex.cs b/PrintHex.cs index 291b30154..1d2024386 100644 --- a/PrintHex.cs +++ b/PrintHex.cs @@ -37,11 +37,22 @@ namespace DiscImageChef { public static class PrintHex { + /// + /// Prints a byte array as hexadecimal values to the console + /// + /// Array + /// Width of line public static void PrintHexArray(byte[] array, int width) { DicConsole.WriteLine(ByteArrayToHexArrayString(array, width)); } + /// + /// Prints a byte array as hexadecimal values to a string + /// + /// Array + /// Width of line + /// String containing hexadecimal values public static string ByteArrayToHexArrayString(byte[] array, int width) { StringBuilder sb = new StringBuilder();