Code restyling.

This commit is contained in:
2020-02-29 18:03:33 +00:00
parent ad4bfdc0b5
commit 0bc3b5c1fe
7 changed files with 37 additions and 36 deletions

View File

@@ -42,7 +42,8 @@ namespace Aaru.Helpers
public enum BitEndian public enum BitEndian
{ {
/// <summary>Little-endian, or least significant bit</summary> /// <summary>Little-endian, or least significant bit</summary>
Little, /// <summary>Big-endian, or most significant bit</summary> Little,
/// <summary>Big-endian, or most significant bit</summary>
Big, Big,
/// <summary>PDP-11 endian, little endian except for 32-bit integers where the 16 halves are swapped between them</summary> /// <summary>PDP-11 endian, little endian except for 32-bit integers where the 16 halves are swapped between them</summary>
Pdp Pdp

4
CHS.cs
View File

@@ -42,7 +42,7 @@ namespace Aaru.Helpers
/// <param name="maxSector">Number of sectors per track</param> /// <param name="maxSector">Number of sectors per track</param>
/// <returns></returns> /// <returns></returns>
public static uint ToLBA(uint cyl, uint head, uint sector, uint maxHead, uint maxSector) => public static uint ToLBA(uint cyl, uint head, uint sector, uint maxHead, uint maxSector) =>
maxHead == 0 || maxSector == 0 ? (cyl * 16 + head) * 63 + sector - 1 maxHead == 0 || maxSector == 0 ? ((((cyl * 16) + head) * 63) + sector) - 1
: (cyl * maxHead + head) * maxSector + sector - 1; : ((((cyl * maxHead) + head) * maxSector) + sector) - 1;
} }
} }

View File

@@ -42,7 +42,7 @@ namespace Aaru.Helpers
number = number - ((number >> 1) & 0x55555555); number = number - ((number >> 1) & 0x55555555);
number = (number & 0x33333333) + ((number >> 2) & 0x33333333); number = (number & 0x33333333) + ((number >> 2) & 0x33333333);
return(int)((((number + (number >> 4)) & 0x0F0F0F0F) * 0x01010101) >> 24); return (int)((((number + (number >> 4)) & 0x0F0F0F0F) * 0x01010101) >> 24);
} }
} }
} }

View File

