mirror of
https://github.com/aaru-dps/Aaru.Helpers.git
synced 2025-12-16 19:24:35 +00:00
Code restyling.
This commit is contained in:
@@ -42,7 +42,8 @@ namespace Aaru.Helpers
|
||||
public enum BitEndian
|
||||
{
|
||||
/// <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,
|
||||
/// <summary>PDP-11 endian, little endian except for 32-bit integers where the 16 halves are swapped between them</summary>
|
||||
Pdp
|
||||
|
||||
4
CHS.cs
4
CHS.cs
@@ -42,7 +42,7 @@ namespace Aaru.Helpers
|
||||
/// <param name="maxSector">Number of sectors per track</param>
|
||||
/// <returns></returns>
|
||||
public static uint ToLBA(uint cyl, uint head, uint sector, uint maxHead, uint maxSector) =>
|
||||
maxHead == 0 || maxSector == 0 ? (cyl * 16 + head) * 63 + sector - 1
|
||||
: (cyl * maxHead + head) * maxSector + sector - 1;
|
||||
maxHead == 0 || maxSector == 0 ? ((((cyl * 16) + head) * 63) + sector) - 1
|
||||
: ((((cyl * maxHead) + head) * maxSector) + sector) - 1;
|
||||
}
|
||||
}
|
||||
@@ -42,7 +42,7 @@ namespace Aaru.Helpers
|
||||
number = number - ((number >> 1) & 0x55555555);
|
||||
number = (number & 0x33333333) + ((number >> 2) & 0x33333333);
|
||||
|
||||
return(int)((((number + (number >> 4)) & 0x0F0F0F0F) * 0x01010101) >> 24);
|
||||
return (int)((((number + (number >> 4)) & 0x0F0F0F0F) * 0x01010101) >> 24);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -285,8 +285,8 @@ namespace Aaru
|
||||
{
|
||||
byte specification = (byte)((typeAndTimeZone & 0xF000) >> 12);
|
||||
|
||||
long ticks = (long)centiseconds * 100000 + (long)hundredsOfMicroseconds * 1000 +
|
||||
(long)microseconds * 10;
|
||||
long ticks = ((long)centiseconds * 100000) + ((long)hundredsOfMicroseconds * 1000) +
|
||||
((long)microseconds * 10);
|
||||
|
||||
if(specification == 0)
|
||||
return new DateTime(year, month, day, hour, minute, second, DateTimeKind.Utc).AddTicks(ticks);
|
||||
@@ -321,7 +321,7 @@ namespace Aaru
|
||||
public static DateTime Os9ToDateTime(byte[] date)
|
||||
{
|
||||
if(date == null ||
|
||||
date.Length != 3 && date.Length != 5)
|
||||
(date.Length != 3 && date.Length != 5))
|
||||
return DateTime.MinValue;
|
||||
|
||||
DateTime os9Date;
|
||||
@@ -363,12 +363,12 @@ namespace Aaru
|
||||
{
|
||||
try
|
||||
{
|
||||
int iyear = (year >> 4) * 10 + (year & 0xF);
|
||||
int imonth = (month >> 4) * 10 + (month & 0xF);
|
||||
int iday = (day >> 4) * 10 + (day & 0xF);
|
||||
int iminute = (minute >> 4) * 10 + (minute & 0xF);
|
||||
int ihour = (hour >> 4) * 10 + (hour & 0xF);
|
||||
int isecond = (second >> 4) * 10 + (second & 0xF);
|
||||
int iyear = ((year >> 4) * 10) + (year & 0xF);
|
||||
int imonth = ((month >> 4) * 10) + (month & 0xF);
|
||||
int iday = ((day >> 4) * 10) + (day & 0xF);
|
||||
int iminute = ((minute >> 4) * 10) + (minute & 0xF);
|
||||
int ihour = ((hour >> 4) * 10) + (hour & 0xF);
|
||||
int isecond = ((second >> 4) * 10) + (second & 0xF);
|
||||
|
||||
if(iyear >= 70)
|
||||
iyear += 1900;
|
||||
|
||||
12
Marshal.cs
12
Marshal.cs
@@ -89,7 +89,7 @@ namespace Aaru.Helpers
|
||||
|
||||
ptr.Free();
|
||||
|
||||
return(T)SwapStructureMembersEndian(str);
|
||||
return (T)SwapStructureMembersEndian(str);
|
||||
}
|
||||
|
||||
/// <summary>Marshal big-endian binary data to a structure</summary>
|
||||
@@ -121,7 +121,7 @@ namespace Aaru.Helpers
|
||||
|
||||
ptr.Free();
|
||||
|
||||
return(T)SwapStructureMembersEndianPdp(str);
|
||||
return (T)SwapStructureMembersEndianPdp(str);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -175,7 +175,7 @@ namespace Aaru.Helpers
|
||||
{
|
||||
T str = SpanToStructureLittleEndian<T>(bytes);
|
||||
|
||||
return(T)SwapStructureMembersEndian(str);
|
||||
return (T)SwapStructureMembersEndian(str);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -192,7 +192,7 @@ namespace Aaru.Helpers
|
||||
{
|
||||
T str = SpanToStructureLittleEndian<T>(bytes.Slice(start, length));
|
||||
|
||||
return(T)SwapStructureMembersEndian(str);
|
||||
return (T)SwapStructureMembersEndian(str);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -207,7 +207,7 @@ namespace Aaru.Helpers
|
||||
{
|
||||
object str = SpanToStructureLittleEndian<T>(bytes);
|
||||
|
||||
return(T)SwapStructureMembersEndianPdp(str);
|
||||
return (T)SwapStructureMembersEndianPdp(str);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -222,7 +222,7 @@ namespace Aaru.Helpers
|
||||
{
|
||||
object str = SpanToStructureLittleEndian<T>(bytes.Slice(start, length));
|
||||
|
||||
return(T)SwapStructureMembersEndianPdp(str);
|
||||
return (T)SwapStructureMembersEndianPdp(str);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -136,7 +136,7 @@ namespace Aaru
|
||||
for(int i = SpacePaddedString.Length; i >= start; i--)
|
||||
{
|
||||
if(i == start)
|
||||
return"";
|
||||
return "";
|
||||
|
||||
if(SpacePaddedString[i - 1] == 0x20)
|
||||
continue;
|
||||
|
||||
@@ -53,7 +53,7 @@ namespace Aaru
|
||||
{
|
||||
x = ((x << 8) & 0xFF00FF00) | ((x >> 8) & 0xFF00FF);
|
||||
|
||||
return(x << 16) | (x >> 16);
|
||||
return (x << 16) | (x >> 16);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
@@ -61,7 +61,7 @@ namespace Aaru
|
||||
{
|
||||
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)]
|
||||
|
||||
Reference in New Issue
Block a user