mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
REFACTOR: Reformat code.
This commit is contained in:
@@ -48,6 +48,7 @@ namespace DiscImageChef
|
||||
/// architecture.
|
||||
///</summary>
|
||||
public static bool IsLittleEndian { get; set; }
|
||||
|
||||
// should default to false, which is what we want for Empire
|
||||
/// <summary>
|
||||
/// Converts the specified double-precision floating point number to a 64-bit
|
||||
@@ -362,7 +363,9 @@ namespace DiscImageChef
|
||||
///</summary>
|
||||
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
|
||||
///</summary>
|
||||
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
|
||||
///</summary>
|
||||
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
|
||||
///</summary>
|
||||
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
|
||||
///</summary>
|
||||
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
|
||||
///</summary>
|
||||
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
|
||||
///</summary>
|
||||
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
|
||||
///</summary>
|
||||
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
|
||||
///</summary>
|
||||
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]);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user