@@ -285,8 +285,8 @@ namespace Aaru
{ {
byte specification = (byte)((typeAndTimeZone & 0xF000) >> 12); byte specification = (byte)((typeAndTimeZone & 0xF000) >> 12);
long ticks = (long)centiseconds * 100000 + (long)hundredsOfMicroseconds * 1000 + long ticks = ((long)centiseconds * 100000) + ((long)hundredsOfMicroseconds * 1000) +
(long)microseconds * 10; ((long)microseconds * 10);
if(specification == 0) if(specification == 0)
return new DateTime(year, month, day, hour, minute, second, DateTimeKind.Utc).AddTicks(ticks); return new DateTime(year, month, day, hour, minute, second, DateTimeKind.Utc).AddTicks(ticks);
@@ -321,7 +321,7 @@ namespace Aaru
public static DateTime Os9ToDateTime(byte[] date) public static DateTime Os9ToDateTime(byte[] date)
{ {
if(date == null || if(date == null ||
date.Length != 3 && date.Length != 5) (date.Length != 3 && date.Length != 5))
return DateTime.MinValue; return DateTime.MinValue;
DateTime os9Date; DateTime os9Date;
@@ -363,12 +363,12 @@ namespace Aaru
{ {
try try
{ {
int iyear = (year >> 4) * 10 + (year & 0xF); int iyear = ((year >> 4) * 10) + (year & 0xF);
int imonth = (month >> 4) * 10 + (month & 0xF); int imonth = ((month >> 4) * 10) + (month & 0xF);
int iday = (day >> 4) * 10 + (day & 0xF); int iday = ((day >> 4) * 10) + (day & 0xF);
int iminute = (minute >> 4) * 10 + (minute & 0xF); int iminute = ((minute >> 4) * 10) + (minute & 0xF);
int ihour = (hour >> 4) * 10 + (hour & 0xF); int ihour = ((hour >> 4) * 10) + (hour & 0xF);
int isecond = (second >> 4) * 10 + (second & 0xF); int isecond = ((second >> 4) * 10) + (second & 0xF);
if(iyear >= 70) if(iyear >= 70)
iyear += 1900; iyear += 1900;

View File

@@ -89,7 +89,7 @@ namespace Aaru.Helpers
ptr.Free(); ptr.Free();
return(T)SwapStructureMembersEndian(str); return (T)SwapStructureMembersEndian(str);
} }
/// <summary>Marshal big-endian binary data to a structure</summary> /// <summary>Marshal big-endian binary data to a structure</summary>
@@ -121,7 +121,7 @@ namespace Aaru.Helpers
ptr.Free(); ptr.Free();
return(T)SwapStructureMembersEndianPdp(str); return (T)SwapStructureMembersEndianPdp(str);
} }
} }
@@ -175,7 +175,7 @@ namespace Aaru.Helpers
{ {
T str = SpanToStructureLittleEndian<T>(bytes); T str = SpanToStructureLittleEndian<T>(bytes);
return(T)SwapStructureMembersEndian(str); return (T)SwapStructureMembersEndian(str);
} }
/// <summary> /// <summary>
@@ -192,7 +192,7 @@ namespace Aaru.Helpers
{ {
T str = SpanToStructureLittleEndian<T>(bytes.Slice(start, length)); T str = SpanToStructureLittleEndian<T>(bytes.Slice(start, length));
return(T)SwapStructureMembersEndian(str); return (T)SwapStructureMembersEndian(str);
} }
/// <summary> /// <summary>
@@ -207,7 +207,7 @@ namespace Aaru.Helpers
{ {
object str = SpanToStructureLittleEndian<T>(bytes); object str = SpanToStructureLittleEndian<T>(bytes);
return(T)SwapStructureMembersEndianPdp(str); return (T)SwapStructureMembersEndianPdp(str);
} }
/// <summary> /// <summary>
@@ -222,7 +222,7 @@ namespace Aaru.Helpers
{ {
object str = SpanToStructureLittleEndian<T>(bytes.Slice(start, length)); object str = SpanToStructureLittleEndian<T>(bytes.Slice(start, length));
return(T)SwapStructureMembersEndianPdp(str); return (T)SwapStructureMembersEndianPdp(str);
} }
/// <summary> /// <summary>

View File

@@ -136,7 +136,7 @@ namespace Aaru
for(int i = SpacePaddedString.Length; i >= start; i--) for(int i = SpacePaddedString.Length; i >= start; i--)
{ {
if(i == start) if(i == start)
return""; return "";
if(SpacePaddedString[i - 1] == 0x20) if(SpacePaddedString[i - 1] == 0x20)
continue; continue;

View File

@@ -53,7 +53,7 @@ namespace Aaru
{ {
x = ((x << 8) & 0xFF00FF00) | ((x >> 8) & 0xFF00FF); x = ((x << 8) & 0xFF00FF00) | ((x >> 8) & 0xFF00FF);
return(x << 16) | (x >> 16); return (x << 16) | (x >> 16);
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
@@ -61,7 +61,7 @@ namespace Aaru
{ {
x = (int)(((x << 8) & 0xFF00FF00) | (((uint)x >> 8) & 0xFF00FF)); x = (int)(((x << 8) & 0xFF00FF00) | (((uint)x >> 8) & 0xFF00FF));
return(int)(((uint)x << 16) | (((uint)x >> 16) & 0xFFFF)); return (int)(((uint)x << 16) | (((uint)x >> 16) & 0xFFFF));
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]