diff --git a/DiscImageChef.Checksums/Adler32Context.cs b/DiscImageChef.Checksums/Adler32Context.cs
index 083ae310..a950b842 100644
--- a/DiscImageChef.Checksums/Adler32Context.cs
+++ b/DiscImageChef.Checksums/Adler32Context.cs
@@ -42,12 +42,12 @@ namespace DiscImageChef.Checksums
public class Adler32Context : IChecksum
{
const ushort ADLER_MODULE = 65521;
- ushort sum1, sum2;
+ ushort sum1, sum2;
///
/// Initializes the Adler-32 sums
///
- public void Init()
+ public Adler32Context()
{
sum1 = 1;
sum2 = 0;
@@ -63,7 +63,7 @@ namespace DiscImageChef.Checksums
for(int i = 0; i < len; i++)
{
sum1 = (ushort)((sum1 + data[i]) % ADLER_MODULE);
- sum2 = (ushort)((sum2 + sum1) % ADLER_MODULE);
+ sum2 = (ushort)((sum2 + sum1) % ADLER_MODULE);
}
}
@@ -81,7 +81,7 @@ namespace DiscImageChef.Checksums
///
public byte[] Final()
{
- uint finalSum = (uint)((sum2 << 16) | sum1);
+ uint finalSum = (uint)((sum2 << 16) | sum1);
BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian;
return BigEndianBitConverter.GetBytes(finalSum);
}
@@ -91,7 +91,7 @@ namespace DiscImageChef.Checksums
///
public string End()
{
- uint finalSum = (uint)((sum2 << 16) | sum1);
+ uint finalSum = (uint)((sum2 << 16) | sum1);
StringBuilder adlerOutput = new StringBuilder();
BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian;
@@ -119,8 +119,8 @@ namespace DiscImageChef.Checksums
public static string File(string filename, out byte[] hash)
{
FileStream fileStream = new FileStream(filename, FileMode.Open);
- ushort localSum1, localSum2;
- uint finalSum;
+ ushort localSum1, localSum2;
+ uint finalSum;
localSum1 = 1;
localSum2 = 0;
@@ -128,13 +128,13 @@ namespace DiscImageChef.Checksums
for(int i = 0; i < fileStream.Length; i++)
{
localSum1 = (ushort)((localSum1 + fileStream.ReadByte()) % ADLER_MODULE);
- localSum2 = (ushort)((localSum2 + localSum1) % ADLER_MODULE);
+ localSum2 = (ushort)((localSum2 + localSum1) % ADLER_MODULE);
}
finalSum = (uint)((localSum2 << 16) | localSum1);
BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian;
- hash = BigEndianBitConverter.GetBytes(finalSum);
+ hash = BigEndianBitConverter.GetBytes(finalSum);
StringBuilder adlerOutput = new StringBuilder();
@@ -154,21 +154,21 @@ namespace DiscImageChef.Checksums
public static string Data(byte[] data, uint len, out byte[] hash)
{
ushort localSum1, localSum2;
- uint finalSum;
+ uint finalSum;
localSum1 = 1;
localSum2 = 0;
for(int i = 0; i < len; i++)
{
- localSum1 = (ushort)((localSum1 + data[i]) % ADLER_MODULE);
+ localSum1 = (ushort)((localSum1 + data[i]) % ADLER_MODULE);
localSum2 = (ushort)((localSum2 + localSum1) % ADLER_MODULE);
}
finalSum = (uint)((localSum2 << 16) | localSum1);
BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian;
- hash = BigEndianBitConverter.GetBytes(finalSum);
+ hash = BigEndianBitConverter.GetBytes(finalSum);
StringBuilder adlerOutput = new StringBuilder();
diff --git a/DiscImageChef.Checksums/CRC16Context.cs b/DiscImageChef.Checksums/CRC16Context.cs
index ec65593b..f779a377 100644
--- a/DiscImageChef.Checksums/CRC16Context.cs
+++ b/DiscImageChef.Checksums/CRC16Context.cs
@@ -43,14 +43,14 @@ namespace DiscImageChef.Checksums
{
const ushort CRC16_POLY = 0xA001;
const ushort CRC16_SEED = 0x0000;
- ushort hashInt;
- ushort[] table;
+ readonly ushort[] table;
+ ushort hashInt;
///
/// Initializes the CRC16 table and seed
///
- public void Init()
+ public Crc16Context()
{
hashInt = CRC16_SEED;
@@ -58,9 +58,11 @@ namespace DiscImageChef.Checksums
for(int i = 0; i < 256; i++)
{
ushort entry = (ushort)i;
- for(int j = 0; j < 8; j++)
- if((entry & 1) == 1) entry = (ushort)((entry >> 1) ^ CRC16_POLY);
- else entry = (ushort)(entry >> 1);
+ for(int j = 0; j < 8; j++)
+ if((entry & 1) == 1)
+ entry = (ushort)((entry >> 1) ^ CRC16_POLY);
+ else
+ entry = (ushort)(entry >> 1);
table[i] = entry;
}
@@ -102,7 +104,7 @@ namespace DiscImageChef.Checksums
StringBuilder crc16Output = new StringBuilder();
BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian;
- for(int i = 0; i < BigEndianBitConverter.GetBytes(hashInt ^ CRC16_SEED).Length; i++)
+ for(int i = 0; i < BigEndianBitConverter.GetBytes(hashInt ^ CRC16_SEED).Length; i++)
crc16Output.Append(BigEndianBitConverter.GetBytes(hashInt ^ CRC16_SEED)[i].ToString("x2"));
return crc16Output.ToString();
@@ -126,7 +128,7 @@ namespace DiscImageChef.Checksums
public static string File(string filename, out byte[] hash)
{
FileStream fileStream = new FileStream(filename, FileMode.Open);
- ushort localhashInt;
+ ushort localhashInt;
localhashInt = CRC16_SEED;
@@ -134,9 +136,11 @@ namespace DiscImageChef.Checksums
for(int i = 0; i < 256; i++)
{
ushort entry = (ushort)i;
- for(int j = 0; j < 8; j++)
- if((entry & 1) == 1) entry = (ushort)((entry >> 1) ^ CRC16_POLY);
- else entry = (ushort)(entry >> 1);
+ for(int j = 0; j < 8; j++)
+ if((entry & 1) == 1)
+ entry = (ushort)((entry >> 1) ^ CRC16_POLY);
+ else
+ entry = (ushort)(entry >> 1);
localTable[i] = entry;
}
@@ -146,7 +150,7 @@ namespace DiscImageChef.Checksums
(ushort)((localhashInt >> 8) ^ localTable[fileStream.ReadByte() ^ (localhashInt & 0xff)]);
BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian;
- hash = BigEndianBitConverter.GetBytes(localhashInt);
+ hash = BigEndianBitConverter.GetBytes(localhashInt);
StringBuilder crc16Output = new StringBuilder();
@@ -186,9 +190,11 @@ namespace DiscImageChef.Checksums
for(int i = 0; i < 256; i++)
{
ushort entry = (ushort)i;
- for(int j = 0; j < 8; j++)
- if((entry & 1) == 1) entry = (ushort)((entry >> 1) ^ polynomial);
- else entry = (ushort)(entry >> 1);
+ for(int j = 0; j < 8; j++)
+ if((entry & 1) == 1)
+ entry = (ushort)((entry >> 1) ^ polynomial);
+ else
+ entry = (ushort)(entry >> 1);
localTable[i] = entry;
}
@@ -197,7 +203,7 @@ namespace DiscImageChef.Checksums
localhashInt = (ushort)((localhashInt >> 8) ^ localTable[data[i] ^ (localhashInt & 0xff)]);
BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian;
- hash = BigEndianBitConverter.GetBytes(localhashInt);
+ hash = BigEndianBitConverter.GetBytes(localhashInt);
StringBuilder crc16Output = new StringBuilder();
diff --git a/DiscImageChef.Checksums/CRC32Context.cs b/DiscImageChef.Checksums/CRC32Context.cs
index e2319969..03e7acea 100644
--- a/DiscImageChef.Checksums/CRC32Context.cs
+++ b/DiscImageChef.Checksums/CRC32Context.cs
@@ -43,14 +43,14 @@ namespace DiscImageChef.Checksums
{
const uint CRC32_POLY = 0xEDB88320;
const uint CRC32_SEED = 0xFFFFFFFF;
- uint hashInt;
- uint[] table;
+ readonly uint[] table;
+ uint hashInt;
///
/// Initializes the CRC32 table and seed
///
- public void Init()
+ public Crc32Context()
{
hashInt = CRC32_SEED;
@@ -58,9 +58,11 @@ namespace DiscImageChef.Checksums
for(int i = 0; i < 256; i++)
{
uint entry = (uint)i;
- for(int j = 0; j < 8; j++)
- if((entry & 1) == 1) entry = (entry >> 1) ^ CRC32_POLY;
- else entry = entry >> 1;
+ for(int j = 0; j < 8; j++)
+ if((entry & 1) == 1)
+ entry = (entry >> 1) ^ CRC32_POLY;
+ else
+ entry = entry >> 1;
table[i] = entry;
}
@@ -102,7 +104,7 @@ namespace DiscImageChef.Checksums
StringBuilder crc32Output = new StringBuilder();
BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian;
- for(int i = 0; i < BigEndianBitConverter.GetBytes(hashInt ^ CRC32_SEED).Length; i++)
+ for(int i = 0; i < BigEndianBitConverter.GetBytes(hashInt ^ CRC32_SEED).Length; i++)
crc32Output.Append(BigEndianBitConverter.GetBytes(hashInt ^ CRC32_SEED)[i].ToString("x2"));
return crc32Output.ToString();
@@ -126,7 +128,7 @@ namespace DiscImageChef.Checksums
public static string File(string filename, out byte[] hash)
{
FileStream fileStream = new FileStream(filename, FileMode.Open);
- uint localhashInt;
+ uint localhashInt;
localhashInt = CRC32_SEED;
@@ -134,25 +136,27 @@ namespace DiscImageChef.Checksums
for(int i = 0; i < 256; i++)
{
uint entry = (uint)i;
- for(int j = 0; j < 8; j++)
- if((entry & 1) == 1) entry = (entry >> 1) ^ CRC32_POLY;
- else entry = entry >> 1;
+ for(int j = 0; j < 8; j++)
+ if((entry & 1) == 1)
+ entry = (entry >> 1) ^ CRC32_POLY;
+ else
+ entry = entry >> 1;
localTable[i] = entry;
}
for(int i = 0; i < fileStream.Length; i++)
{
- localhashInt = (localhashInt >> 8) ^ localTable[fileStream.ReadByte() ^ (localhashInt & 0xff)];
- if((localhashInt ^ CRC32_SEED) == 0xB883C628 || (localhashInt ^CRC32_SEED) == 0x28C683B8)
- {
+ localhashInt = (localhashInt >> 8) ^
+ localTable[fileStream.ReadByte() ^ (localhashInt & 0xff)];
+ if((localhashInt ^ CRC32_SEED) == 0xB883C628 ||
+ (localhashInt ^ CRC32_SEED) == 0x28C683B8)
System.Console.WriteLine("CRC found at position {0}", fileStream.Position);
- }
}
- localhashInt ^= CRC32_SEED;
- BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian;
- hash = BigEndianBitConverter.GetBytes(localhashInt);
+ localhashInt ^= CRC32_SEED;
+ BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian;
+ hash = BigEndianBitConverter.GetBytes(localhashInt);
StringBuilder crc32Output = new StringBuilder();
@@ -192,9 +196,11 @@ namespace DiscImageChef.Checksums
for(int i = 0; i < 256; i++)
{
uint entry = (uint)i;
- for(int j = 0; j < 8; j++)
- if((entry & 1) == 1) entry = (entry >> 1) ^ polynomial;
- else entry = entry >> 1;
+ for(int j = 0; j < 8; j++)
+ if((entry & 1) == 1)
+ entry = (entry >> 1) ^ polynomial;
+ else
+ entry = entry >> 1;
localTable[i] = entry;
}
@@ -202,9 +208,9 @@ namespace DiscImageChef.Checksums
for(int i = 0; i < len; i++)
localhashInt = (localhashInt >> 8) ^ localTable[data[i] ^ (localhashInt & 0xff)];
- localhashInt ^= CRC32_SEED;
- BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian;
- hash = BigEndianBitConverter.GetBytes(localhashInt);
+ localhashInt ^= CRC32_SEED;
+ BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian;
+ hash = BigEndianBitConverter.GetBytes(localhashInt);
StringBuilder crc32Output = new StringBuilder();
diff --git a/DiscImageChef.Checksums/CRC64Context.cs b/DiscImageChef.Checksums/CRC64Context.cs
index b1bc62bd..92136282 100644
--- a/DiscImageChef.Checksums/CRC64Context.cs
+++ b/DiscImageChef.Checksums/CRC64Context.cs
@@ -43,14 +43,14 @@ namespace DiscImageChef.Checksums
{
const ulong CRC64_POLY = 0xC96C5795D7870F42;
const ulong CRC64_SEED = 0xFFFFFFFFFFFFFFFF;
- ulong hashInt;
- ulong[] table;
+ readonly ulong[] table;
+ ulong hashInt;
///
/// Initializes the CRC64 table and seed
///
- public void Init()
+ public Crc64Context()
{
hashInt = CRC64_SEED;
@@ -58,9 +58,11 @@ namespace DiscImageChef.Checksums
for(int i = 0; i < 256; i++)
{
ulong entry = (ulong)i;
- for(int j = 0; j < 8; j++)
- if((entry & 1) == 1) entry = (entry >> 1) ^ CRC64_POLY;
- else entry = entry >> 1;
+ for(int j = 0; j < 8; j++)
+ if((entry & 1) == 1)
+ entry = (entry >> 1) ^ CRC64_POLY;
+ else
+ entry = entry >> 1;
table[i] = entry;
}
@@ -126,7 +128,7 @@ namespace DiscImageChef.Checksums
public static string File(string filename, out byte[] hash)
{
FileStream fileStream = new FileStream(filename, FileMode.Open);
- ulong localhashInt;
+ ulong localhashInt;
localhashInt = CRC64_SEED;
@@ -134,9 +136,11 @@ namespace DiscImageChef.Checksums
for(int i = 0; i < 256; i++)
{
ulong entry = (ulong)i;
- for(int j = 0; j < 8; j++)
- if((entry & 1) == 1) entry = (entry >> 1) ^ CRC64_POLY;
- else entry = entry >> 1;
+ for(int j = 0; j < 8; j++)
+ if((entry & 1) == 1)
+ entry = (entry >> 1) ^ CRC64_POLY;
+ else
+ entry = entry >> 1;
localTable[i] = entry;
}
@@ -144,9 +148,9 @@ namespace DiscImageChef.Checksums
for(int i = 0; i < fileStream.Length; i++)
localhashInt = (localhashInt >> 8) ^ localTable[(ulong)fileStream.ReadByte() ^ (localhashInt & 0xffL)];
- localhashInt ^= CRC64_SEED;
- BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian;
- hash = BigEndianBitConverter.GetBytes(localhashInt);
+ localhashInt ^= CRC64_SEED;
+ BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian;
+ hash = BigEndianBitConverter.GetBytes(localhashInt);
StringBuilder crc64Output = new StringBuilder();
@@ -186,9 +190,11 @@ namespace DiscImageChef.Checksums
for(int i = 0; i < 256; i++)
{
ulong entry = (ulong)i;
- for(int j = 0; j < 8; j++)
- if((entry & 1) == 1) entry = (entry >> 1) ^ polynomial;
- else entry = entry >> 1;
+ for(int j = 0; j < 8; j++)
+ if((entry & 1) == 1)
+ entry = (entry >> 1) ^ polynomial;
+ else
+ entry = entry >> 1;
localTable[i] = entry;
}
@@ -196,9 +202,9 @@ namespace DiscImageChef.Checksums
for(int i = 0; i < len; i++)
localhashInt = (localhashInt >> 8) ^ localTable[data[i] ^ (localhashInt & 0xff)];
- localhashInt ^= CRC64_SEED;
- BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian;
- hash = BigEndianBitConverter.GetBytes(localhashInt);
+ localhashInt ^= CRC64_SEED;
+ BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian;
+ hash = BigEndianBitConverter.GetBytes(localhashInt);
StringBuilder crc64Output = new StringBuilder();
diff --git a/DiscImageChef.Checksums/FletcherContext.cs b/DiscImageChef.Checksums/FletcherContext.cs
index a79c7395..f8eb3f74 100644
--- a/DiscImageChef.Checksums/FletcherContext.cs
+++ b/DiscImageChef.Checksums/FletcherContext.cs
@@ -40,19 +40,19 @@ namespace DiscImageChef.Checksums
{
public class Fletcher32Context : IChecksum
{
- bool inodd;
- byte oddValue;
+ bool inodd;
+ byte oddValue;
ushort sum1, sum2;
///
/// Initializes the Fletcher32 sums
///
- public void Init()
+ public Fletcher32Context()
{
- sum1 = 0xFFFF;
- sum2 = 0xFFFF;
+ sum1 = 0xFFFF;
+ sum2 = 0xFFFF;
oddValue = 0;
- inodd = false;
+ inodd = false;
}
///
@@ -67,13 +67,13 @@ namespace DiscImageChef.Checksums
if(len % 2 != 0)
{
oddValue = data[len - 1];
- inodd = true;
+ inodd = true;
for(int i = 0; i < len - 1; i += 2)
{
block = BigEndianBitConverter.ToUInt16(data, i);
- sum1 = (ushort)((sum1 + block) % 0xFFFF);
- sum2 = (ushort)((sum2 + sum1) % 0xFFFF);
+ sum1 = (ushort)((sum1 + block) % 0xFFFF);
+ sum2 = (ushort)((sum2 + sum1) % 0xFFFF);
}
}
else
@@ -82,32 +82,32 @@ namespace DiscImageChef.Checksums
for(int i = 0; i < len; i += 2)
{
block = BigEndianBitConverter.ToUInt16(data, i);
- sum1 = (ushort)((sum1 + block) % 0xFFFF);
- sum2 = (ushort)((sum2 + sum1) % 0xFFFF);
+ sum1 = (ushort)((sum1 + block) % 0xFFFF);
+ sum2 = (ushort)((sum2 + sum1) % 0xFFFF);
}
}
// Carrying odd
else
{
byte[] oddData = new byte[2];
- oddData[0] = oddValue;
- oddData[1] = data[0];
+ oddData[0] = oddValue;
+ oddData[1] = data[0];
block = BigEndianBitConverter.ToUInt16(oddData, 0);
- sum1 = (ushort)((sum1 + block) % 0xFFFF);
- sum2 = (ushort)((sum2 + sum1) % 0xFFFF);
+ sum1 = (ushort)((sum1 + block) % 0xFFFF);
+ sum2 = (ushort)((sum2 + sum1) % 0xFFFF);
// Even size, carrying odd
if(len % 2 == 0)
{
oddValue = data[len - 1];
- inodd = true;
+ inodd = true;
for(int i = 1; i < len - 1; i += 2)
{
block = BigEndianBitConverter.ToUInt16(data, i);
- sum1 = (ushort)((sum1 + block) % 0xFFFF);
- sum2 = (ushort)((sum2 + sum1) % 0xFFFF);
+ sum1 = (ushort)((sum1 + block) % 0xFFFF);
+ sum2 = (ushort)((sum2 + sum1) % 0xFFFF);
}
}
else
@@ -116,8 +116,8 @@ namespace DiscImageChef.Checksums
for(int i = 1; i < len; i += 2)
{
block = BigEndianBitConverter.ToUInt16(data, i);
- sum1 = (ushort)((sum1 + block) % 0xFFFF);
- sum2 = (ushort)((sum2 + sum1) % 0xFFFF);
+ sum1 = (ushort)((sum1 + block) % 0xFFFF);
+ sum2 = (ushort)((sum2 + sum1) % 0xFFFF);
}
}
}
@@ -146,7 +146,7 @@ namespace DiscImageChef.Checksums
///
public string End()
{
- uint finalSum = (uint)(sum1 + (sum2 << 16));
+ uint finalSum = (uint)(sum1 + (sum2 << 16));
StringBuilder fletcherOutput = new StringBuilder();
for(int i = 0; i < BigEndianBitConverter.GetBytes(finalSum).Length; i++)
@@ -173,20 +173,20 @@ namespace DiscImageChef.Checksums
public static string File(string filename, out byte[] hash)
{
FileStream fileStream = new FileStream(filename, FileMode.Open);
- ushort localSum1, localSum2, block;
- uint finalSum;
- byte[] blockBytes;
+ ushort localSum1, localSum2, block;
+ uint finalSum;
+ byte[] blockBytes;
localSum1 = 0xFFFF;
localSum2 = 0xFFFF;
if(fileStream.Length % 2 == 0)
- for(int i = 0; i < fileStream.Length; i += 2)
+ for(int i = 0; i < fileStream.Length; i += 2)
{
blockBytes = new byte[2];
fileStream.Read(blockBytes, 0, 2);
- block = BigEndianBitConverter.ToUInt16(blockBytes, 0);
- localSum1 = (ushort)((localSum1 + block) % 0xFFFF);
+ block = BigEndianBitConverter.ToUInt16(blockBytes, 0);
+ localSum1 = (ushort)((localSum1 + block) % 0xFFFF);
localSum2 = (ushort)((localSum2 + localSum1) % 0xFFFF);
}
else
@@ -195,17 +195,17 @@ namespace DiscImageChef.Checksums
{
blockBytes = new byte[2];
fileStream.Read(blockBytes, 0, 2);
- block = BigEndianBitConverter.ToUInt16(blockBytes, 0);
- localSum1 = (ushort)((localSum1 + block) % 0xFFFF);
+ block = BigEndianBitConverter.ToUInt16(blockBytes, 0);
+ localSum1 = (ushort)((localSum1 + block) % 0xFFFF);
localSum2 = (ushort)((localSum2 + localSum1) % 0xFFFF);
}
byte[] oddData = new byte[2];
- oddData[0] = (byte)fileStream.ReadByte();
- oddData[1] = 0;
+ oddData[0] = (byte)fileStream.ReadByte();
+ oddData[1] = 0;
- block = BigEndianBitConverter.ToUInt16(oddData, 0);
- localSum1 = (ushort)((localSum1 + block) % 0xFFFF);
+ block = BigEndianBitConverter.ToUInt16(oddData, 0);
+ localSum1 = (ushort)((localSum1 + block) % 0xFFFF);
localSum2 = (ushort)((localSum2 + localSum1) % 0xFFFF);
}
@@ -229,33 +229,33 @@ namespace DiscImageChef.Checksums
public static string Data(byte[] data, uint len, out byte[] hash)
{
ushort localSum1, localSum2, block;
- uint finalSum;
+ uint finalSum;
localSum1 = 0xFFFF;
localSum2 = 0xFFFF;
- if(len % 2 == 0)
+ if(len % 2 == 0)
for(int i = 0; i < len; i += 2)
{
- block = BigEndianBitConverter.ToUInt16(data, i);
- localSum1 = (ushort)((localSum1 + block) % 0xFFFF);
+ block = BigEndianBitConverter.ToUInt16(data, i);
+ localSum1 = (ushort)((localSum1 + block) % 0xFFFF);
localSum2 = (ushort)((localSum2 + localSum1) % 0xFFFF);
}
else
{
for(int i = 0; i < len - 1; i += 2)
{
- block = BigEndianBitConverter.ToUInt16(data, i);
- localSum1 = (ushort)((localSum1 + block) % 0xFFFF);
+ block = BigEndianBitConverter.ToUInt16(data, i);
+ localSum1 = (ushort)((localSum1 + block) % 0xFFFF);
localSum2 = (ushort)((localSum2 + localSum1) % 0xFFFF);
}
byte[] oddData = new byte[2];
- oddData[0] = data[len - 1];
- oddData[1] = 0;
+ oddData[0] = data[len - 1];
+ oddData[1] = 0;
- block = BigEndianBitConverter.ToUInt16(oddData, 0);
- localSum1 = (ushort)((localSum1 + block) % 0xFFFF);
+ block = BigEndianBitConverter.ToUInt16(oddData, 0);
+ localSum1 = (ushort)((localSum1 + block) % 0xFFFF);
localSum2 = (ushort)((localSum2 + localSum1) % 0xFFFF);
}
@@ -304,7 +304,7 @@ namespace DiscImageChef.Checksums
for(int i = 0; i < len; i++)
{
sum1 = (byte)((sum1 + data[i]) % 0xFF);
- sum2 = (byte)((sum2 + sum1) % 0xFF);
+ sum2 = (byte)((sum2 + sum1) % 0xFF);
}
}
@@ -331,7 +331,7 @@ namespace DiscImageChef.Checksums
///
public string End()
{
- ushort finalSum = (ushort)(sum1 + (sum2 << 8));
+ ushort finalSum = (ushort)(sum1 + (sum2 << 8));
StringBuilder fletcherOutput = new StringBuilder();
for(int i = 0; i < BigEndianBitConverter.GetBytes(finalSum).Length; i++)
@@ -358,16 +358,16 @@ namespace DiscImageChef.Checksums
public static string File(string filename, out byte[] hash)
{
FileStream fileStream = new FileStream(filename, FileMode.Open);
- byte localSum1, localSum2, block;
- ushort finalSum;
+ byte localSum1, localSum2, block;
+ ushort finalSum;
localSum1 = 0xFF;
localSum2 = 0xFF;
for(int i = 0; i < fileStream.Length; i += 2)
{
- block = (byte)fileStream.ReadByte();
- localSum1 = (byte)((localSum1 + block) % 0xFF);
+ block = (byte)fileStream.ReadByte();
+ localSum1 = (byte)((localSum1 + block) % 0xFF);
localSum2 = (byte)((localSum2 + localSum1) % 0xFF);
}
@@ -390,7 +390,7 @@ namespace DiscImageChef.Checksums
/// Byte array of the hash value.
public static string Data(byte[] data, uint len, out byte[] hash)
{
- byte localSum1, localSum2;
+ byte localSum1, localSum2;
ushort finalSum;
localSum1 = 0xFF;
@@ -398,7 +398,7 @@ namespace DiscImageChef.Checksums
for(int i = 0; i < len; i++)
{
- localSum1 = (byte)((localSum1 + data[i]) % 0xFF);
+ localSum1 = (byte)((localSum1 + data[i]) % 0xFF);
localSum2 = (byte)((localSum2 + localSum1) % 0xFF);
}
diff --git a/DiscImageChef.Checksums/IChecksum.cs b/DiscImageChef.Checksums/IChecksum.cs
index a29a96b1..862bbd89 100644
--- a/DiscImageChef.Checksums/IChecksum.cs
+++ b/DiscImageChef.Checksums/IChecksum.cs
@@ -34,11 +34,6 @@ namespace DiscImageChef.Checksums
{
public interface IChecksum
{
- ///
- /// Initializes the algorithm
- ///
- void Init();
-
///
/// Updates the hash with data.
///
diff --git a/DiscImageChef.Checksums/MD5Context.cs b/DiscImageChef.Checksums/MD5Context.cs
index 6fd0dc2e..90a9c5b6 100644
--- a/DiscImageChef.Checksums/MD5Context.cs
+++ b/DiscImageChef.Checksums/MD5Context.cs
@@ -46,7 +46,7 @@ namespace DiscImageChef.Checksums
///
/// Initializes the MD5 hash provider
///
- public void Init()
+ public Md5Context()
{
md5Provider = MD5.Create();
}
@@ -99,7 +99,7 @@ namespace DiscImageChef.Checksums
public byte[] File(string filename)
{
FileStream fileStream = new FileStream(filename, FileMode.Open);
- byte[] result = md5Provider.ComputeHash(fileStream);
+ byte[] result = md5Provider.ComputeHash(fileStream);
fileStream.Close();
return result;
}
@@ -111,8 +111,8 @@ namespace DiscImageChef.Checksums
/// Byte array of the hash value.
public string File(string filename, out byte[] hash)
{
- FileStream fileStream = new FileStream(filename, FileMode.Open);
- hash = md5Provider.ComputeHash(fileStream);
+ FileStream fileStream = new FileStream(filename, FileMode.Open);
+ hash = md5Provider.ComputeHash(fileStream);
StringBuilder md5Output = new StringBuilder();
foreach(byte h in hash) md5Output.Append(h.ToString("x2"));
@@ -130,7 +130,7 @@ namespace DiscImageChef.Checksums
/// Byte array of the hash value.
public string Data(byte[] data, uint len, out byte[] hash)
{
- hash = md5Provider.ComputeHash(data, 0, (int)len);
+ hash = md5Provider.ComputeHash(data, 0, (int)len);
StringBuilder md5Output = new StringBuilder();
foreach(byte h in hash) md5Output.Append(h.ToString("x2"));
diff --git a/DiscImageChef.Checksums/RIPEMD160Context.cs b/DiscImageChef.Checksums/RIPEMD160Context.cs
index 120f2cbd..404f9e35 100644
--- a/DiscImageChef.Checksums/RIPEMD160Context.cs
+++ b/DiscImageChef.Checksums/RIPEMD160Context.cs
@@ -46,7 +46,7 @@ namespace DiscImageChef.Checksums
///
/// Initializes the RIPEMD160 hash provider
///
- public void Init()
+ public Ripemd160Context()
{
ripemd160Provider = RIPEMD160.Create();
}
@@ -99,7 +99,7 @@ namespace DiscImageChef.Checksums
public byte[] File(string filename)
{
FileStream fileStream = new FileStream(filename, FileMode.Open);
- byte[] result = ripemd160Provider.ComputeHash(fileStream);
+ byte[] result = ripemd160Provider.ComputeHash(fileStream);
fileStream.Close();
return result;
}
@@ -111,8 +111,8 @@ namespace DiscImageChef.Checksums
/// Byte array of the hash value.
public string File(string filename, out byte[] hash)
{
- FileStream fileStream = new FileStream(filename, FileMode.Open);
- hash = ripemd160Provider.ComputeHash(fileStream);
+ FileStream fileStream = new FileStream(filename, FileMode.Open);
+ hash = ripemd160Provider.ComputeHash(fileStream);
StringBuilder ripemd160Output = new StringBuilder();
foreach(byte h in hash) ripemd160Output.Append(h.ToString("x2"));
@@ -130,7 +130,7 @@ namespace DiscImageChef.Checksums
/// Byte array of the hash value.
public string Data(byte[] data, uint len, out byte[] hash)
{
- hash = ripemd160Provider.ComputeHash(data, 0, (int)len);
+ hash = ripemd160Provider.ComputeHash(data, 0, (int)len);
StringBuilder ripemd160Output = new StringBuilder();
foreach(byte h in hash) ripemd160Output.Append(h.ToString("x2"));
diff --git a/DiscImageChef.Checksums/SHA1Context.cs b/DiscImageChef.Checksums/SHA1Context.cs
index f62887a5..23c5cc8b 100644
--- a/DiscImageChef.Checksums/SHA1Context.cs
+++ b/DiscImageChef.Checksums/SHA1Context.cs
@@ -46,7 +46,7 @@ namespace DiscImageChef.Checksums
///
/// Initializes the SHA1 hash provider
///
- public void Init()
+ public Sha1Context()
{
sha1Provider = SHA1.Create();
}
@@ -99,7 +99,7 @@ namespace DiscImageChef.Checksums
public byte[] File(string filename)
{
FileStream fileStream = new FileStream(filename, FileMode.Open);
- byte[] result = sha1Provider.ComputeHash(fileStream);
+ byte[] result = sha1Provider.ComputeHash(fileStream);
fileStream.Close();
return result;
}
@@ -111,8 +111,8 @@ namespace DiscImageChef.Checksums
/// Byte array of the hash value.
public string File(string filename, out byte[] hash)
{
- FileStream fileStream = new FileStream(filename, FileMode.Open);
- hash = sha1Provider.ComputeHash(fileStream);
+ FileStream fileStream = new FileStream(filename, FileMode.Open);
+ hash = sha1Provider.ComputeHash(fileStream);
StringBuilder sha1Output = new StringBuilder();
foreach(byte h in hash) sha1Output.Append(h.ToString("x2"));
@@ -130,7 +130,7 @@ namespace DiscImageChef.Checksums
/// Byte array of the hash value.
public string Data(byte[] data, uint len, out byte[] hash)
{
- hash = sha1Provider.ComputeHash(data, 0, (int)len);
+ hash = sha1Provider.ComputeHash(data, 0, (int)len);
StringBuilder sha1Output = new StringBuilder();
foreach(byte h in hash) sha1Output.Append(h.ToString("x2"));
diff --git a/DiscImageChef.Checksums/SHA256Context.cs b/DiscImageChef.Checksums/SHA256Context.cs
index 43e10734..e0056fb1 100644
--- a/DiscImageChef.Checksums/SHA256Context.cs
+++ b/DiscImageChef.Checksums/SHA256Context.cs
@@ -46,7 +46,7 @@ namespace DiscImageChef.Checksums
///
/// Initializes the SHA256 hash provider
///
- public void Init()
+ public Sha256Context()
{
sha256Provider = SHA256.Create();
}
@@ -99,7 +99,7 @@ namespace DiscImageChef.Checksums
public byte[] File(string filename)
{
FileStream fileStream = new FileStream(filename, FileMode.Open);
- byte[] result = sha256Provider.ComputeHash(fileStream);
+ byte[] result = sha256Provider.ComputeHash(fileStream);
fileStream.Close();
return result;
}
@@ -111,8 +111,8 @@ namespace DiscImageChef.Checksums
/// Byte array of the hash value.
public string File(string filename, out byte[] hash)
{
- FileStream fileStream = new FileStream(filename, FileMode.Open);
- hash = sha256Provider.ComputeHash(fileStream);
+ FileStream fileStream = new FileStream(filename, FileMode.Open);
+ hash = sha256Provider.ComputeHash(fileStream);
StringBuilder sha256Output = new StringBuilder();
foreach(byte h in hash) sha256Output.Append(h.ToString("x2"));
@@ -130,7 +130,7 @@ namespace DiscImageChef.Checksums
/// Byte array of the hash value.
public string Data(byte[] data, uint len, out byte[] hash)
{
- hash = sha256Provider.ComputeHash(data, 0, (int)len);
+ hash = sha256Provider.ComputeHash(data, 0, (int)len);
StringBuilder sha256Output = new StringBuilder();
foreach(byte h in hash) sha256Output.Append(h.ToString("x2"));
diff --git a/DiscImageChef.Checksums/SHA384Context.cs b/DiscImageChef.Checksums/SHA384Context.cs
index 1fd534cb..cd66c8b6 100644
--- a/DiscImageChef.Checksums/SHA384Context.cs
+++ b/DiscImageChef.Checksums/SHA384Context.cs
@@ -46,7 +46,7 @@ namespace DiscImageChef.Checksums
///
/// Initializes the SHA384 hash provider
///
- public void Init()
+ public Sha384Context()
{
sha384Provider = SHA384.Create();
}
@@ -99,7 +99,7 @@ namespace DiscImageChef.Checksums
public byte[] File(string filename)
{
FileStream fileStream = new FileStream(filename, FileMode.Open);
- byte[] result = sha384Provider.ComputeHash(fileStream);
+ byte[] result = sha384Provider.ComputeHash(fileStream);
fileStream.Close();
return result;
}
@@ -111,8 +111,8 @@ namespace DiscImageChef.Checksums
/// Byte array of the hash value.
public string File(string filename, out byte[] hash)
{
- FileStream fileStream = new FileStream(filename, FileMode.Open);
- hash = sha384Provider.ComputeHash(fileStream);
+ FileStream fileStream = new FileStream(filename, FileMode.Open);
+ hash = sha384Provider.ComputeHash(fileStream);
StringBuilder sha384Output = new StringBuilder();
foreach(byte h in hash) sha384Output.Append(h.ToString("x2"));
@@ -130,7 +130,7 @@ namespace DiscImageChef.Checksums
/// Byte array of the hash value.
public string Data(byte[] data, uint len, out byte[] hash)
{
- hash = sha384Provider.ComputeHash(data, 0, (int)len);
+ hash = sha384Provider.ComputeHash(data, 0, (int)len);
StringBuilder sha384Output = new StringBuilder();
foreach(byte h in hash) sha384Output.Append(h.ToString("x2"));
diff --git a/DiscImageChef.Checksums/SHA512Context.cs b/DiscImageChef.Checksums/SHA512Context.cs
index 5beb4cce..d90e0ff8 100644
--- a/DiscImageChef.Checksums/SHA512Context.cs
+++ b/DiscImageChef.Checksums/SHA512Context.cs
@@ -46,7 +46,7 @@ namespace DiscImageChef.Checksums
///
/// Initializes the SHA512 hash provider
///
- public void Init()
+ public Sha512Context()
{
sha512Provider = SHA512.Create();
}
@@ -99,7 +99,7 @@ namespace DiscImageChef.Checksums
public byte[] File(string filename)
{
FileStream fileStream = new FileStream(filename, FileMode.Open);
- byte[] result = sha512Provider.ComputeHash(fileStream);
+ byte[] result = sha512Provider.ComputeHash(fileStream);
fileStream.Close();
return result;
}
@@ -111,8 +111,8 @@ namespace DiscImageChef.Checksums
/// Byte array of the hash value.
public string File(string filename, out byte[] hash)
{
- FileStream fileStream = new FileStream(filename, FileMode.Open);
- hash = sha512Provider.ComputeHash(fileStream);
+ FileStream fileStream = new FileStream(filename, FileMode.Open);
+ hash = sha512Provider.ComputeHash(fileStream);
StringBuilder sha512Output = new StringBuilder();
foreach(byte h in hash) sha512Output.Append(h.ToString("x2"));
@@ -130,7 +130,7 @@ namespace DiscImageChef.Checksums
/// Byte array of the hash value.
public string Data(byte[] data, uint len, out byte[] hash)
{
- hash = sha512Provider.ComputeHash(data, 0, (int)len);
+ hash = sha512Provider.ComputeHash(data, 0, (int)len);
StringBuilder sha512Output = new StringBuilder();
foreach(byte h in hash) sha512Output.Append(h.ToString("x2"));
diff --git a/DiscImageChef.Checksums/SpamSumContext.cs b/DiscImageChef.Checksums/SpamSumContext.cs
index 14878322..b36a1376 100644
--- a/DiscImageChef.Checksums/SpamSumContext.cs
+++ b/DiscImageChef.Checksums/SpamSumContext.cs
@@ -49,12 +49,12 @@ namespace DiscImageChef.Checksums
///
public class SpamSumContext : IChecksum
{
- const uint ROLLING_WINDOW = 7;
- const uint MIN_BLOCKSIZE = 3;
- const uint HASH_PRIME = 0x01000193;
- const uint HASH_INIT = 0x28021967;
- const uint NUM_BLOCKHASHES = 31;
- const uint SPAMSUM_LENGTH = 64;
+ const uint ROLLING_WINDOW = 7;
+ const uint MIN_BLOCKSIZE = 3;
+ const uint HASH_PRIME = 0x01000193;
+ const uint HASH_INIT = 0x28021967;
+ const uint NUM_BLOCKHASHES = 31;
+ const uint SPAMSUM_LENGTH = 64;
const uint FUZZY_MAX_RESULT = 2 * SPAMSUM_LENGTH + 20;
//"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
readonly byte[] b64 =
@@ -67,30 +67,70 @@ namespace DiscImageChef.Checksums
FuzzyState self;
- void roll_init()
- {
- self.Roll = new RollState {Window = new byte[ROLLING_WINDOW]};
- }
-
///
/// Initializes the SpamSum structures
///
- public void Init()
+ public SpamSumContext()
{
- self = new FuzzyState {Bh = new BlockhashContext[NUM_BLOCKHASHES]};
+ self =
+ new FuzzyState {Bh = new BlockhashContext[NUM_BLOCKHASHES]};
for(int i = 0; i < NUM_BLOCKHASHES; i++) self.Bh[i].Digest = new byte[SPAMSUM_LENGTH];
- self.Bhstart = 0;
- self.Bhend = 1;
- self.Bh[0].H = HASH_INIT;
- self.Bh[0].Halfh = HASH_INIT;
- self.Bh[0].Digest[0] = 0;
+ self.Bhstart = 0;
+ self.Bhend = 1;
+ self.Bh[0].H = HASH_INIT;
+ self.Bh[0].Halfh = HASH_INIT;
+ self.Bh[0].Digest[0] = 0;
self.Bh[0].Halfdigest = 0;
- self.Bh[0].Dlen = 0;
- self.TotalSize = 0;
+ self.Bh[0].Dlen = 0;
+ self.TotalSize = 0;
roll_init();
}
+ ///
+ /// Updates the hash with data.
+ ///
+ /// Data buffer.
+ /// Length of buffer to hash.
+ public void Update(byte[] data, uint len)
+ {
+ self.TotalSize += len;
+ for(int i = 0; i < len; i++) fuzzy_engine_step(data[i]);
+ }
+
+ ///
+ /// Updates the hash with data.
+ ///
+ /// Data buffer.
+ public void Update(byte[] data)
+ {
+ Update(data, (uint)data.Length);
+ }
+
+ ///
+ /// Returns a byte array of the hash value.
+ ///
+ public byte[] Final()
+ {
+ // SpamSum does not have a binary representation, or so it seems
+ throw new NotImplementedException("SpamSum does not have a binary representation.");
+ }
+
+ ///
+ /// Returns a base64 representation of the hash value.
+ ///
+ public string End()
+ {
+ FuzzyDigest(out byte[] result);
+
+ return CToString(result);
+ }
+
+ void roll_init()
+ {
+ self.Roll = new RollState {Window = new byte[ROLLING_WINDOW]};
+ }
+
/*
* a rolling hash, based on the Adler checksum. By using a rolling hash
* we can perform auto resynchronisation after inserts/deletes
@@ -116,7 +156,7 @@ namespace DiscImageChef.Checksums
* in theory should have no effect. This AND has been removed
* for performance (jk) */
self.Roll.H3 <<= 5;
- self.Roll.H3 ^= c;
+ self.Roll.H3 ^= c;
}
uint roll_sum()
@@ -144,13 +184,13 @@ namespace DiscImageChef.Checksums
if(self.Bhend == 0) // assert
throw new Exception("Assertion failed");
- obh = self.Bhend - 1;
- nbh = self.Bhend;
- self.Bh[nbh].H = self.Bh[obh].H;
- self.Bh[nbh].Halfh = self.Bh[obh].Halfh;
- self.Bh[nbh].Digest[0] = 0;
+ obh = self.Bhend - 1;
+ nbh = self.Bhend;
+ self.Bh[nbh].H = self.Bh[obh].H;
+ self.Bh[nbh].Halfh = self.Bh[obh].Halfh;
+ self.Bh[nbh].Digest[0] = 0;
self.Bh[nbh].Halfdigest = 0;
- self.Bh[nbh].Dlen = 0;
+ self.Bh[nbh].Dlen = 0;
++self.Bhend;
}
@@ -165,6 +205,7 @@ namespace DiscImageChef.Checksums
* blocksize. */ return;
if(self.Bh[self.Bhstart + 1].Dlen < SPAMSUM_LENGTH / 2)
/* Estimate adjustment would select this blocksize. */ return;
+
/* At this point we are clearly no longer interested in the
* start_blocksize. Get rid of it. */
++self.Bhstart;
@@ -173,7 +214,7 @@ namespace DiscImageChef.Checksums
void fuzzy_engine_step(byte c)
{
ulong h;
- uint i;
+ uint i;
/* At each character we update the rolling hash and the normal hashes.
* When the rolling hash hits a reset value then we emit a normal hash
* as a element of the signature and reset the normal hash. */
@@ -182,7 +223,7 @@ namespace DiscImageChef.Checksums
for(i = self.Bhstart; i < self.Bhend; ++i)
{
- self.Bh[i].H = sum_hash(c, self.Bh[i].H);
+ self.Bh[i].H = sum_hash(c, self.Bh[i].H);
self.Bh[i].Halfh = sum_hash(c, self.Bh[i].Halfh);
}
@@ -193,12 +234,13 @@ namespace DiscImageChef.Checksums
/* Once this condition is false for one bs, it is
* automatically false for all further bs. I.e. if
* h === -1 (mod 2*bs) then h === -1 (mod bs). */ break;
+
/* We have hit a reset point. We now emit hashes which are
* based on all characters in the piece of the message between
* the last reset point and this one */
if(0 == self.Bh[i].Dlen) fuzzy_try_fork_blockhash();
- self.Bh[i].Digest[self.Bh[i].Dlen] = b64[self.Bh[i].H % 64];
- self.Bh[i].Halfdigest = b64[self.Bh[i].Halfh % 64];
+ self.Bh[i].Digest[self.Bh[i].Dlen] = b64[self.Bh[i].H % 64];
+ self.Bh[i].Halfdigest = b64[self.Bh[i].Halfh % 64];
if(self.Bh[i].Dlen < SPAMSUM_LENGTH - 1)
{
/* We can have a problem with the tail overflowing. The
@@ -208,45 +250,25 @@ namespace DiscImageChef.Checksums
* last few pieces of the message into a single piece
* */
self.Bh[i].Digest[++self.Bh[i].Dlen] = 0;
- self.Bh[i].H = HASH_INIT;
+ self.Bh[i].H = HASH_INIT;
if(self.Bh[i].Dlen >= SPAMSUM_LENGTH / 2) continue;
- self.Bh[i].Halfh = HASH_INIT;
+ self.Bh[i].Halfh = HASH_INIT;
self.Bh[i].Halfdigest = 0;
}
else fuzzy_try_reduce_blockhash();
}
}
- ///
- /// Updates the hash with data.
- ///
- /// Data buffer.
- /// Length of buffer to hash.
- public void Update(byte[] data, uint len)
- {
- self.TotalSize += len;
- for(int i = 0; i < len; i++) fuzzy_engine_step(data[i]);
- }
-
- ///
- /// Updates the hash with data.
- ///
- /// Data buffer.
- public void Update(byte[] data)
- {
- Update(data, (uint)data.Length);
- }
-
// CLAUNIA: Flags seems to never be used in ssdeep, so I just removed it for code simplicity
uint FuzzyDigest(out byte[] result)
{
StringBuilder sb = new StringBuilder();
- uint bi = self.Bhstart;
- uint h = roll_sum();
- int i, resultOff;
- int remain = (int)(FUZZY_MAX_RESULT - 1); /* Exclude terminating '\0'. */
- result = new byte[FUZZY_MAX_RESULT];
+ uint bi = self.Bhstart;
+ uint h = roll_sum();
+ int i, resultOff;
+ int remain = (int)(FUZZY_MAX_RESULT - 1); /* Exclude terminating '\0'. */
+ result = new byte[FUZZY_MAX_RESULT];
/* Verify that our elimination was not overeager. */
if(!(bi == 0 || (ulong)SSDEEP_BS(bi) / 2 * SPAMSUM_LENGTH < self.TotalSize))
throw new Exception("Assertion failed");
@@ -259,6 +281,7 @@ namespace DiscImageChef.Checksums
++bi;
if(bi >= NUM_BLOCKHASHES) throw new OverflowException("The input exceeds data types.");
}
+
/* Adapt blocksize guess to actual digest length. */
while(bi >= self.Bhend) --bi;
while(bi > self.Bhstart && self.Bh[bi].Dlen < SPAMSUM_LENGTH / 2) --bi;
@@ -282,14 +305,15 @@ namespace DiscImageChef.Checksums
Array.Copy(self.Bh[bi].Digest, 0, result, resultOff, i);
resultOff += i;
- remain -= i;
+ remain -= i;
if(h != 0)
{
if(remain <= 0) throw new Exception("Assertion failed");
result[resultOff] = b64[self.Bh[bi].H % 64];
- if(i < 3 || result[resultOff] != result[resultOff - 1] || result[resultOff] != result[resultOff - 2] ||
- result[resultOff] != result[resultOff - 3])
+ if(i < 3 || result[resultOff] != result[resultOff - 1] ||
+ result[resultOff] != result[resultOff - 2] ||
+ result[resultOff] != result[resultOff - 3])
{
++resultOff;
--remain;
@@ -300,8 +324,9 @@ namespace DiscImageChef.Checksums
if(remain <= 0) throw new Exception("Assertion failed");
result[resultOff] = self.Bh[bi].Digest[i];
- if(i < 3 || result[resultOff] != result[resultOff - 1] || result[resultOff] != result[resultOff - 2] ||
- result[resultOff] != result[resultOff - 3])
+ if(i < 3 || result[resultOff] != result[resultOff - 1] ||
+ result[resultOff] != result[resultOff - 2] ||
+ result[resultOff] != result[resultOff - 3])
{
++resultOff;
--remain;
@@ -320,16 +345,17 @@ namespace DiscImageChef.Checksums
Array.Copy(self.Bh[bi].Digest, 0, result, resultOff, i);
resultOff += i;
- remain -= i;
+ remain -= i;
if(h != 0)
{
if(remain <= 0) throw new Exception("Assertion failed");
- h = self.Bh[bi].Halfh;
+ h = self.Bh[bi].Halfh;
result[resultOff] = b64[h % 64];
- if(i < 3 || result[resultOff] != result[resultOff - 1] ||
- result[resultOff] != result[resultOff - 2] || result[resultOff] != result[resultOff - 3])
+ if(i < 3 || result[resultOff] != result[resultOff - 1] ||
+ result[resultOff] != result[resultOff - 2] ||
+ result[resultOff] != result[resultOff - 3])
{
++resultOff;
--remain;
@@ -343,8 +369,9 @@ namespace DiscImageChef.Checksums
if(remain <= 0) throw new Exception("Assertion failed");
result[resultOff] = (byte)i;
- if(i < 3 || result[resultOff] != result[resultOff - 1] ||
- result[resultOff] != result[resultOff - 2] || result[resultOff] != result[resultOff - 3])
+ if(i < 3 || result[resultOff] != result[resultOff - 1] ||
+ result[resultOff] != result[resultOff - 2] ||
+ result[resultOff] != result[resultOff - 3])
{
++resultOff;
--remain;
@@ -355,7 +382,7 @@ namespace DiscImageChef.Checksums
else if(h != 0)
{
if(self.Bh[bi].Dlen != 0) throw new Exception("Assertion failed");
- if(remain <= 0) throw new Exception("Assertion failed");
+ if(remain <= 0) throw new Exception("Assertion failed");
result[resultOff++] = b64[self.Bh[bi].H % 64];
/* No need to bother with FUZZY_FLAG_ELIMSEQ, because this
@@ -367,25 +394,6 @@ namespace DiscImageChef.Checksums
return 0;
}
- ///
- /// Returns a byte array of the hash value.
- ///
- public byte[] Final()
- {
- // SpamSum does not have a binary representation, or so it seems
- throw new NotImplementedException("SpamSum does not have a binary representation.");
- }
-
- ///
- /// Returns a base64 representation of the hash value.
- ///
- public string End()
- {
- FuzzyDigest(out byte[] result);
-
- return CToString(result);
- }
-
///
/// Gets the hash of a file
///
@@ -417,7 +425,6 @@ namespace DiscImageChef.Checksums
public static string Data(byte[] data, uint len, out byte[] hash)
{
SpamSumContext fuzzyContext = new SpamSumContext();
- fuzzyContext.Init();
fuzzyContext.Update(data, len);
@@ -469,8 +476,8 @@ namespace DiscImageChef.Checksums
* output hash to stay compatible with ssdeep output. */
struct BlockhashContext
{
- public uint H;
- public uint Halfh;
+ public uint H;
+ public uint Halfh;
public byte[] Digest;
// SPAMSUM_LENGTH
public byte Halfdigest;
@@ -479,11 +486,11 @@ namespace DiscImageChef.Checksums
struct FuzzyState
{
- public uint Bhstart;
- public uint Bhend;
+ public uint Bhstart;
+ public uint Bhend;
public BlockhashContext[] Bh;
//NUM_BLOCKHASHES
- public ulong TotalSize;
+ public ulong TotalSize;
public RollState Roll;
}
}
diff --git a/DiscImageChef.Core/Benchmark.cs b/DiscImageChef.Core/Benchmark.cs
index 05ea105c..d04ef069 100644
--- a/DiscImageChef.Core/Benchmark.cs
+++ b/DiscImageChef.Core/Benchmark.cs
@@ -33,26 +33,25 @@
using System;
using System.Collections.Generic;
using System.IO;
-using System.Linq;
using DiscImageChef.Checksums;
namespace DiscImageChef.Core
{
public struct BenchmarkResults
{
- public double FillTime;
- public double FillSpeed;
- public double ReadTime;
- public double ReadSpeed;
- public double EntropyTime;
- public double EntropySpeed;
+ public double FillTime;
+ public double FillSpeed;
+ public double ReadTime;
+ public double ReadSpeed;
+ public double EntropyTime;
+ public double EntropySpeed;
public Dictionary Entries;
- public long MinMemory;
- public long MaxMemory;
- public double SeparateTime;
- public double SeparateSpeed;
- public double TotalTime;
- public double TotalSpeed;
+ public long MinMemory;
+ public long MaxMemory;
+ public double SeparateTime;
+ public double SeparateSpeed;
+ public double TotalTime;
+ public double TotalSpeed;
}
public struct BenchmarkEntry
@@ -66,9 +65,9 @@ namespace DiscImageChef.Core
///
public static class Benchmark
{
- public static event InitProgressHandler InitProgressEvent;
+ public static event InitProgressHandler InitProgressEvent;
public static event UpdateProgressHandler UpdateProgressEvent;
- public static event EndProgressHandler EndProgressEvent;
+ public static event EndProgressHandler EndProgressEvent;
static void InitProgress()
{
@@ -89,16 +88,16 @@ namespace DiscImageChef.Core
{
BenchmarkResults results = new BenchmarkResults
{
- Entries = new Dictionary(),
- MinMemory = long.MaxValue,
- MaxMemory = 0,
+ Entries = new Dictionary(),
+ MinMemory = long.MaxValue,
+ MaxMemory = 0,
SeparateTime = 0
};
- MemoryStream ms = new MemoryStream(bufferSize);
- Random rnd = new Random();
- DateTime start;
- DateTime end;
- long mem;
+ MemoryStream ms = new MemoryStream(bufferSize);
+ Random rnd = new Random();
+ DateTime start;
+ DateTime end;
+ long mem;
start = DateTime.Now;
InitProgress();
@@ -113,14 +112,14 @@ namespace DiscImageChef.Core
EndProgress();
end = DateTime.Now;
- results.FillTime = (end - start).TotalSeconds;
+ results.FillTime = (end - start).TotalSeconds;
results.FillSpeed = bufferSize / 1048576.0 / (end - start).TotalSeconds;
ms.Seek(0, SeekOrigin.Begin);
- mem = GC.GetTotalMemory(false);
+ mem = GC.GetTotalMemory(false);
if(mem > results.MaxMemory) results.MaxMemory = mem;
if(mem < results.MinMemory) results.MinMemory = mem;
- start = DateTime.Now;
+ start = DateTime.Now;
InitProgress();
for(int i = 0; i < bufferSize / blockSize; i++)
{
@@ -130,22 +129,21 @@ namespace DiscImageChef.Core
}
EndProgress();
- end = DateTime.Now;
- mem = GC.GetTotalMemory(false);
+ end = DateTime.Now;
+ mem = GC.GetTotalMemory(false);
if(mem > results.MaxMemory) results.MaxMemory = mem;
if(mem < results.MinMemory) results.MinMemory = mem;
- results.ReadTime = (end - start).TotalSeconds;
+ results.ReadTime = (end - start).TotalSeconds;
results.ReadSpeed = bufferSize / 1048576.0 / (end - start).TotalSeconds;
#region Adler32
IChecksum ctx = new Adler32Context();
- ctx.Init();
ms.Seek(0, SeekOrigin.Begin);
- mem = GC.GetTotalMemory(false);
+ mem = GC.GetTotalMemory(false);
if(mem > results.MaxMemory) results.MaxMemory = mem;
if(mem < results.MinMemory) results.MinMemory = mem;
- start = DateTime.Now;
+ start = DateTime.Now;
InitProgress();
for(int i = 0; i < bufferSize / blockSize; i++)
{
@@ -157,28 +155,27 @@ namespace DiscImageChef.Core
EndProgress();
ctx.End();
- end = DateTime.Now;
- mem = GC.GetTotalMemory(false);
+ end = DateTime.Now;
+ mem = GC.GetTotalMemory(false);
if(mem > results.MaxMemory) results.MaxMemory = mem;
if(mem < results.MinMemory) results.MinMemory = mem;
results.Entries.Add("Adler32",
new BenchmarkEntry
{
- TimeSpan = (end - start).TotalSeconds,
- Speed = bufferSize / 1048576.0 / (end - start).TotalSeconds
+ TimeSpan = (end - start).TotalSeconds,
+ Speed = bufferSize / 1048576.0 / (end - start).TotalSeconds
});
results.SeparateTime += (end - start).TotalSeconds;
#endregion Adler32
#region CRC16
ctx = new Crc16Context();
- ctx.Init();
ms.Seek(0, SeekOrigin.Begin);
- mem = GC.GetTotalMemory(false);
+ mem = GC.GetTotalMemory(false);
if(mem > results.MaxMemory) results.MaxMemory = mem;
if(mem < results.MinMemory) results.MinMemory = mem;
- start = DateTime.Now;
+ start = DateTime.Now;
InitProgress();
for(int i = 0; i < bufferSize / blockSize; i++)
{
@@ -190,28 +187,27 @@ namespace DiscImageChef.Core
EndProgress();
ctx.End();
- end = DateTime.Now;
- mem = GC.GetTotalMemory(false);
+ end = DateTime.Now;
+ mem = GC.GetTotalMemory(false);
if(mem > results.MaxMemory) results.MaxMemory = mem;
if(mem < results.MinMemory) results.MinMemory = mem;
results.Entries.Add("CRC16",
new BenchmarkEntry
{
- TimeSpan = (end - start).TotalSeconds,
- Speed = bufferSize / 1048576.0 / (end - start).TotalSeconds
+ TimeSpan = (end - start).TotalSeconds,
+ Speed = bufferSize / 1048576.0 / (end - start).TotalSeconds
});
results.SeparateTime += (end - start).TotalSeconds;
#endregion CRC16
#region CRC32
ctx = new Crc32Context();
- ctx.Init();
ms.Seek(0, SeekOrigin.Begin);
- mem = GC.GetTotalMemory(false);
+ mem = GC.GetTotalMemory(false);
if(mem > results.MaxMemory) results.MaxMemory = mem;
if(mem < results.MinMemory) results.MinMemory = mem;
- start = DateTime.Now;
+ start = DateTime.Now;
InitProgress();
for(int i = 0; i < bufferSize / blockSize; i++)
{
@@ -223,28 +219,27 @@ namespace DiscImageChef.Core
EndProgress();
ctx.End();
- end = DateTime.Now;
- mem = GC.GetTotalMemory(false);
+ end = DateTime.Now;
+ mem = GC.GetTotalMemory(false);
if(mem > results.MaxMemory) results.MaxMemory = mem;
if(mem < results.MinMemory) results.MinMemory = mem;
results.Entries.Add("CRC32",
new BenchmarkEntry
{
- TimeSpan = (end - start).TotalSeconds,
- Speed = bufferSize / 1048576.0 / (end - start).TotalSeconds
+ TimeSpan = (end - start).TotalSeconds,
+ Speed = bufferSize / 1048576.0 / (end - start).TotalSeconds
});
results.SeparateTime += (end - start).TotalSeconds;
#endregion CRC32
#region CRC64
ctx = new Crc64Context();
- ctx.Init();
ms.Seek(0, SeekOrigin.Begin);
- mem = GC.GetTotalMemory(false);
+ mem = GC.GetTotalMemory(false);
if(mem > results.MaxMemory) results.MaxMemory = mem;
if(mem < results.MinMemory) results.MinMemory = mem;
- start = DateTime.Now;
+ start = DateTime.Now;
InitProgress();
for(int i = 0; i < bufferSize / blockSize; i++)
{
@@ -256,28 +251,27 @@ namespace DiscImageChef.Core
EndProgress();
ctx.End();
- end = DateTime.Now;
- mem = GC.GetTotalMemory(false);
+ end = DateTime.Now;
+ mem = GC.GetTotalMemory(false);
if(mem > results.MaxMemory) results.MaxMemory = mem;
if(mem < results.MinMemory) results.MinMemory = mem;
results.Entries.Add("CRC64",
new BenchmarkEntry
{
- TimeSpan = (end - start).TotalSeconds,
- Speed = bufferSize / 1048576.0 / (end - start).TotalSeconds
+ TimeSpan = (end - start).TotalSeconds,
+ Speed = bufferSize / 1048576.0 / (end - start).TotalSeconds
});
results.SeparateTime += (end - start).TotalSeconds;
#endregion CRC64
#region MD5
ctx = new Md5Context();
- ctx.Init();
ms.Seek(0, SeekOrigin.Begin);
- mem = GC.GetTotalMemory(false);
+ mem = GC.GetTotalMemory(false);
if(mem > results.MaxMemory) results.MaxMemory = mem;
if(mem < results.MinMemory) results.MinMemory = mem;
- start = DateTime.Now;
+ start = DateTime.Now;
InitProgress();
for(int i = 0; i < bufferSize / blockSize; i++)
{
@@ -289,28 +283,27 @@ namespace DiscImageChef.Core
EndProgress();
ctx.End();
- end = DateTime.Now;
- mem = GC.GetTotalMemory(false);
+ end = DateTime.Now;
+ mem = GC.GetTotalMemory(false);
if(mem > results.MaxMemory) results.MaxMemory = mem;
if(mem < results.MinMemory) results.MinMemory = mem;
results.Entries.Add("MD5",
new BenchmarkEntry
{
- TimeSpan = (end - start).TotalSeconds,
- Speed = bufferSize / 1048576.0 / (end - start).TotalSeconds
+ TimeSpan = (end - start).TotalSeconds,
+ Speed = bufferSize / 1048576.0 / (end - start).TotalSeconds
});
results.SeparateTime += (end - start).TotalSeconds;
#endregion MD5
#region RIPEMD160
ctx = new Ripemd160Context();
- ctx.Init();
ms.Seek(0, SeekOrigin.Begin);
- mem = GC.GetTotalMemory(false);
+ mem = GC.GetTotalMemory(false);
if(mem > results.MaxMemory) results.MaxMemory = mem;
if(mem < results.MinMemory) results.MinMemory = mem;
- start = DateTime.Now;
+ start = DateTime.Now;
InitProgress();
for(int i = 0; i < bufferSize / blockSize; i++)
{
@@ -322,28 +315,27 @@ namespace DiscImageChef.Core
EndProgress();
ctx.End();
- end = DateTime.Now;
- mem = GC.GetTotalMemory(false);
+ end = DateTime.Now;
+ mem = GC.GetTotalMemory(false);
if(mem > results.MaxMemory) results.MaxMemory = mem;
if(mem < results.MinMemory) results.MinMemory = mem;
results.Entries.Add("RIPEMD160",
new BenchmarkEntry
{
- TimeSpan = (end - start).TotalSeconds,
- Speed = bufferSize / 1048576.0 / (end - start).TotalSeconds
+ TimeSpan = (end - start).TotalSeconds,
+ Speed = bufferSize / 1048576.0 / (end - start).TotalSeconds
});
results.SeparateTime += (end - start).TotalSeconds;
#endregion RIPEMD160
#region SHA1
ctx = new Sha1Context();
- ctx.Init();
ms.Seek(0, SeekOrigin.Begin);
- mem = GC.GetTotalMemory(false);
+ mem = GC.GetTotalMemory(false);
if(mem > results.MaxMemory) results.MaxMemory = mem;
if(mem < results.MinMemory) results.MinMemory = mem;
- start = DateTime.Now;
+ start = DateTime.Now;
InitProgress();
for(int i = 0; i < bufferSize / blockSize; i++)
{
@@ -355,28 +347,27 @@ namespace DiscImageChef.Core
EndProgress();
ctx.End();
- end = DateTime.Now;
- mem = GC.GetTotalMemory(false);
+ end = DateTime.Now;
+ mem = GC.GetTotalMemory(false);
if(mem > results.MaxMemory) results.MaxMemory = mem;
if(mem < results.MinMemory) results.MinMemory = mem;
results.Entries.Add("SHA1",
new BenchmarkEntry
{
- TimeSpan = (end - start).TotalSeconds,
- Speed = bufferSize / 1048576.0 / (end - start).TotalSeconds
+ TimeSpan = (end - start).TotalSeconds,
+ Speed = bufferSize / 1048576.0 / (end - start).TotalSeconds
});
results.SeparateTime += (end - start).TotalSeconds;
#endregion SHA1
#region SHA256
ctx = new Sha256Context();
- ctx.Init();
ms.Seek(0, SeekOrigin.Begin);
- mem = GC.GetTotalMemory(false);
+ mem = GC.GetTotalMemory(false);
if(mem > results.MaxMemory) results.MaxMemory = mem;
if(mem < results.MinMemory) results.MinMemory = mem;
- start = DateTime.Now;
+ start = DateTime.Now;
InitProgress();
for(int i = 0; i < bufferSize / blockSize; i++)
{
@@ -388,28 +379,27 @@ namespace DiscImageChef.Core
EndProgress();
ctx.End();
- end = DateTime.Now;
- mem = GC.GetTotalMemory(false);
+ end = DateTime.Now;
+ mem = GC.GetTotalMemory(false);
if(mem > results.MaxMemory) results.MaxMemory = mem;
if(mem < results.MinMemory) results.MinMemory = mem;
results.Entries.Add("SHA256",
new BenchmarkEntry
{
- TimeSpan = (end - start).TotalSeconds,
- Speed = bufferSize / 1048576.0 / (end - start).TotalSeconds
+ TimeSpan = (end - start).TotalSeconds,
+ Speed = bufferSize / 1048576.0 / (end - start).TotalSeconds
});
results.SeparateTime += (end - start).TotalSeconds;
#endregion SHA256
#region SHA384
ctx = new Sha384Context();
- ctx.Init();
ms.Seek(0, SeekOrigin.Begin);
- mem = GC.GetTotalMemory(false);
+ mem = GC.GetTotalMemory(false);
if(mem > results.MaxMemory) results.MaxMemory = mem;
if(mem < results.MinMemory) results.MinMemory = mem;
- start = DateTime.Now;
+ start = DateTime.Now;
InitProgress();
for(int i = 0; i < bufferSize / blockSize; i++)
{
@@ -421,28 +411,27 @@ namespace DiscImageChef.Core
EndProgress();
ctx.End();
- end = DateTime.Now;
- mem = GC.GetTotalMemory(false);
+ end = DateTime.Now;
+ mem = GC.GetTotalMemory(false);
if(mem > results.MaxMemory) results.MaxMemory = mem;
if(mem < results.MinMemory) results.MinMemory = mem;
results.Entries.Add("SHA384",
new BenchmarkEntry
{
- TimeSpan = (end - start).TotalSeconds,
- Speed = bufferSize / 1048576.0 / (end - start).TotalSeconds
+ TimeSpan = (end - start).TotalSeconds,
+ Speed = bufferSize / 1048576.0 / (end - start).TotalSeconds
});
results.SeparateTime += (end - start).TotalSeconds;
#endregion SHA384
#region SHA512
ctx = new Sha512Context();
- ctx.Init();
ms.Seek(0, SeekOrigin.Begin);
- mem = GC.GetTotalMemory(false);
+ mem = GC.GetTotalMemory(false);
if(mem > results.MaxMemory) results.MaxMemory = mem;
if(mem < results.MinMemory) results.MinMemory = mem;
- start = DateTime.Now;
+ start = DateTime.Now;
InitProgress();
for(int i = 0; i < bufferSize / blockSize; i++)
{
@@ -454,28 +443,27 @@ namespace DiscImageChef.Core
EndProgress();
ctx.End();
- end = DateTime.Now;
- mem = GC.GetTotalMemory(false);
+ end = DateTime.Now;
+ mem = GC.GetTotalMemory(false);
if(mem > results.MaxMemory) results.MaxMemory = mem;
if(mem < results.MinMemory) results.MinMemory = mem;
results.Entries.Add("SHA512",
new BenchmarkEntry
{
- TimeSpan = (end - start).TotalSeconds,
- Speed = bufferSize / 1048576.0 / (end - start).TotalSeconds
+ TimeSpan = (end - start).TotalSeconds,
+ Speed = bufferSize / 1048576.0 / (end - start).TotalSeconds
});
results.SeparateTime += (end - start).TotalSeconds;
#endregion SHA512
#region SpamSum
ctx = new SpamSumContext();
- ctx.Init();
ms.Seek(0, SeekOrigin.Begin);
- mem = GC.GetTotalMemory(false);
+ mem = GC.GetTotalMemory(false);
if(mem > results.MaxMemory) results.MaxMemory = mem;
if(mem < results.MinMemory) results.MinMemory = mem;
- start = DateTime.Now;
+ start = DateTime.Now;
InitProgress();
for(int i = 0; i < bufferSize / blockSize; i++)
{
@@ -487,16 +475,16 @@ namespace DiscImageChef.Core
EndProgress();
ctx.End();
- end = DateTime.Now;
- mem = GC.GetTotalMemory(false);
+ end = DateTime.Now;
+ mem = GC.GetTotalMemory(false);
if(mem > results.MaxMemory) results.MaxMemory = mem;
if(mem < results.MinMemory) results.MinMemory = mem;
results.Entries.Add("SpamSum",
new BenchmarkEntry
{
- TimeSpan = (end - start).TotalSeconds,
- Speed = bufferSize / 1048576.0 / (end - start).TotalSeconds
+ TimeSpan = (end - start).TotalSeconds,
+ Speed = bufferSize / 1048576.0 / (end - start).TotalSeconds
});
results.SeparateTime += (end - start).TotalSeconds;
#endregion SpamSum
@@ -504,10 +492,10 @@ namespace DiscImageChef.Core
#region Entropy
ulong[] entTable = new ulong[256];
ms.Seek(0, SeekOrigin.Begin);
- mem = GC.GetTotalMemory(false);
+ mem = GC.GetTotalMemory(false);
if(mem > results.MaxMemory) results.MaxMemory = mem;
if(mem < results.MinMemory) results.MinMemory = mem;
- start = DateTime.Now;
+ start = DateTime.Now;
InitProgress();
for(int i = 0; i < bufferSize / blockSize; i++)
{
@@ -518,20 +506,18 @@ namespace DiscImageChef.Core
}
EndProgress();
- double entropy = entTable.Select(l => (double)l / (double)bufferSize)
- .Select(frequency => -(frequency * Math.Log(frequency, 2))).Sum();
- end = DateTime.Now;
- mem = GC.GetTotalMemory(false);
+ end = DateTime.Now;
+ mem = GC.GetTotalMemory(false);
if(mem > results.MaxMemory) results.MaxMemory = mem;
if(mem < results.MinMemory) results.MinMemory = mem;
- results.EntropyTime = (end - start).TotalSeconds;
+ results.EntropyTime = (end - start).TotalSeconds;
results.EntropySpeed = bufferSize / 1048576.0 / (end - start).TotalSeconds;
#endregion Entropy
#region Multitasking
- start = DateTime.Now;
+ start = DateTime.Now;
Checksum allChecksums = new Checksum();
InitProgress();
for(int i = 0; i < bufferSize / blockSize; i++)
@@ -547,12 +533,12 @@ namespace DiscImageChef.Core
EndProgress();
allChecksums.End();
- end = DateTime.Now;
- mem = GC.GetTotalMemory(false);
+ end = DateTime.Now;
+ mem = GC.GetTotalMemory(false);
if(mem > results.MaxMemory) results.MaxMemory = mem;
if(mem < results.MinMemory) results.MinMemory = mem;
- results.TotalTime = (end - start).TotalSeconds;
+ results.TotalTime = (end - start).TotalSeconds;
results.TotalSpeed = bufferSize / 1048576.0 / results.TotalTime;
#endregion
diff --git a/DiscImageChef.Core/Checksum.cs b/DiscImageChef.Core/Checksum.cs
index 8a91c012..638959cf 100644
--- a/DiscImageChef.Core/Checksum.cs
+++ b/DiscImageChef.Core/Checksum.cs
@@ -41,18 +41,18 @@ namespace DiscImageChef.Core
[Flags]
public enum EnableChecksum
{
- Adler32 = 1,
- Crc16 = 2,
- Crc32 = 4,
- Crc64 = 8,
- Md5 = 16,
+ Adler32 = 1,
+ Crc16 = 2,
+ Crc32 = 4,
+ Crc64 = 8,
+ Md5 = 16,
Ripemd160 = 32,
- Sha1 = 64,
- Sha256 = 128,
- Sha384 = 256,
- Sha512 = 512,
- SpamSum = 1024,
- All = Adler32 | Crc16 | Crc32 | Crc64 | Md5 | Ripemd160 | Sha1 | Sha256 | Sha384 | Sha512 | SpamSum
+ Sha1 = 64,
+ Sha256 = 128,
+ Sha384 = 256,
+ Sha512 = 512,
+ SpamSum = 1024,
+ All = Adler32 | Crc16 | Crc32 | Crc64 | Md5 | Ripemd160 | Sha1 | Sha256 | Sha384 | Sha512 | SpamSum
}
///
@@ -60,40 +60,40 @@ namespace DiscImageChef.Core
///
public class Checksum
{
- IChecksum adler32Ctx;
- HashPacket adlerPkt;
- Thread adlerThread;
- IChecksum crc16Ctx;
- HashPacket crc16Pkt;
- Thread crc16Thread;
- IChecksum crc32Ctx;
- HashPacket crc32Pkt;
- Thread crc32Thread;
- IChecksum crc64Ctx;
- HashPacket crc64Pkt;
- Thread crc64Thread;
+ IChecksum adler32Ctx;
+ HashPacket adlerPkt;
+ Thread adlerThread;
+ IChecksum crc16Ctx;
+ HashPacket crc16Pkt;
+ Thread crc16Thread;
+ IChecksum crc32Ctx;
+ HashPacket crc32Pkt;
+ Thread crc32Thread;
+ IChecksum crc64Ctx;
+ HashPacket crc64Pkt;
+ Thread crc64Thread;
EnableChecksum enabled;
- IChecksum md5Ctx;
- HashPacket md5Pkt;
- Thread md5Thread;
- IChecksum ripemd160Ctx;
- HashPacket ripemd160Pkt;
- Thread ripemd160Thread;
- IChecksum sha1Ctx;
- HashPacket sha1Pkt;
- Thread sha1Thread;
- IChecksum sha256Ctx;
- HashPacket sha256Pkt;
- Thread sha256Thread;
- IChecksum sha384Ctx;
- HashPacket sha384Pkt;
- Thread sha384Thread;
- IChecksum sha512Ctx;
- HashPacket sha512Pkt;
- Thread sha512Thread;
- HashPacket spamsumPkt;
- Thread spamsumThread;
- IChecksum ssctx;
+ IChecksum md5Ctx;
+ HashPacket md5Pkt;
+ Thread md5Thread;
+ IChecksum ripemd160Ctx;
+ HashPacket ripemd160Pkt;
+ Thread ripemd160Thread;
+ IChecksum sha1Ctx;
+ HashPacket sha1Pkt;
+ Thread sha1Thread;
+ IChecksum sha256Ctx;
+ HashPacket sha256Pkt;
+ Thread sha256Thread;
+ IChecksum sha384Ctx;
+ HashPacket sha384Pkt;
+ Thread sha384Thread;
+ IChecksum sha512Ctx;
+ HashPacket sha512Pkt;
+ Thread sha512Thread;
+ HashPacket spamsumPkt;
+ Thread spamsumThread;
+ IChecksum ssctx;
public Checksum(EnableChecksum enabled = EnableChecksum.All)
{
@@ -102,102 +102,80 @@ namespace DiscImageChef.Core
if(enabled.HasFlag(EnableChecksum.Adler32))
{
adler32Ctx = new Adler32Context();
- adlerPkt = new HashPacket();
- adler32Ctx.Init();
- adlerPkt.Context = adler32Ctx;
+ adlerPkt = new HashPacket {Context = adler32Ctx};
}
if(enabled.HasFlag(EnableChecksum.Crc16))
{
crc16Ctx = new Crc16Context();
- crc16Pkt = new HashPacket();
- crc16Ctx.Init();
- crc16Pkt.Context = crc16Ctx;
+ crc16Pkt = new HashPacket {Context = crc16Ctx};
}
if(enabled.HasFlag(EnableChecksum.Crc32))
{
crc32Ctx = new Crc32Context();
- crc32Pkt = new HashPacket();
- crc32Ctx.Init();
- crc32Pkt.Context = crc32Ctx;
+ crc32Pkt = new HashPacket {Context = crc32Ctx};
}
if(enabled.HasFlag(EnableChecksum.Crc64))
{
crc64Ctx = new Crc64Context();
- crc64Pkt = new HashPacket();
- crc64Ctx.Init();
- crc64Pkt.Context = crc64Ctx;
+ crc64Pkt = new HashPacket {Context = crc64Ctx};
}
if(enabled.HasFlag(EnableChecksum.Md5))
{
md5Ctx = new Md5Context();
- md5Pkt = new HashPacket();
- md5Ctx.Init();
- md5Pkt.Context = md5Ctx;
+ md5Pkt = new HashPacket {Context = md5Ctx};
}
if(enabled.HasFlag(EnableChecksum.Ripemd160))
{
ripemd160Ctx = new Ripemd160Context();
- ripemd160Pkt = new HashPacket();
- ripemd160Ctx.Init();
- ripemd160Pkt.Context = ripemd160Ctx;
+ ripemd160Pkt = new HashPacket {Context = ripemd160Ctx};
}
if(enabled.HasFlag(EnableChecksum.Sha1))
{
sha1Ctx = new Sha1Context();
- sha1Pkt = new HashPacket();
- sha1Ctx.Init();
- sha1Pkt.Context = sha1Ctx;
+ sha1Pkt = new HashPacket {Context = sha1Ctx};
}
if(enabled.HasFlag(EnableChecksum.Sha256))
{
sha256Ctx = new Sha256Context();
- sha256Pkt = new HashPacket();
- sha256Ctx.Init();
- sha256Pkt.Context = sha256Ctx;
+ sha256Pkt = new HashPacket {Context = sha256Ctx};
}
if(enabled.HasFlag(EnableChecksum.Sha384))
{
sha384Ctx = new Sha384Context();
- sha384Pkt = new HashPacket();
- sha384Ctx.Init();
- sha384Pkt.Context = sha384Ctx;
+ sha384Pkt = new HashPacket {Context = sha384Ctx};
}
if(enabled.HasFlag(EnableChecksum.Sha512))
{
sha512Ctx = new Sha512Context();
- sha512Pkt = new HashPacket();
- sha512Ctx.Init();
- sha512Pkt.Context = sha512Ctx;
+ sha512Pkt = new HashPacket {Context = sha512Ctx};
}
if(enabled.HasFlag(EnableChecksum.SpamSum))
{
- ssctx = new SpamSumContext();
- spamsumPkt = new HashPacket();
- ssctx.Init();
- spamsumPkt.Context = ssctx;
+ ssctx = new SpamSumContext();
+ spamsumPkt = new HashPacket {Context = ssctx};
}
- adlerThread = new Thread(UpdateHash);
- crc16Thread = new Thread(UpdateHash);
- crc32Thread = new Thread(UpdateHash);
- crc64Thread = new Thread(UpdateHash);
- md5Thread = new Thread(UpdateHash);
+ adlerThread = new Thread(UpdateHash);
+ crc16Thread = new Thread(UpdateHash);
+ crc32Thread = new Thread(UpdateHash);
+ crc64Thread = new Thread(UpdateHash);
+ md5Thread = new Thread(UpdateHash);
ripemd160Thread = new Thread(UpdateHash);
- sha1Thread = new Thread(UpdateHash);
- sha256Thread = new Thread(UpdateHash);
- sha384Thread = new Thread(UpdateHash);
- sha512Thread = new Thread(UpdateHash);
- spamsumThread = new Thread(UpdateHash);
+ sha1Thread = new Thread(UpdateHash);
+ sha256Thread = new Thread(UpdateHash);
+ sha384Thread = new Thread(UpdateHash);
+ sha512Thread = new Thread(UpdateHash);
+ spamsumThread = new Thread(UpdateHash);
}
public void Update(byte[] data)
@@ -213,6 +191,7 @@ namespace DiscImageChef.Core
crc16Pkt.Data = data;
crc16Thread.Start(crc16Pkt);
}
+
if(enabled.HasFlag(EnableChecksum.Crc32))
{
crc32Pkt.Data = data;
@@ -267,21 +246,21 @@ namespace DiscImageChef.Core
spamsumThread.Start(spamsumPkt);
}
- while(adlerThread.IsAlive || crc16Thread.IsAlive || crc32Thread.IsAlive || crc64Thread.IsAlive ||
- md5Thread.IsAlive || ripemd160Thread.IsAlive || sha1Thread.IsAlive || sha256Thread.IsAlive ||
- sha384Thread.IsAlive || sha512Thread.IsAlive || spamsumThread.IsAlive) { }
+ while(adlerThread.IsAlive || crc16Thread.IsAlive || crc32Thread.IsAlive || crc64Thread.IsAlive ||
+ md5Thread.IsAlive || ripemd160Thread.IsAlive || sha1Thread.IsAlive || sha256Thread.IsAlive ||
+ sha384Thread.IsAlive || sha512Thread.IsAlive || spamsumThread.IsAlive) { }
- if(enabled.HasFlag(EnableChecksum.SpamSum)) adlerThread = new Thread(UpdateHash);
- if(enabled.HasFlag(EnableChecksum.SpamSum)) crc16Thread = new Thread(UpdateHash);
- if(enabled.HasFlag(EnableChecksum.SpamSum)) crc32Thread = new Thread(UpdateHash);
- if(enabled.HasFlag(EnableChecksum.SpamSum)) crc64Thread = new Thread(UpdateHash);
- if(enabled.HasFlag(EnableChecksum.SpamSum)) md5Thread = new Thread(UpdateHash);
+ if(enabled.HasFlag(EnableChecksum.SpamSum)) adlerThread = new Thread(UpdateHash);
+ if(enabled.HasFlag(EnableChecksum.SpamSum)) crc16Thread = new Thread(UpdateHash);
+ if(enabled.HasFlag(EnableChecksum.SpamSum)) crc32Thread = new Thread(UpdateHash);
+ if(enabled.HasFlag(EnableChecksum.SpamSum)) crc64Thread = new Thread(UpdateHash);
+ if(enabled.HasFlag(EnableChecksum.SpamSum)) md5Thread = new Thread(UpdateHash);
if(enabled.HasFlag(EnableChecksum.SpamSum)) ripemd160Thread = new Thread(UpdateHash);
- if(enabled.HasFlag(EnableChecksum.SpamSum)) sha1Thread = new Thread(UpdateHash);
- if(enabled.HasFlag(EnableChecksum.SpamSum)) sha256Thread = new Thread(UpdateHash);
- if(enabled.HasFlag(EnableChecksum.SpamSum)) sha384Thread = new Thread(UpdateHash);
- if(enabled.HasFlag(EnableChecksum.SpamSum)) sha512Thread = new Thread(UpdateHash);
- if(enabled.HasFlag(EnableChecksum.SpamSum)) spamsumThread = new Thread(UpdateHash);
+ if(enabled.HasFlag(EnableChecksum.SpamSum)) sha1Thread = new Thread(UpdateHash);
+ if(enabled.HasFlag(EnableChecksum.SpamSum)) sha256Thread = new Thread(UpdateHash);
+ if(enabled.HasFlag(EnableChecksum.SpamSum)) sha384Thread = new Thread(UpdateHash);
+ if(enabled.HasFlag(EnableChecksum.SpamSum)) sha512Thread = new Thread(UpdateHash);
+ if(enabled.HasFlag(EnableChecksum.SpamSum)) spamsumThread = new Thread(UpdateHash);
}
public List End()
@@ -360,147 +339,114 @@ namespace DiscImageChef.Core
internal static List GetChecksums(byte[] data, EnableChecksum enabled = EnableChecksum.All)
{
- IChecksum adler32CtxData = null;
- IChecksum crc16CtxData = null;
- IChecksum crc32CtxData = null;
- IChecksum crc64CtxData = null;
- IChecksum md5CtxData = null;
+ IChecksum adler32CtxData = null;
+ IChecksum crc16CtxData = null;
+ IChecksum crc32CtxData = null;
+ IChecksum crc64CtxData = null;
+ IChecksum md5CtxData = null;
IChecksum ripemd160CtxData = null;
- IChecksum sha1CtxData = null;
- IChecksum sha256CtxData = null;
- IChecksum sha384CtxData = null;
- IChecksum sha512CtxData = null;
- IChecksum ssctxData = null;
+ IChecksum sha1CtxData = null;
+ IChecksum sha256CtxData = null;
+ IChecksum sha384CtxData = null;
+ IChecksum sha512CtxData = null;
+ IChecksum ssctxData = null;
- Thread adlerThreadData = new Thread(UpdateHash);
- Thread crc16ThreadData = new Thread(UpdateHash);
- Thread crc32ThreadData = new Thread(UpdateHash);
- Thread crc64ThreadData = new Thread(UpdateHash);
- Thread md5ThreadData = new Thread(UpdateHash);
+ Thread adlerThreadData = new Thread(UpdateHash);
+ Thread crc16ThreadData = new Thread(UpdateHash);
+ Thread crc32ThreadData = new Thread(UpdateHash);
+ Thread crc64ThreadData = new Thread(UpdateHash);
+ Thread md5ThreadData = new Thread(UpdateHash);
Thread ripemd160ThreadData = new Thread(UpdateHash);
- Thread sha1ThreadData = new Thread(UpdateHash);
- Thread sha256ThreadData = new Thread(UpdateHash);
- Thread sha384ThreadData = new Thread(UpdateHash);
- Thread sha512ThreadData = new Thread(UpdateHash);
- Thread spamsumThreadData = new Thread(UpdateHash);
+ Thread sha1ThreadData = new Thread(UpdateHash);
+ Thread sha256ThreadData = new Thread(UpdateHash);
+ Thread sha384ThreadData = new Thread(UpdateHash);
+ Thread sha512ThreadData = new Thread(UpdateHash);
+ Thread spamsumThreadData = new Thread(UpdateHash);
if(enabled.HasFlag(EnableChecksum.SpamSum))
{
- adler32CtxData = new Adler32Context();
- HashPacket adlerPktData = new HashPacket();
- adler32CtxData.Init();
- adlerPktData.Context = adler32CtxData;
- adlerPktData.Data = data;
+ adler32CtxData = new Adler32Context();
+ HashPacket adlerPktData = new HashPacket {Context = adler32CtxData, Data = data};
adlerThreadData.Start(adlerPktData);
}
if(enabled.HasFlag(EnableChecksum.SpamSum))
{
- HashPacket crc16PktData = new HashPacket();
- crc16CtxData = new Crc16Context();
- crc16CtxData.Init();
- crc16PktData.Context = crc16CtxData;
- crc16PktData.Data = data;
+ crc16CtxData = new Crc16Context();
+ HashPacket crc16PktData = new HashPacket {Context = crc16CtxData, Data = data};
crc16ThreadData.Start(crc16PktData);
}
if(enabled.HasFlag(EnableChecksum.SpamSum))
{
- HashPacket crc32PktData = new HashPacket();
- crc32CtxData = new Crc32Context();
- crc32CtxData.Init();
- crc32PktData.Context = crc32CtxData;
- crc32PktData.Data = data;
+ crc32CtxData = new Crc32Context();
+ HashPacket crc32PktData = new HashPacket {Context = crc32CtxData, Data = data};
crc32ThreadData.Start(crc32PktData);
}
if(enabled.HasFlag(EnableChecksum.SpamSum))
{
- HashPacket crc64PktData = new HashPacket();
- crc64CtxData = new Crc64Context();
- crc64CtxData.Init();
- crc64PktData.Context = crc64CtxData;
- crc64PktData.Data = data;
+ crc64CtxData = new Crc64Context();
+ HashPacket crc64PktData = new HashPacket {Context = crc64CtxData, Data = data};
crc64ThreadData.Start(crc64PktData);
}
if(enabled.HasFlag(EnableChecksum.SpamSum))
{
- HashPacket md5PktData = new HashPacket();
- md5CtxData = new Md5Context();
- md5CtxData.Init();
- md5PktData.Context = md5CtxData;
- md5PktData.Data = data;
+ md5CtxData = new Md5Context();
+ HashPacket md5PktData = new HashPacket {Context = md5CtxData, Data = data};
md5ThreadData.Start(md5PktData);
}
if(enabled.HasFlag(EnableChecksum.SpamSum))
{
- HashPacket ripemd160PktData = new HashPacket();
- ripemd160CtxData = new Ripemd160Context();
- ripemd160CtxData.Init();
- ripemd160PktData.Context = ripemd160CtxData;
- ripemd160PktData.Data = data;
+ ripemd160CtxData = new Ripemd160Context();
+ HashPacket ripemd160PktData = new HashPacket {Context = ripemd160CtxData, Data = data};
ripemd160ThreadData.Start(ripemd160PktData);
}
if(enabled.HasFlag(EnableChecksum.SpamSum))
{
- HashPacket sha1PktData = new HashPacket();
- sha1CtxData = new Sha1Context();
- sha1CtxData.Init();
- sha1PktData.Context = sha1CtxData;
- sha1PktData.Data = data;
+ sha1CtxData = new Sha1Context();
+ HashPacket sha1PktData = new HashPacket {Context = sha1CtxData, Data = data};
sha1ThreadData.Start(sha1PktData);
}
if(enabled.HasFlag(EnableChecksum.SpamSum))
{
- HashPacket sha256PktData = new HashPacket();
- sha256CtxData = new Sha256Context();
- sha256CtxData.Init();
- sha256PktData.Context = sha256CtxData;
- sha256PktData.Data = data;
+ sha256CtxData = new Sha256Context();
+ HashPacket sha256PktData = new HashPacket {Context = sha256CtxData, Data = data};
sha256ThreadData.Start(sha256PktData);
}
if(enabled.HasFlag(EnableChecksum.SpamSum))
{
- HashPacket sha384PktData = new HashPacket();
- sha384CtxData = new Sha384Context();
- sha384CtxData.Init();
- sha384PktData.Context = sha384CtxData;
- sha384PktData.Data = data;
+ sha384CtxData = new Sha384Context();
+ HashPacket sha384PktData = new HashPacket {Context = sha384CtxData, Data = data};
sha384ThreadData.Start(sha384PktData);
}
if(enabled.HasFlag(EnableChecksum.SpamSum))
{
- HashPacket sha512PktData = new HashPacket();
- sha512CtxData = new Sha512Context();
- sha512CtxData.Init();
- sha512PktData.Context = sha512CtxData;
- sha512PktData.Data = data;
+ sha512CtxData = new Sha512Context();
+ HashPacket sha512PktData = new HashPacket {Context = sha512CtxData, Data = data};
sha512ThreadData.Start(sha512PktData);
}
if(enabled.HasFlag(EnableChecksum.SpamSum))
{
- HashPacket spamsumPktData = new HashPacket();
- ssctxData = new SpamSumContext();
- ssctxData.Init();
- spamsumPktData.Context = ssctxData;
- spamsumPktData.Data = data;
+ ssctxData = new SpamSumContext();
+ HashPacket spamsumPktData = new HashPacket {Context = ssctxData, Data = data};
spamsumThreadData.Start(spamsumPktData);
}
- while(adlerThreadData.IsAlive || crc16ThreadData.IsAlive || crc32ThreadData.IsAlive ||
- crc64ThreadData.IsAlive || md5ThreadData.IsAlive || ripemd160ThreadData.IsAlive ||
- sha1ThreadData.IsAlive || sha256ThreadData.IsAlive || sha384ThreadData.IsAlive ||
+ while(adlerThreadData.IsAlive || crc16ThreadData.IsAlive || crc32ThreadData.IsAlive ||
+ crc64ThreadData.IsAlive || md5ThreadData.IsAlive || ripemd160ThreadData.IsAlive ||
+ sha1ThreadData.IsAlive || sha256ThreadData.IsAlive || sha384ThreadData.IsAlive ||
sha512ThreadData.IsAlive || spamsumThreadData.IsAlive) { }
List dataChecksums = new List();
- ChecksumType chk;
+ ChecksumType chk;
if(enabled.HasFlag(EnableChecksum.Adler32))
{
@@ -574,7 +520,7 @@ namespace DiscImageChef.Core
struct HashPacket
{
public IChecksum Context;
- public byte[] Data;
+ public byte[] Data;
}
static void UpdateHash(object packet)
diff --git a/DiscImageChef.DiscImages/CHD.cs b/DiscImageChef.DiscImages/CHD.cs
index 28b74516..a13ba985 100644
--- a/DiscImageChef.DiscImages/CHD.cs
+++ b/DiscImageChef.DiscImages/CHD.cs
@@ -1318,7 +1318,6 @@ namespace DiscImageChef.DiscImages
if(mapVersion >= 3)
{
Sha1Context sha1Ctx = new Sha1Context();
- sha1Ctx.Init();
for(uint i = 0; i < totalHunks; i++) sha1Ctx.Update(GetHunk(i));
calculated = sha1Ctx.Final();
@@ -1326,7 +1325,6 @@ namespace DiscImageChef.DiscImages
else
{
Md5Context md5Ctx = new Md5Context();
- md5Ctx.Init();
for(uint i = 0; i < totalHunks; i++) md5Ctx.Update(GetHunk(i));
calculated = md5Ctx.Final();
@@ -1713,7 +1711,7 @@ namespace DiscImageChef.DiscImages
if(!sectorCache.TryGetValue(sectorAddress, out byte[] sector))
{
- track = GetTrack(sectorAddress);
+ track = GetTrack(sectorAddress);
uint sectorSize = (uint)track.TrackRawBytesPerSector;
ulong hunkNo = sectorAddress / sectorsPerHunk;
diff --git a/DiscImageChef.DiscImages/DiscImageChef.cs b/DiscImageChef.DiscImages/DiscImageChef.cs
index 9e1a008a..ce15f59e 100644
--- a/DiscImageChef.DiscImages/DiscImageChef.cs
+++ b/DiscImageChef.DiscImages/DiscImageChef.cs
@@ -1770,7 +1770,6 @@ namespace DiscImageChef.DiscImages
Marshal.FreeHGlobal(structurePointer);
crcVerify = new Crc64Context();
- crcVerify.Init();
readBytes = 0;
DicConsole.DebugWriteLine("DiscImageChef format plugin",
@@ -1807,7 +1806,6 @@ namespace DiscImageChef.DiscImages
Marshal.FreeHGlobal(structurePointer);
crcVerify = new Crc64Context();
- crcVerify.Init();
readBytes = 0;
DicConsole.DebugWriteLine("DiscImageChef format plugin",
@@ -2524,29 +2522,13 @@ namespace DiscImageChef.DiscImages
imageStream.WriteByte(0);
}
- if(doMd5)
- {
- md5Provider = new Md5Context();
- md5Provider.Init();
- }
+ if(doMd5) md5Provider = new Md5Context();
- if(doSha1)
- {
- sha1Provider = new Sha1Context();
- sha1Provider.Init();
- }
+ if(doSha1) sha1Provider = new Sha1Context();
- if(doSha256)
- {
- sha256Provider = new Sha256Context();
- sha256Provider.Init();
- }
+ if(doSha256) sha256Provider = new Sha256Context();
- if(doSpamsum)
- {
- spamsumProvider = new SpamSumContext();
- spamsumProvider.Init();
- }
+ if(doSpamsum) spamsumProvider = new SpamSumContext();
}
DicConsole.DebugWriteLine("DiscImageChef format plugin", "In memory DDT?: {0}", inMemoryDdt);
@@ -2689,7 +2671,6 @@ namespace DiscImageChef.DiscImages
currentBlockHeader.crc64 = BitConverter.ToUInt64(crc64.Final(), 0);
Crc64Context cmpCrc64Context = new Crc64Context();
- cmpCrc64Context.Init();
byte[] lzmaProperties = new byte[0];
@@ -2777,7 +2758,6 @@ namespace DiscImageChef.DiscImages
flakeWriter = new FlakeWriter("", blockStream, flakeWriterSettings) {DoSeekTable = false};
else lzmaBlockStream = new LzmaStream(lzmaEncoderProperties, false, blockStream);
crc64 = new Crc64Context();
- crc64.Init();
}
ulong ddtEntry = (ulong)((imageStream.Position << shift) + currentBlockOffset);
@@ -3111,7 +3091,6 @@ namespace DiscImageChef.DiscImages
currentBlockHeader.crc64 = BitConverter.ToUInt64(crc64.Final(), 0);
Crc64Context cmpCrc64Context = new Crc64Context();
- cmpCrc64Context.Init();
byte[] lzmaProperties = new byte[0];
@@ -3227,7 +3206,6 @@ namespace DiscImageChef.DiscImages
{
tagData = blockStream.ToArray();
Crc64Context crc64Ctx = new Crc64Context();
- crc64Ctx.Init();
crc64Ctx.Update(lzmaProperties);
crc64Ctx.Update(tagData);
tagCrc = crc64Ctx.Final();
@@ -3569,7 +3547,6 @@ namespace DiscImageChef.DiscImages
blockStream = new MemoryStream();
lzmaBlockStream = new LzmaStream(lzmaEncoderProperties, false, blockStream);
crc64 = new Crc64Context();
- crc64.Init();
for(ulong i = 0; i < (ulong)userDataDdt.LongLength; i++)
{
byte[] ddtEntry = BitConverter.GetBytes(userDataDdt[i]);
@@ -3581,7 +3558,6 @@ namespace DiscImageChef.DiscImages
lzmaBlockStream.Close();
ddtHeader.cmpLength = (uint)blockStream.Length + LZMA_PROPERTIES_LENGTH;
Crc64Context cmpCrc64Context = new Crc64Context();
- cmpCrc64Context.Init();
cmpCrc64Context.Update(lzmaProperties);
cmpCrc64Context.Update(blockStream.ToArray());
ddtHeader.cmpCrc64 = BitConverter.ToUInt64(cmpCrc64Context.Final(), 0);
@@ -3629,15 +3605,15 @@ namespace DiscImageChef.DiscImages
crc64 = BitConverter.ToUInt64(blockCrc, 0),
sectorSize = 16
};
-
+
byte[] lzmaProperties = null;
-
+
if(nocompress)
{
prefixBlock.compression = CompressionType.None;
- prefixBlock.cmpCrc64 = prefixBlock.crc64;
- prefixBlock.cmpLength = prefixBlock.length;
- blockStream = new MemoryStream(sectorPrefix);
+ prefixBlock.cmpCrc64 = prefixBlock.crc64;
+ prefixBlock.cmpLength = prefixBlock.length;
+ blockStream = new MemoryStream(sectorPrefix);
}
else
{
@@ -3664,7 +3640,6 @@ namespace DiscImageChef.DiscImages
if(prefixBlock.compression == CompressionType.Lzma)
imageStream.Write(lzmaProperties, 0, lzmaProperties.Length);
imageStream.Write(blockStream.ToArray(), 0, (int)blockStream.Length);
-
index.RemoveAll(t => t.blockType == BlockType.DataBlock &&
t.dataType == DataType.CdSectorPrefix);
@@ -3762,7 +3737,7 @@ namespace DiscImageChef.DiscImages
subchannelBlock.compression = CompressionType.None;
subchannelBlock.cmpCrc64 = subchannelBlock.crc64;
subchannelBlock.cmpLength = subchannelBlock.length;
- blockStream = new MemoryStream(sectorSubchannel);
+ blockStream = new MemoryStream(sectorSubchannel);
}
else
{
@@ -3928,7 +3903,7 @@ namespace DiscImageChef.DiscImages
}
byte[] lzmaProperties = null;
-
+
if(nocompress)
{
subchannelBlock.compression = CompressionType.None;
diff --git a/DiscImageChef.DiscImages/UDIF.cs b/DiscImageChef.DiscImages/UDIF.cs
index 33d1eada..b66372a8 100644
--- a/DiscImageChef.DiscImages/UDIF.cs
+++ b/DiscImageChef.DiscImages/UDIF.cs
@@ -774,9 +774,7 @@ namespace DiscImageChef.DiscImages
currentChunk = new BlockChunk();
currentSector = 0;
dataForkChecksum = new Crc32Context();
- dataForkChecksum.Init();
- masterChecksum = new Crc32Context();
- masterChecksum.Init();
+ masterChecksum = new Crc32Context();
IsWriting = true;
ErrorMessage = null;
diff --git a/DiscImageChef.DiscImages/VHD.cs b/DiscImageChef.DiscImages/VHD.cs
index 2689f338..14382f36 100644
--- a/DiscImageChef.DiscImages/VHD.cs
+++ b/DiscImageChef.DiscImages/VHD.cs
@@ -370,7 +370,6 @@ namespace DiscImageChef.DiscImages
thisDateTime = thisDateTime.AddSeconds(thisFooter.Timestamp);
Sha1Context sha1Ctx = new Sha1Context();
- sha1Ctx.Init();
sha1Ctx.Update(thisFooter.Reserved);
DicConsole.DebugWriteLine("VirtualPC plugin", "footer.cookie = 0x{0:X8}", thisFooter.Cookie);
@@ -590,7 +589,6 @@ namespace DiscImageChef.DiscImages
parentDateTime = parentDateTime.AddSeconds(thisDynamic.ParentTimestamp);
sha1Ctx = new Sha1Context();
- sha1Ctx.Init();
sha1Ctx.Update(thisDynamic.Reserved2);
DicConsole.DebugWriteLine("VirtualPC plugin", "dynamic.cookie = 0x{0:X8}", thisDynamic.Cookie);
diff --git a/DiscImageChef.Filesystems/AmigaDOS.cs b/DiscImageChef.Filesystems/AmigaDOS.cs
index f7e985a2..4f62411c 100644
--- a/DiscImageChef.Filesystems/AmigaDOS.cs
+++ b/DiscImageChef.Filesystems/AmigaDOS.cs
@@ -44,16 +44,16 @@ namespace DiscImageChef.Filesystems
{
public class AmigaDOSPlugin : IFilesystem
{
- const uint FFS_MASK = 0x444F5300;
+ const uint FFS_MASK = 0x444F5300;
const uint MUFS_MASK = 0x6D754600;
- const uint TYPE_HEADER = 2;
+ const uint TYPE_HEADER = 2;
const uint SUBTYPE_ROOT = 1;
public FileSystemType XmlFsType { get; private set; }
- public string Name => "Amiga DOS filesystem";
- public Guid Id => new Guid("3c882400-208c-427d-a086-9119852a1bc7");
- public Encoding Encoding { get; private set; }
+ public string Name => "Amiga DOS filesystem";
+ public Guid Id => new Guid("3c882400-208c-427d-a086-9119852a1bc7");
+ public Encoding Encoding { get; private set; }
public bool Identify(IMediaImage imagePlugin, Partition partition)
{
@@ -67,15 +67,15 @@ namespace DiscImageChef.Filesystems
// However while you can set a block size different from the sector size on formatting, the bootblock block
// size for floppies is the sector size, and for RDB is usually is the hard disk sector size,
// so this is not entirely wrong...
- byte[] sector = imagePlugin.ReadSectors(0 + partition.Start, 2);
- BootBlock bblk = BigEndianMarshal.ByteArrayToStructureBigEndian(sector);
+ byte[] sector = imagePlugin.ReadSectors(0 + partition.Start, 2);
+ BootBlock bblk = BigEndianMarshal.ByteArrayToStructureBigEndian(sector);
// AROS boot floppies...
- if(sector.Length >= 512 && sector[510] == 0x55 && sector[511] == 0xAA &&
+ if(sector.Length >= 512 && sector[510] == 0x55 && sector[511] == 0xAA &&
(bblk.diskType & FFS_MASK) != FFS_MASK && (bblk.diskType & MUFS_MASK) != MUFS_MASK)
{
sector = imagePlugin.ReadSectors(1 + partition.Start, 2);
- bblk = BigEndianMarshal.ByteArrayToStructureBigEndian(sector);
+ bblk = BigEndianMarshal.ByteArrayToStructureBigEndian(sector);
}
// Not FFS or MuFS?
@@ -86,7 +86,7 @@ namespace DiscImageChef.Filesystems
uint bsum = AmigaBootChecksum(sector);
DicConsole.DebugWriteLine("AmigaDOS plugin", "bblk.checksum = 0x{0:X8}", bblk.checksum);
- DicConsole.DebugWriteLine("AmigaDOS plugin", "bsum = 0x{0:X8}", bsum);
+ DicConsole.DebugWriteLine("AmigaDOS plugin", "bsum = 0x{0:X8}", bsum);
ulong bRootPtr = 0;
@@ -99,10 +99,10 @@ namespace DiscImageChef.Filesystems
ulong[] rootPtrs =
{
- bRootPtr + partition.Start, (partition.End - partition.Start + 1) / 2 + partition.Start - 2,
- (partition.End - partition.Start + 1) / 2 + partition.Start - 1,
- (partition.End - partition.Start + 1) / 2 + partition.Start,
- (partition.End - partition.Start + 1) / 2 + partition.Start + 4
+ bRootPtr + partition.Start, (partition.End - partition.Start + 1) / 2 + partition.Start - 2,
+ (partition.End - partition.Start + 1) / 2 + partition.Start - 1,
+ (partition.End - partition.Start + 1) / 2 + partition.Start,
+ (partition.End - partition.Start + 1) / 2 + partition.Start + 4
};
RootBlock rblk = new RootBlock();
@@ -122,10 +122,10 @@ namespace DiscImageChef.Filesystems
DicConsole.DebugWriteLine("AmigaDOS plugin", "rblk.hashTableSize = {0}", rblk.hashTableSize);
- uint blockSize = (rblk.hashTableSize + 56) * 4;
- uint sectorsPerBlock = (uint)(blockSize / sector.Length);
+ uint blockSize = (rblk.hashTableSize + 56) * 4;
+ uint sectorsPerBlock = (uint)(blockSize / sector.Length);
- DicConsole.DebugWriteLine("AmigaDOS plugin", "blockSize = {0}", blockSize);
+ DicConsole.DebugWriteLine("AmigaDOS plugin", "blockSize = {0}", blockSize);
DicConsole.DebugWriteLine("AmigaDOS plugin", "sectorsPerBlock = {0}", sectorsPerBlock);
if(blockSize % sector.Length > 0) sectorsPerBlock++;
@@ -136,11 +136,11 @@ namespace DiscImageChef.Filesystems
// Clear checksum on sector
rblk.checksum = BigEndianBitConverter.ToUInt32(sector, 20);
- sector[20] = sector[21] = sector[22] = sector[23] = 0;
- uint rsum = AmigaChecksum(sector);
+ sector[20] = sector[21] = sector[22] = sector[23] = 0;
+ uint rsum = AmigaChecksum(sector);
DicConsole.DebugWriteLine("AmigaDOS plugin", "rblk.checksum = 0x{0:X8}", rblk.checksum);
- DicConsole.DebugWriteLine("AmigaDOS plugin", "rsum = 0x{0:X8}", rsum);
+ DicConsole.DebugWriteLine("AmigaDOS plugin", "rsum = 0x{0:X8}", rsum);
rblk.sec_type = BigEndianBitConverter.ToUInt32(sector, sector.Length - 4);
DicConsole.DebugWriteLine("AmigaDOS plugin", "rblk.sec_type = {0}", rblk.sec_type);
@@ -152,21 +152,21 @@ namespace DiscImageChef.Filesystems
}
public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information,
- Encoding encoding)
+ Encoding encoding)
{
- Encoding = encoding ?? Encoding.GetEncoding("iso-8859-1");
- StringBuilder sbInformation = new StringBuilder();
- XmlFsType = new FileSystemType();
- information = null;
+ Encoding = encoding ?? Encoding.GetEncoding("iso-8859-1");
+ StringBuilder sbInformation = new StringBuilder();
+ XmlFsType = new FileSystemType();
+ information = null;
BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian;
byte[] bootBlockSectors = imagePlugin.ReadSectors(0 + partition.Start, 2);
BootBlock bootBlk = BigEndianMarshal.ByteArrayToStructureBigEndian(bootBlockSectors);
- bootBlk.bootCode = new byte[bootBlockSectors.Length - 12];
+ bootBlk.bootCode = new byte[bootBlockSectors.Length - 12];
Array.Copy(bootBlockSectors, 12, bootBlk.bootCode, 0, bootBlk.bootCode.Length);
bootBlockSectors[4] = bootBlockSectors[5] = bootBlockSectors[6] = bootBlockSectors[7] = 0;
- uint bsum = AmigaBootChecksum(bootBlockSectors);
+ uint bsum = AmigaBootChecksum(bootBlockSectors);
ulong bRootPtr = 0;
@@ -179,14 +179,14 @@ namespace DiscImageChef.Filesystems
ulong[] rootPtrs =
{
- bRootPtr + partition.Start, (partition.End - partition.Start + 1) / 2 + partition.Start - 2,
- (partition.End - partition.Start + 1) / 2 + partition.Start - 1,
- (partition.End - partition.Start + 1) / 2 + partition.Start,
- (partition.End - partition.Start + 1) / 2 + partition.Start + 4
+ bRootPtr + partition.Start, (partition.End - partition.Start + 1) / 2 + partition.Start - 2,
+ (partition.End - partition.Start + 1) / 2 + partition.Start - 1,
+ (partition.End - partition.Start + 1) / 2 + partition.Start,
+ (partition.End - partition.Start + 1) / 2 + partition.Start + 4
};
- RootBlock rootBlk = new RootBlock();
- byte[] rootBlockSector = null;
+ RootBlock rootBlk = new RootBlock();
+ byte[] rootBlockSector = null;
bool rootFound = false;
uint blockSize = 0;
@@ -206,10 +206,10 @@ namespace DiscImageChef.Filesystems
DicConsole.DebugWriteLine("AmigaDOS plugin", "rootBlk.hashTableSize = {0}", rootBlk.hashTableSize);
- blockSize = (rootBlk.hashTableSize + 56) * 4;
- uint sectorsPerBlock = (uint)(blockSize / rootBlockSector.Length);
+ blockSize = (rootBlk.hashTableSize + 56) * 4;
+ uint sectorsPerBlock = (uint)(blockSize / rootBlockSector.Length);
- DicConsole.DebugWriteLine("AmigaDOS plugin", "blockSize = {0}", blockSize);
+ DicConsole.DebugWriteLine("AmigaDOS plugin", "blockSize = {0}", blockSize);
DicConsole.DebugWriteLine("AmigaDOS plugin", "sectorsPerBlock = {0}", sectorsPerBlock);
if(blockSize % rootBlockSector.Length > 0) sectorsPerBlock++;
@@ -219,12 +219,12 @@ namespace DiscImageChef.Filesystems
rootBlockSector = imagePlugin.ReadSectors(rootPtr, sectorsPerBlock);
// Clear checksum on sector
- rootBlk.checksum = BigEndianBitConverter.ToUInt32(rootBlockSector, 20);
+ rootBlk.checksum = BigEndianBitConverter.ToUInt32(rootBlockSector, 20);
rootBlockSector[20] = rootBlockSector[21] = rootBlockSector[22] = rootBlockSector[23] = 0;
- uint rsum = AmigaChecksum(rootBlockSector);
+ uint rsum = AmigaChecksum(rootBlockSector);
DicConsole.DebugWriteLine("AmigaDOS plugin", "rootBlk.checksum = 0x{0:X8}", rootBlk.checksum);
- DicConsole.DebugWriteLine("AmigaDOS plugin", "rsum = 0x{0:X8}", rsum);
+ DicConsole.DebugWriteLine("AmigaDOS plugin", "rsum = 0x{0:X8}", rsum);
rootBlk.sec_type = BigEndianBitConverter.ToUInt32(rootBlockSector, rootBlockSector.Length - 4);
DicConsole.DebugWriteLine("AmigaDOS plugin", "rootBlk.sec_type = {0}", rootBlk.sec_type);
@@ -232,7 +232,7 @@ namespace DiscImageChef.Filesystems
if(rootBlk.sec_type != SUBTYPE_ROOT || rootBlk.checksum != rsum) continue;
rootBlockSector = imagePlugin.ReadSectors(rootPtr, sectorsPerBlock);
- rootFound = true;
+ rootFound = true;
break;
}
@@ -287,7 +287,6 @@ namespace DiscImageChef.Filesystems
if(bootBlk.checksum == bsum)
{
Sha1Context sha1Ctx = new Sha1Context();
- sha1Ctx.Init();
sha1Ctx.Update(bootBlk.bootCode);
sbInformation.AppendLine("Volume is bootable");
sbInformation.AppendFormat("Boot code SHA1 is {0}", sha1Ctx.End()).AppendLine();
@@ -304,7 +303,7 @@ namespace DiscImageChef.Filesystems
long blocks = (long)((partition.End - partition.Start + 1) * imagePlugin.Info.SectorSize / blockSize);
sbInformation.AppendFormat("Volume block size is {0} bytes", blockSize).AppendLine();
- sbInformation.AppendFormat("Volume has {0} blocks", blocks).AppendLine();
+ sbInformation.AppendFormat("Volume has {0} blocks", blocks).AppendLine();
sbInformation.AppendFormat("Volume created on {0}",
DateHandlers.AmigaToDateTime(rootBlk.cDays, rootBlk.cMins, rootBlk.cTicks))
.AppendLine();
@@ -317,15 +316,17 @@ namespace DiscImageChef.Filesystems
sbInformation.AppendFormat("Root block checksum is 0x{0:X8}", rootBlk.checksum).AppendLine();
information = sbInformation.ToString();
- XmlFsType.CreationDate = DateHandlers.AmigaToDateTime(rootBlk.cDays, rootBlk.cMins, rootBlk.cTicks);
+ XmlFsType.CreationDate =
+ DateHandlers.AmigaToDateTime(rootBlk.cDays, rootBlk.cMins, rootBlk.cTicks);
XmlFsType.CreationDateSpecified = true;
- XmlFsType.ModificationDate = DateHandlers.AmigaToDateTime(rootBlk.vDays, rootBlk.vMins, rootBlk.vTicks);
+ XmlFsType.ModificationDate =
+ DateHandlers.AmigaToDateTime(rootBlk.vDays, rootBlk.vMins, rootBlk.vTicks);
XmlFsType.ModificationDateSpecified = true;
- XmlFsType.Dirty = rootBlk.bitmapFlag != 0xFFFFFFFF;
- XmlFsType.Clusters = blocks;
- XmlFsType.ClusterSize = (int)blockSize;
- XmlFsType.VolumeName = diskName;
- XmlFsType.Bootable = bsum == bootBlk.checksum;
+ XmlFsType.Dirty = rootBlk.bitmapFlag != 0xFFFFFFFF;
+ XmlFsType.Clusters = blocks;
+ XmlFsType.ClusterSize = (int)blockSize;
+ XmlFsType.VolumeName = diskName;
+ XmlFsType.Bootable = bsum == bootBlk.checksum;
// Useful as a serial
XmlFsType.VolumeSerial = $"{rootBlk.checksum:X8}";
}
@@ -333,10 +334,10 @@ namespace DiscImageChef.Filesystems
static RootBlock MarshalRootBlock(byte[] block)
{
byte[] tmp = new byte[228];
- Array.Copy(block, 0, tmp, 0, 24);
+ Array.Copy(block, 0, tmp, 0, 24);
Array.Copy(block, block.Length - 200, tmp, 28, 200);
- RootBlock root = BigEndianMarshal.ByteArrayToStructureBigEndian(tmp);
- root.hashTable = new uint[(block.Length - 224) / 4];
+ RootBlock root = BigEndianMarshal.ByteArrayToStructureBigEndian(tmp);
+ root.hashTable = new uint[(block.Length - 224) / 4];
BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian;
for(int i = 0; i < root.hashTable.Length; i++)
root.hashTable[i] = BigEndianBitConverter.ToUInt32(block, 24 + i * 4);
@@ -390,7 +391,8 @@ namespace DiscImageChef.Filesystems
///
/// Offset 0x0C, Boot code, til completion. Size is intentionally incorrect to allow marshaling to work.
///
- [MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)] public byte[] bootCode;
+ [MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)]
+ public byte[] bootCode;
}
[StructLayout(LayoutKind.Sequential, Pack = 1)]
@@ -424,7 +426,8 @@ namespace DiscImageChef.Filesystems
/// Offset 0x18, Hashtable, size = (block size / 4) - 56 or size = hashTableSize.
/// Size intentionally bad to allow marshalling to work.
///
- [MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)] public uint[] hashTable;
+ [MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)]
+ public uint[] hashTable;
///
/// Offset 0x18+hashTableSize*4+0, bitmap flag, 0xFFFFFFFF if valid
///
@@ -432,7 +435,8 @@ namespace DiscImageChef.Filesystems
///
/// Offset 0x18+hashTableSize*4+4, bitmap pages, 25 entries
///
- [MarshalAs(UnmanagedType.ByValArray, SizeConst = 25)] public uint[] bitmapPages;
+ [MarshalAs(UnmanagedType.ByValArray, SizeConst = 25)]
+ public uint[] bitmapPages;
///
/// Offset 0x18+hashTableSize*4+104, pointer to bitmap extension block
///
@@ -452,7 +456,8 @@ namespace DiscImageChef.Filesystems
///
/// Offset 0x18+hashTableSize*4+120, disk name, pascal string, 31 bytes
///
- [MarshalAs(UnmanagedType.ByValArray, SizeConst = 31)] public byte[] diskName;
+ [MarshalAs(UnmanagedType.ByValArray, SizeConst = 31)]
+ public byte[] diskName;
///
/// Offset 0x18+hashTableSize*4+151, unused
///
diff --git a/DiscImageChef.Filesystems/FAT.cs b/DiscImageChef.Filesystems/FAT.cs
index 90bae760..82278c91 100644
--- a/DiscImageChef.Filesystems/FAT.cs
+++ b/DiscImageChef.Filesystems/FAT.cs
@@ -705,7 +705,6 @@ namespace DiscImageChef.Filesystems
string extraInfo = null;
string bootChk = null;
Sha1Context sha1Ctx = new Sha1Context();
- sha1Ctx.Init();
// This is needed because for FAT16, GEMDOS increases bytes per sector count instead of using big_sectors field.
uint sectorsPerRealSector;
@@ -1527,7 +1526,6 @@ namespace DiscImageChef.Filesystems
byte[] bootCode = new byte[512 - sigSize - bpbSector[1] - 2];
Array.Copy(bpbSector, bpbSector[1] + 2, bootCode, 0, bootCode.Length);
sha1Ctx = new Sha1Context();
- sha1Ctx.Init();
sha1Ctx.Update(bootCode);
bootChk = sha1Ctx.End();
}
@@ -1539,7 +1537,6 @@ namespace DiscImageChef.Filesystems
Array.Copy(bpbSector, BitConverter.ToUInt16(bpbSector, 1) + 3, bootCode, 0,
bootCode.Length);
sha1Ctx = new Sha1Context();
- sha1Ctx.Init();
sha1Ctx.Update(bootCode);
bootChk = sha1Ctx.End();
}
diff --git a/DiscImageChef.Filesystems/HPFS.cs b/DiscImageChef.Filesystems/HPFS.cs
index 4e473aa8..d7c1fc6f 100644
--- a/DiscImageChef.Filesystems/HPFS.cs
+++ b/DiscImageChef.Filesystems/HPFS.cs
@@ -44,28 +44,26 @@ namespace DiscImageChef.Filesystems
public class HPFS : IFilesystem
{
public FileSystemType XmlFsType { get; private set; }
- public Encoding Encoding { get; private set; }
- public string Name => "OS/2 High Performance File System";
- public Guid Id => new Guid("33513B2C-f590-4acb-8bf2-0b1d5e19dec5");
+ public Encoding Encoding { get; private set; }
+ public string Name => "OS/2 High Performance File System";
+ public Guid Id => new Guid("33513B2C-f590-4acb-8bf2-0b1d5e19dec5");
public bool Identify(IMediaImage imagePlugin, Partition partition)
{
if(16 + partition.Start >= partition.End) return false;
- uint magic1, magic2;
-
byte[] hpfsSbSector =
imagePlugin.ReadSector(16 + partition.Start); // Seek to superblock, on logical sector 16
- magic1 = BitConverter.ToUInt32(hpfsSbSector, 0x000);
- magic2 = BitConverter.ToUInt32(hpfsSbSector, 0x004);
+ uint magic1 = BitConverter.ToUInt32(hpfsSbSector, 0x000);
+ uint magic2 = BitConverter.ToUInt32(hpfsSbSector, 0x004);
return magic1 == 0xF995E849 && magic2 == 0xFA53E9C5;
}
public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information,
- Encoding encoding)
+ Encoding encoding)
{
- Encoding = encoding ?? Encoding.GetEncoding("ibm850");
+ Encoding = encoding ?? Encoding.GetEncoding("ibm850");
information = "";
StringBuilder sb = new StringBuilder();
@@ -94,7 +92,8 @@ namespace DiscImageChef.Filesystems
Marshal.FreeHGlobal(spPtr);
if(StringHandlers.CToString(hpfsBpb.fs_type) != "HPFS " || hpfsSb.magic1 != 0xF995E849 ||
- hpfsSb.magic2 != 0xFA53E9C5 || hpfsSp.magic1 != 0xF9911849 || hpfsSp.magic2 != 0xFA5229C5)
+ hpfsSb.magic2 != 0xFA53E9C5 || hpfsSp.magic1 != 0xF9911849 ||
+ hpfsSp.magic2 != 0xFA5229C5)
{
sb.AppendLine("This may not be HPFS, following information may be not correct.");
sb.AppendFormat("File system type: \"{0}\" (Should be \"HPFS \")", hpfsBpb.fs_type).AppendLine();
@@ -104,7 +103,7 @@ namespace DiscImageChef.Filesystems
sb.AppendFormat("Spareblock magic2: 0x{0:X8} (Should be 0xFA5229C5)", hpfsSp.magic2).AppendLine();
}
- sb.AppendFormat("OEM name: {0}", StringHandlers.CToString(hpfsBpb.oem_name)).AppendLine();
+ sb.AppendFormat("OEM name: {0}", StringHandlers.CToString(hpfsBpb.oem_name)).AppendLine();
sb.AppendFormat("{0} bytes per sector", hpfsBpb.bps).AppendLine();
// sb.AppendFormat("{0} sectors per cluster", hpfs_bpb.spc).AppendLine();
// sb.AppendFormat("{0} reserved sectors", hpfs_bpb.rsectors).AppendLine();
@@ -115,85 +114,91 @@ namespace DiscImageChef.Filesystems
// sb.AppendFormat("{0} sectors per FAT", hpfs_bpb.spfat).AppendLine();
// sb.AppendFormat("{0} sectors per track", hpfs_bpb.sptrk).AppendLine();
// sb.AppendFormat("{0} heads", hpfs_bpb.heads).AppendLine();
- sb.AppendFormat("{0} sectors hidden before BPB", hpfsBpb.hsectors).AppendLine();
+ sb.AppendFormat("{0} sectors hidden before BPB", hpfsBpb.hsectors).AppendLine();
sb.AppendFormat("{0} sectors on volume ({1} bytes)", hpfsSb.sectors, hpfsSb.sectors * hpfsBpb.bps)
.AppendLine();
// sb.AppendFormat("{0} sectors on volume ({1} bytes)", hpfs_bpb.big_sectors, hpfs_bpb.big_sectors * hpfs_bpb.bps).AppendLine();
sb.AppendFormat("BIOS Drive Number: 0x{0:X2}", hpfsBpb.drive_no).AppendLine();
- sb.AppendFormat("NT Flags: 0x{0:X2}", hpfsBpb.nt_flags).AppendLine();
- sb.AppendFormat("Signature: 0x{0:X2}", hpfsBpb.signature).AppendLine();
- sb.AppendFormat("Serial number: 0x{0:X8}", hpfsBpb.serial_no).AppendLine();
- sb.AppendFormat("Volume label: {0}", StringHandlers.CToString(hpfsBpb.volume_label, Encoding)).AppendLine();
+ sb.AppendFormat("NT Flags: 0x{0:X2}", hpfsBpb.nt_flags).AppendLine();
+ sb.AppendFormat("Signature: 0x{0:X2}", hpfsBpb.signature).AppendLine();
+ sb.AppendFormat("Serial number: 0x{0:X8}", hpfsBpb.serial_no).AppendLine();
+ sb.AppendFormat("Volume label: {0}", StringHandlers.CToString(hpfsBpb.volume_label, Encoding))
+ .AppendLine();
// sb.AppendFormat("Filesystem type: \"{0}\"", hpfs_bpb.fs_type).AppendLine();
- DateTime lastChk = DateHandlers.UnixToDateTime(hpfsSb.last_chkdsk);
+ DateTime lastChk = DateHandlers.UnixToDateTime(hpfsSb.last_chkdsk);
DateTime lastOptim = DateHandlers.UnixToDateTime(hpfsSb.last_optim);
- sb.AppendFormat("HPFS version: {0}", hpfsSb.version).AppendLine();
- sb.AppendFormat("Functional version: {0}", hpfsSb.func_version).AppendLine();
- sb.AppendFormat("Sector of root directory FNode: {0}", hpfsSb.root_fnode).AppendLine();
- sb.AppendFormat("{0} sectors are marked bad", hpfsSb.badblocks).AppendLine();
- sb.AppendFormat("Sector of free space bitmaps: {0}", hpfsSb.bitmap_lsn).AppendLine();
- sb.AppendFormat("Sector of bad blocks list: {0}", hpfsSb.badblock_lsn).AppendLine();
+ sb.AppendFormat("HPFS version: {0}", hpfsSb.version)
+ .AppendLine();
+ sb.AppendFormat("Functional version: {0}", hpfsSb.func_version)
+ .AppendLine();
+ sb.AppendFormat("Sector of root directory FNode: {0}", hpfsSb.root_fnode)
+ .AppendLine();
+ sb.AppendFormat("{0} sectors are marked bad", hpfsSb.badblocks)
+ .AppendLine();
+ sb.AppendFormat("Sector of free space bitmaps: {0}", hpfsSb.bitmap_lsn)
+ .AppendLine();
+ sb.AppendFormat("Sector of bad blocks list: {0}", hpfsSb.badblock_lsn)
+ .AppendLine();
if(hpfsSb.last_chkdsk > 0) sb.AppendFormat("Date of last integrity check: {0}", lastChk).AppendLine();
else sb.AppendLine("Filesystem integrity has never been checked");
if(hpfsSb.last_optim > 0) sb.AppendFormat("Date of last optimization {0}", lastOptim).AppendLine();
else sb.AppendLine("Filesystem has never been optimized");
- sb.AppendFormat("Directory band has {0} sectors", hpfsSb.dband_sectors).AppendLine();
- sb.AppendFormat("Directory band starts at sector {0}", hpfsSb.dband_start).AppendLine();
- sb.AppendFormat("Directory band ends at sector {0}", hpfsSb.dband_last).AppendLine();
+ sb.AppendFormat("Directory band has {0} sectors", hpfsSb.dband_sectors).AppendLine();
+ sb.AppendFormat("Directory band starts at sector {0}", hpfsSb.dband_start).AppendLine();
+ sb.AppendFormat("Directory band ends at sector {0}", hpfsSb.dband_last).AppendLine();
sb.AppendFormat("Sector of directory band bitmap: {0}", hpfsSb.dband_bitmap).AppendLine();
- sb.AppendFormat("Sector of ACL directory: {0}", hpfsSb.acl_start).AppendLine();
+ sb.AppendFormat("Sector of ACL directory: {0}", hpfsSb.acl_start).AppendLine();
- sb.AppendFormat("Sector of Hotfix directory: {0}", hpfsSp.hotfix_start).AppendLine();
- sb.AppendFormat("{0} used Hotfix entries", hpfsSp.hotfix_used).AppendLine();
- sb.AppendFormat("{0} total Hotfix entries", hpfsSp.hotfix_entries).AppendLine();
- sb.AppendFormat("{0} free spare DNodes", hpfsSp.spare_dnodes_free).AppendLine();
- sb.AppendFormat("{0} total spare DNodes", hpfsSp.spare_dnodes).AppendLine();
+ sb.AppendFormat("Sector of Hotfix directory: {0}", hpfsSp.hotfix_start).AppendLine();
+ sb.AppendFormat("{0} used Hotfix entries", hpfsSp.hotfix_used).AppendLine();
+ sb.AppendFormat("{0} total Hotfix entries", hpfsSp.hotfix_entries).AppendLine();
+ sb.AppendFormat("{0} free spare DNodes", hpfsSp.spare_dnodes_free).AppendLine();
+ sb.AppendFormat("{0} total spare DNodes", hpfsSp.spare_dnodes).AppendLine();
sb.AppendFormat("Sector of codepage directory: {0}", hpfsSp.codepage_lsn).AppendLine();
- sb.AppendFormat("{0} codepages used in the volume", hpfsSp.codepages).AppendLine();
- sb.AppendFormat("SuperBlock CRC32: {0:X8}", hpfsSp.sb_crc32).AppendLine();
- sb.AppendFormat("SpareBlock CRC32: {0:X8}", hpfsSp.sp_crc32).AppendLine();
+ sb.AppendFormat("{0} codepages used in the volume", hpfsSp.codepages).AppendLine();
+ sb.AppendFormat("SuperBlock CRC32: {0:X8}", hpfsSp.sb_crc32).AppendLine();
+ sb.AppendFormat("SpareBlock CRC32: {0:X8}", hpfsSp.sp_crc32).AppendLine();
sb.AppendLine("Flags:");
sb.AppendLine((hpfsSp.flags1 & 0x01) == 0x01 ? "Filesystem is dirty." : "Filesystem is clean.");
- if((hpfsSp.flags1 & 0x02) == 0x02) sb.AppendLine("Spare directory blocks are in use");
- if((hpfsSp.flags1 & 0x04) == 0x04) sb.AppendLine("Hotfixes are in use");
- if((hpfsSp.flags1 & 0x08) == 0x08) sb.AppendLine("Disk contains bad sectors");
- if((hpfsSp.flags1 & 0x10) == 0x10) sb.AppendLine("Disk has a bad bitmap");
- if((hpfsSp.flags1 & 0x20) == 0x20) sb.AppendLine("Filesystem was formatted fast");
- if((hpfsSp.flags1 & 0x40) == 0x40) sb.AppendLine("Unknown flag 0x40 on flags1 is active");
- if((hpfsSp.flags1 & 0x80) == 0x80) sb.AppendLine("Filesystem has been mounted by an old IFS");
- if((hpfsSp.flags2 & 0x01) == 0x01) sb.AppendLine("Install DASD limits");
- if((hpfsSp.flags2 & 0x02) == 0x02) sb.AppendLine("Resync DASD limits");
- if((hpfsSp.flags2 & 0x04) == 0x04) sb.AppendLine("DASD limits are operational");
- if((hpfsSp.flags2 & 0x08) == 0x08) sb.AppendLine("Multimedia is active");
- if((hpfsSp.flags2 & 0x10) == 0x10) sb.AppendLine("DCE ACLs are active");
- if((hpfsSp.flags2 & 0x20) == 0x20) sb.AppendLine("DASD limits are dirty");
- if((hpfsSp.flags2 & 0x40) == 0x40) sb.AppendLine("Unknown flag 0x40 on flags2 is active");
- if((hpfsSp.flags2 & 0x80) == 0x80) sb.AppendLine("Unknown flag 0x80 on flags2 is active");
+ if((hpfsSp.flags1 & 0x02) == 0x02) sb.AppendLine("Spare directory blocks are in use");
+ if((hpfsSp.flags1 & 0x04) == 0x04) sb.AppendLine("Hotfixes are in use");
+ if((hpfsSp.flags1 & 0x08) == 0x08) sb.AppendLine("Disk contains bad sectors");
+ if((hpfsSp.flags1 & 0x10) == 0x10) sb.AppendLine("Disk has a bad bitmap");
+ if((hpfsSp.flags1 & 0x20) == 0x20) sb.AppendLine("Filesystem was formatted fast");
+ if((hpfsSp.flags1 & 0x40) == 0x40) sb.AppendLine("Unknown flag 0x40 on flags1 is active");
+ if((hpfsSp.flags1 & 0x80) == 0x80) sb.AppendLine("Filesystem has been mounted by an old IFS");
+ if((hpfsSp.flags2 & 0x01) == 0x01) sb.AppendLine("Install DASD limits");
+ if((hpfsSp.flags2 & 0x02) == 0x02) sb.AppendLine("Resync DASD limits");
+ if((hpfsSp.flags2 & 0x04) == 0x04) sb.AppendLine("DASD limits are operational");
+ if((hpfsSp.flags2 & 0x08) == 0x08) sb.AppendLine("Multimedia is active");
+ if((hpfsSp.flags2 & 0x10) == 0x10) sb.AppendLine("DCE ACLs are active");
+ if((hpfsSp.flags2 & 0x20) == 0x20) sb.AppendLine("DASD limits are dirty");
+ if((hpfsSp.flags2 & 0x40) == 0x40) sb.AppendLine("Unknown flag 0x40 on flags2 is active");
+ if((hpfsSp.flags2 & 0x80) == 0x80) sb.AppendLine("Unknown flag 0x80 on flags2 is active");
XmlFsType = new FileSystemType();
// Theoretically everything from BPB to SB is boot code, should I hash everything or only the sector loaded by BIOS itself?
- if(hpfsBpb.jump[0] == 0xEB && hpfsBpb.jump[1] > 0x3C && hpfsBpb.jump[1] < 0x80 &&
+ if(hpfsBpb.jump[0] == 0xEB && hpfsBpb.jump[1] > 0x3C && hpfsBpb.jump[1] < 0x80 &&
hpfsBpb.signature2 == 0xAA55)
{
- XmlFsType.Bootable = true;
+ XmlFsType.Bootable = true;
Sha1Context sha1Ctx = new Sha1Context();
- sha1Ctx.Init();
- string bootChk = sha1Ctx.Data(hpfsBpb.boot_code, out byte[] sha1_out);
+ string bootChk = sha1Ctx.Data(hpfsBpb.boot_code, out byte[] sha1_out);
sb.AppendLine("Volume is bootable");
sb.AppendFormat("Boot code's SHA1: {0}", bootChk).AppendLine();
}
- XmlFsType.Dirty |= (hpfsSp.flags1 & 0x01) == 0x01;
- XmlFsType.Clusters = hpfsSb.sectors;
- XmlFsType.ClusterSize = hpfsBpb.bps;
- XmlFsType.Type = "HPFS";
- XmlFsType.VolumeName = StringHandlers.CToString(hpfsBpb.volume_label, Encoding);
- XmlFsType.VolumeSerial = $"{hpfsBpb.serial_no:X8}";
- XmlFsType.SystemIdentifier = StringHandlers.CToString(hpfsBpb.oem_name);
+ XmlFsType.Dirty |= (hpfsSp.flags1 & 0x01) == 0x01;
+ XmlFsType.Clusters = hpfsSb.sectors;
+ XmlFsType.ClusterSize = hpfsBpb.bps;
+ XmlFsType.Type = "HPFS";
+ XmlFsType.VolumeName = StringHandlers.CToString(hpfsBpb.volume_label, Encoding);
+ XmlFsType.VolumeSerial = $"{hpfsBpb.serial_no:X8}";
+ XmlFsType.SystemIdentifier = StringHandlers.CToString(hpfsBpb.oem_name);
information = sb.ToString();
}
@@ -205,9 +210,11 @@ namespace DiscImageChef.Filesystems
struct HPFS_BIOSParameterBlock
{
/// 0x000, Jump to boot code
- [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] public byte[] jump;
+ [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
+ public byte[] jump;
/// 0x003, OEM Name, 8 bytes, space-padded
- [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] public byte[] oem_name;
+ [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
+ public byte[] oem_name;
/// 0x00B, Bytes per sector
public ushort bps;
/// 0x00D, Sectors per cluster
@@ -241,11 +248,14 @@ namespace DiscImageChef.Filesystems
/// 0x02B, Volume serial number
public uint serial_no;
/// 0x02F, Volume label, 11 bytes, space-padded
- [MarshalAs(UnmanagedType.ByValArray, SizeConst = 11)] public byte[] volume_label;
+ [MarshalAs(UnmanagedType.ByValArray, SizeConst = 11)]
+ public byte[] volume_label;
/// 0x03A, Filesystem type, 8 bytes, space-padded ("HPFS ")
- [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] public byte[] fs_type;
+ [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
+ public byte[] fs_type;
/// Boot code.
- [MarshalAs(UnmanagedType.ByValArray, SizeConst = 448)] public byte[] boot_code;
+ [MarshalAs(UnmanagedType.ByValArray, SizeConst = 448)]
+ public byte[] boot_code;
/// 0x1FE, 0xAA55
public ushort signature2;
}
diff --git a/DiscImageChef.Filesystems/ISO9660/Info.cs b/DiscImageChef.Filesystems/ISO9660/Info.cs
index 80ee7ce7..029f6268 100644
--- a/DiscImageChef.Filesystems/ISO9660/Info.cs
+++ b/DiscImageChef.Filesystems/ISO9660/Info.cs
@@ -569,7 +569,6 @@ namespace DiscImageChef.Filesystems.ISO9660
{
vdSector = imagePlugin.ReadSector(torito.Value.catalog_sector + partition.Start);
Sha1Context sha1Ctx = new Sha1Context();
- sha1Ctx.Init();
int toritoOff = 0;
diff --git a/DiscImageChef.Filesystems/NTFS.cs b/DiscImageChef.Filesystems/NTFS.cs
index 99a498c3..2b69f86f 100644
--- a/DiscImageChef.Filesystems/NTFS.cs
+++ b/DiscImageChef.Filesystems/NTFS.cs
@@ -44,17 +44,15 @@ namespace DiscImageChef.Filesystems
public class NTFS : IFilesystem
{
public FileSystemType XmlFsType { get; private set; }
- public Encoding Encoding { get; private set; }
- public string Name => "New Technology File System (NTFS)";
- public Guid Id => new Guid("33513B2C-1e6d-4d21-a660-0bbc789c3871");
+ public Encoding Encoding { get; private set; }
+ public string Name => "New Technology File System (NTFS)";
+ public Guid Id => new Guid("33513B2C-1e6d-4d21-a660-0bbc789c3871");
public bool Identify(IMediaImage imagePlugin, Partition partition)
{
if(2 + partition.Start >= partition.End) return false;
byte[] eigthBytes = new byte[8];
- byte fatsNo;
- ushort spFat, signature;
byte[] ntfsBpb = imagePlugin.ReadSector(0 + partition.Start);
@@ -63,23 +61,20 @@ namespace DiscImageChef.Filesystems
if(oemName != "NTFS ") return false;
- fatsNo = ntfsBpb[0x010];
+ byte fatsNo = ntfsBpb[0x010];
+ ushort spFat = BitConverter.ToUInt16(ntfsBpb, 0x016);
+ ushort signature = BitConverter.ToUInt16(ntfsBpb, 0x1FE);
if(fatsNo != 0) return false;
-
- spFat = BitConverter.ToUInt16(ntfsBpb, 0x016);
-
- if(spFat != 0) return false;
-
- signature = BitConverter.ToUInt16(ntfsBpb, 0x1FE);
+ if(spFat != 0) return false;
return signature == 0xAA55;
}
public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information,
- Encoding encoding)
+ Encoding encoding)
{
- Encoding = Encoding.Unicode;
+ Encoding = Encoding.Unicode;
information = "";
StringBuilder sb = new StringBuilder();
@@ -91,7 +86,7 @@ namespace DiscImageChef.Filesystems
NtfsBootBlock ntfsBb = (NtfsBootBlock)Marshal.PtrToStructure(bpbPtr, typeof(NtfsBootBlock));
Marshal.FreeHGlobal(bpbPtr);
- sb.AppendFormat("{0} bytes per sector", ntfsBb.bps).AppendLine();
+ sb.AppendFormat("{0} bytes per sector", ntfsBb.bps).AppendLine();
sb.AppendFormat("{0} sectors per cluster ({1} bytes)", ntfsBb.spc, ntfsBb.spc * ntfsBb.bps).AppendLine();
// sb.AppendFormat("{0} reserved sectors", ntfs_bb.rsectors).AppendLine();
// sb.AppendFormat("{0} FATs", ntfs_bb.fats_no).AppendLine();
@@ -99,8 +94,8 @@ namespace DiscImageChef.Filesystems
// sb.AppendFormat("{0} sectors on volume (small)", ntfs_bb.sml_sectors).AppendLine();
sb.AppendFormat("Media descriptor: 0x{0:X2}", ntfsBb.media).AppendLine();
// sb.AppendFormat("{0} sectors per FAT", ntfs_bb.spfat).AppendLine();
- sb.AppendFormat("{0} sectors per track", ntfsBb.sptrk).AppendLine();
- sb.AppendFormat("{0} heads", ntfsBb.heads).AppendLine();
+ sb.AppendFormat("{0} sectors per track", ntfsBb.sptrk).AppendLine();
+ sb.AppendFormat("{0} heads", ntfsBb.heads).AppendLine();
sb.AppendFormat("{0} hidden sectors before filesystem", ntfsBb.hsectors).AppendLine();
// sb.AppendFormat("{0} sectors on volume (big)", ntfs_bb.big_sectors).AppendLine();
sb.AppendFormat("BIOS drive number: 0x{0:X2}", ntfsBb.drive_no).AppendLine();
@@ -108,7 +103,7 @@ namespace DiscImageChef.Filesystems
// sb.AppendFormat("Signature 1: 0x{0:X2}", ntfs_bb.signature1).AppendLine();
sb.AppendFormat("{0} sectors on volume ({1} bytes)", ntfsBb.sectors, ntfsBb.sectors * ntfsBb.bps)
.AppendLine();
- sb.AppendFormat("Cluster where $MFT starts: {0}", ntfsBb.mft_lsn).AppendLine();
+ sb.AppendFormat("Cluster where $MFT starts: {0}", ntfsBb.mft_lsn).AppendLine();
sb.AppendFormat("Cluster where $MFTMirr starts: {0}", ntfsBb.mftmirror_lsn).AppendLine();
if(ntfsBb.mft_rc_clusters > 0)
@@ -127,18 +122,17 @@ namespace DiscImageChef.Filesystems
if(ntfsBb.jump[0] == 0xEB && ntfsBb.jump[1] > 0x4E && ntfsBb.jump[1] < 0x80 && ntfsBb.signature2 == 0xAA55)
{
- XmlFsType.Bootable = true;
+ XmlFsType.Bootable = true;
Sha1Context sha1Ctx = new Sha1Context();
- sha1Ctx.Init();
- string bootChk = sha1Ctx.Data(ntfsBb.boot_code, out _);
+ string bootChk = sha1Ctx.Data(ntfsBb.boot_code, out _);
sb.AppendLine("Volume is bootable");
sb.AppendFormat("Boot code's SHA1: {0}", bootChk).AppendLine();
}
- XmlFsType.ClusterSize = ntfsBb.spc * ntfsBb.bps;
- XmlFsType.Clusters = ntfsBb.sectors / ntfsBb.spc;
+ XmlFsType.ClusterSize = ntfsBb.spc * ntfsBb.bps;
+ XmlFsType.Clusters = ntfsBb.sectors / ntfsBb.spc;
XmlFsType.VolumeSerial = $"{ntfsBb.serial_no:X16}";
- XmlFsType.Type = "NTFS";
+ XmlFsType.Type = "NTFS";
information = sb.ToString();
}
@@ -151,9 +145,11 @@ namespace DiscImageChef.Filesystems
{
// Start of BIOS Parameter Block
/// 0x000, Jump to boot code
- [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] public byte[] jump;
+ [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
+ public byte[] jump;
/// 0x003, OEM Name, 8 bytes, space-padded, must be "NTFS "
- [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] public byte[] oem_name;
+ [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
+ public byte[] oem_name;
/// 0x00B, Bytes per sector
public ushort bps;
/// 0x00D, Sectors per cluster
@@ -210,7 +206,8 @@ namespace DiscImageChef.Filesystems
/// 0x048, Volume serial number
public ulong serial_no;
/// Boot code.
- [MarshalAs(UnmanagedType.ByValArray, SizeConst = 430)] public byte[] boot_code;
+ [MarshalAs(UnmanagedType.ByValArray, SizeConst = 430)]
+ public byte[] boot_code;
/// 0x1FE, 0xAA55
public ushort signature2;
}
diff --git a/DiscImageChef.Partitions/Atari.cs b/DiscImageChef.Partitions/Atari.cs
index 53bdc4e6..02783912 100644
--- a/DiscImageChef.Partitions/Atari.cs
+++ b/DiscImageChef.Partitions/Atari.cs
@@ -42,21 +42,21 @@ namespace DiscImageChef.Partitions
{
public class AtariPartitions : IPartition
{
- const uint TypeGEMDOS = 0x0047454D;
- const uint TypeBigGEMDOS = 0x0042474D;
- const uint TypeExtended = 0x0058474D;
- const uint TypeLinux = 0x004C4E58;
- const uint TypeSwap = 0x00535750;
- const uint TypeRAW = 0x00524157;
- const uint TypeNetBSD = 0x004E4244;
+ const uint TypeGEMDOS = 0x0047454D;
+ const uint TypeBigGEMDOS = 0x0042474D;
+ const uint TypeExtended = 0x0058474D;
+ const uint TypeLinux = 0x004C4E58;
+ const uint TypeSwap = 0x00535750;
+ const uint TypeRAW = 0x00524157;
+ const uint TypeNetBSD = 0x004E4244;
const uint TypeNetBSDSwap = 0x004E4253;
- const uint TypeSysV = 0x00554E58;
- const uint TypeMac = 0x004D4143;
- const uint TypeMinix = 0x004D4958;
- const uint TypeMinix2 = 0x004D4E58;
+ const uint TypeSysV = 0x00554E58;
+ const uint TypeMac = 0x004D4143;
+ const uint TypeMinix = 0x004D4958;
+ const uint TypeMinix2 = 0x004D4E58;
public string Name => "Atari partitions";
- public Guid Id => new Guid("d1dd0f24-ec39-4c4d-9072-be31919a3b5e");
+ public Guid Id => new Guid("d1dd0f24-ec39-4c4d-9072-be31919a3b5e");
public bool GetInformation(IMediaImage imagePlugin, out List partitions, ulong sectorOffset)
{
@@ -70,18 +70,18 @@ namespace DiscImageChef.Partitions
AtariTable table = new AtariTable
{
- boot = new byte[342],
+ boot = new byte[342],
icdEntries = new AtariEntry[8],
- unused = new byte[12],
- entries = new AtariEntry[4]
+ unused = new byte[12],
+ entries = new AtariEntry[4]
};
Array.Copy(sector, 0, table.boot, 0, 342);
for(int i = 0; i < 8; i++)
{
- table.icdEntries[i].type = BigEndianBitConverter.ToUInt32(sector, 342 + i * 12 + 0);
- table.icdEntries[i].start = BigEndianBitConverter.ToUInt32(sector, 342 + i * 12 + 4);
+ table.icdEntries[i].type = BigEndianBitConverter.ToUInt32(sector, 342 + i * 12 + 0);
+ table.icdEntries[i].start = BigEndianBitConverter.ToUInt32(sector, 342 + i * 12 + 4);
table.icdEntries[i].length = BigEndianBitConverter.ToUInt32(sector, 342 + i * 12 + 8);
}
@@ -91,17 +91,16 @@ namespace DiscImageChef.Partitions
for(int i = 0; i < 4; i++)
{
- table.entries[i].type = BigEndianBitConverter.ToUInt32(sector, 454 + i * 12 + 0);
- table.entries[i].start = BigEndianBitConverter.ToUInt32(sector, 454 + i * 12 + 4);
+ table.entries[i].type = BigEndianBitConverter.ToUInt32(sector, 454 + i * 12 + 0);
+ table.entries[i].start = BigEndianBitConverter.ToUInt32(sector, 454 + i * 12 + 4);
table.entries[i].length = BigEndianBitConverter.ToUInt32(sector, 454 + i * 12 + 8);
}
- table.badStart = BigEndianBitConverter.ToUInt32(sector, 502);
+ table.badStart = BigEndianBitConverter.ToUInt32(sector, 502);
table.badLength = BigEndianBitConverter.ToUInt32(sector, 506);
- table.checksum = BigEndianBitConverter.ToUInt16(sector, 510);
+ table.checksum = BigEndianBitConverter.ToUInt16(sector, 510);
Sha1Context sha1Ctx = new Sha1Context();
- sha1Ctx.Init();
sha1Ctx.Update(table.boot);
DicConsole.DebugWriteLine("Atari partition plugin", "Boot code SHA1: {0}", sha1Ctx.End());
@@ -131,11 +130,11 @@ namespace DiscImageChef.Partitions
table.entries[i].length);
}
- DicConsole.DebugWriteLine("Atari partition plugin", "table.badStart = {0}", table.badStart);
- DicConsole.DebugWriteLine("Atari partition plugin", "table.badLength = {0}", table.badLength);
+ DicConsole.DebugWriteLine("Atari partition plugin", "table.badStart = {0}", table.badStart);
+ DicConsole.DebugWriteLine("Atari partition plugin", "table.badLength = {0}", table.badLength);
DicConsole.DebugWriteLine("Atari partition plugin", "table.checksum = 0x{0:X4}", table.checksum);
- bool validTable = false;
+ bool validTable = false;
ulong partitionSequence = 0;
for(int i = 0; i < 4; i++)
{
@@ -162,24 +161,24 @@ namespace DiscImageChef.Partitions
DicConsole.DebugWriteLine("Atari partition plugin",
"WARNING: End of partition goes beyond device size");
- ulong sectorSize = imagePlugin.Info.SectorSize;
+ ulong sectorSize = imagePlugin.Info.SectorSize;
if(sectorSize == 2448 || sectorSize == 2352) sectorSize = 2048;
byte[] partType = new byte[3];
- partType[0] = (byte)((type & 0xFF0000) >> 16);
- partType[1] = (byte)((type & 0x00FF00) >> 8);
- partType[2] = (byte)(type & 0x0000FF);
+ partType[0] = (byte)((type & 0xFF0000) >> 16);
+ partType[1] = (byte)((type & 0x00FF00) >> 8);
+ partType[2] = (byte)(type & 0x0000FF);
Partition part = new Partition
{
- Size = table.entries[i].length * sectorSize,
- Length = table.entries[i].length,
+ Size = table.entries[i].length * sectorSize,
+ Length = table.entries[i].length,
Sequence = partitionSequence,
- Name = "",
- Offset = table.entries[i].start * sectorSize,
- Start = table.entries[i].start,
- Type = Encoding.ASCII.GetString(partType),
- Scheme = Name
+ Name = "",
+ Offset = table.entries[i].start * sectorSize,
+ Start = table.entries[i].start,
+ Type = Encoding.ASCII.GetString(partType),
+ Scheme = Name
};
switch(type)
{
@@ -225,9 +224,9 @@ namespace DiscImageChef.Partitions
break;
case TypeExtended:
- byte[] extendedSector = imagePlugin.ReadSector(table.entries[i].start);
- AtariTable extendedTable = new AtariTable();
- extendedTable.entries = new AtariEntry[4];
+ byte[] extendedSector = imagePlugin.ReadSector(table.entries[i].start);
+ AtariTable extendedTable = new AtariTable();
+ extendedTable.entries = new AtariEntry[4];
for(int j = 0; j < 4; j++)
{
@@ -244,9 +243,11 @@ namespace DiscImageChef.Partitions
uint extendedType = extendedTable.entries[j].type & 0x00FFFFFF;
if(extendedType != TypeGEMDOS && extendedType != TypeBigGEMDOS &&
- extendedType != TypeLinux && extendedType != TypeSwap && extendedType != TypeRAW &&
+ extendedType != TypeLinux && extendedType != TypeSwap &&
+ extendedType != TypeRAW &&
extendedType != TypeNetBSD && extendedType != TypeNetBSDSwap &&
- extendedType != TypeSysV && extendedType != TypeMac && extendedType != TypeMinix &&
+ extendedType != TypeSysV && extendedType != TypeMac &&
+ extendedType != TypeMinix &&
extendedType != TypeMinix2) continue;
validTable = true;
@@ -257,24 +258,24 @@ namespace DiscImageChef.Partitions
DicConsole.DebugWriteLine("Atari partition plugin",
"WARNING: End of partition goes beyond device size");
- ulong sectorSize = imagePlugin.Info.SectorSize;
+ ulong sectorSize = imagePlugin.Info.SectorSize;
if(sectorSize == 2448 || sectorSize == 2352) sectorSize = 2048;
byte[] partType = new byte[3];
- partType[0] = (byte)((extendedType & 0xFF0000) >> 16);
- partType[1] = (byte)((extendedType & 0x00FF00) >> 8);
- partType[2] = (byte)(extendedType & 0x0000FF);
+ partType[0] = (byte)((extendedType & 0xFF0000) >> 16);
+ partType[1] = (byte)((extendedType & 0x00FF00) >> 8);
+ partType[2] = (byte)(extendedType & 0x0000FF);
Partition part = new Partition
{
- Size = extendedTable.entries[j].length * sectorSize,
- Length = extendedTable.entries[j].length,
+ Size = extendedTable.entries[j].length * sectorSize,
+ Length = extendedTable.entries[j].length,
Sequence = partitionSequence,
- Name = "",
- Offset = extendedTable.entries[j].start * sectorSize,
- Start = extendedTable.entries[j].start,
- Type = Encoding.ASCII.GetString(partType),
- Scheme = Name
+ Name = "",
+ Offset = extendedTable.entries[j].start * sectorSize,
+ Start = extendedTable.entries[j].start,
+ Type = Encoding.ASCII.GetString(partType),
+ Scheme = Name
};
switch(extendedType)
{
@@ -328,9 +329,9 @@ namespace DiscImageChef.Partitions
{
uint type = table.icdEntries[i].type & 0x00FFFFFF;
- if(type != TypeGEMDOS && type != TypeBigGEMDOS && type != TypeLinux && type != TypeSwap &&
- type != TypeRAW && type != TypeNetBSD && type != TypeNetBSDSwap && type != TypeSysV &&
- type != TypeMac && type != TypeMinix && type != TypeMinix2) continue;
+ if(type != TypeGEMDOS && type != TypeBigGEMDOS && type != TypeLinux && type != TypeSwap &&
+ type != TypeRAW && type != TypeNetBSD && type != TypeNetBSDSwap && type != TypeSysV &&
+ type != TypeMac && type != TypeMinix && type != TypeMinix2) continue;
if(table.icdEntries[i].start > imagePlugin.Info.Sectors) continue;
@@ -338,24 +339,24 @@ namespace DiscImageChef.Partitions
DicConsole.DebugWriteLine("Atari partition plugin",
"WARNING: End of partition goes beyond device size");
- ulong sectorSize = imagePlugin.Info.SectorSize;
+ ulong sectorSize = imagePlugin.Info.SectorSize;
if(sectorSize == 2448 || sectorSize == 2352) sectorSize = 2048;
byte[] partType = new byte[3];
- partType[0] = (byte)((type & 0xFF0000) >> 16);
- partType[1] = (byte)((type & 0x00FF00) >> 8);
- partType[2] = (byte)(type & 0x0000FF);
+ partType[0] = (byte)((type & 0xFF0000) >> 16);
+ partType[1] = (byte)((type & 0x00FF00) >> 8);
+ partType[2] = (byte)(type & 0x0000FF);
Partition part = new Partition
{
- Size = table.icdEntries[i].length * sectorSize,
- Length = table.icdEntries[i].length,
+ Size = table.icdEntries[i].length * sectorSize,
+ Length = table.icdEntries[i].length,
Sequence = partitionSequence,
- Name = "",
- Offset = table.icdEntries[i].start * sectorSize,
- Start = table.icdEntries[i].start,
- Type = Encoding.ASCII.GetString(partType),
- Scheme = Name
+ Name = "",
+ Offset = table.icdEntries[i].start * sectorSize,
+ Start = table.icdEntries[i].start,
+ Type = Encoding.ASCII.GetString(partType),
+ Scheme = Name
};
switch(type)
{
diff --git a/DiscImageChef.Partitions/RDB.cs b/DiscImageChef.Partitions/RDB.cs
index 1bb65e0b..a1c65f24 100644
--- a/DiscImageChef.Partitions/RDB.cs
+++ b/DiscImageChef.Partitions/RDB.cs
@@ -276,14 +276,14 @@ namespace DiscImageChef.Partitions
const uint FLAGS_NO_AUTOMOUNT = 0x00000002;
public string Name => "Amiga Rigid Disk Block";
- public Guid Id => new Guid("8D72ED97-1854-4170-9CE4-6E8446FD9863");
+ public Guid Id => new Guid("8D72ED97-1854-4170-9CE4-6E8446FD9863");
public bool GetInformation(IMediaImage imagePlugin, out List partitions, ulong sectorOffset)
{
- partitions = new List();
+ partitions = new List();
BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian;
- ulong rdbBlock = 0;
- bool foundRdb = false;
+ ulong rdbBlock = 0;
+ bool foundRdb = false;
while(rdbBlock < 16)
{
@@ -292,7 +292,7 @@ namespace DiscImageChef.Partitions
if(rdbBlock + sectorOffset >= imagePlugin.Info.Sectors) break;
byte[] tmpSector = imagePlugin.ReadSector(rdbBlock + sectorOffset);
- uint magic = BigEndianBitConverter.ToUInt32(tmpSector, 0);
+ uint magic = BigEndianBitConverter.ToUInt32(tmpSector, 0);
DicConsole.DebugWriteLine("Amiga RDB plugin", "Possible magic at block {0} is 0x{1:X8}", rdbBlock,
magic);
@@ -316,64 +316,64 @@ namespace DiscImageChef.Partitions
byte[] sector = imagePlugin.ReadSector(rdbBlock);
- rdb.Magic = BigEndianBitConverter.ToUInt32(sector, 0x00);
- rdb.Size = BigEndianBitConverter.ToUInt32(sector, 0x04);
- rdb.Checksum = BigEndianBitConverter.ToInt32(sector, 0x08);
- rdb.TargetId = BigEndianBitConverter.ToUInt32(sector, 0x0C);
- rdb.BlockSize = BigEndianBitConverter.ToUInt32(sector, 0x10);
- rdb.Flags = BigEndianBitConverter.ToUInt32(sector, 0x04);
- rdb.BadblockPtr = BigEndianBitConverter.ToUInt32(sector, 0x18);
- rdb.PartitionPtr = BigEndianBitConverter.ToUInt32(sector, 0x1C);
- rdb.FsheaderPtr = BigEndianBitConverter.ToUInt32(sector, 0x20);
- rdb.Driveinitcode = BigEndianBitConverter.ToUInt32(sector, 0x24);
- rdb.Reserved1 = BigEndianBitConverter.ToUInt32(sector, 0x28);
- rdb.Reserved2 = BigEndianBitConverter.ToUInt32(sector, 0x2C);
- rdb.Reserved3 = BigEndianBitConverter.ToUInt32(sector, 0x30);
- rdb.Reserved4 = BigEndianBitConverter.ToUInt32(sector, 0x34);
- rdb.Reserved5 = BigEndianBitConverter.ToUInt32(sector, 0x38);
- rdb.Reserved6 = BigEndianBitConverter.ToUInt32(sector, 0x3C);
- rdb.Cylinders = BigEndianBitConverter.ToUInt32(sector, 0x40);
- rdb.Spt = BigEndianBitConverter.ToUInt32(sector, 0x44);
- rdb.Heads = BigEndianBitConverter.ToUInt32(sector, 0x48);
- rdb.Interleave = BigEndianBitConverter.ToUInt32(sector, 0x4C);
- rdb.Parking = BigEndianBitConverter.ToUInt32(sector, 0x50);
- rdb.Reserved7 = BigEndianBitConverter.ToUInt32(sector, 0x54);
- rdb.Reserved8 = BigEndianBitConverter.ToUInt32(sector, 0x58);
- rdb.Reserved9 = BigEndianBitConverter.ToUInt32(sector, 0x5C);
- rdb.Writeprecomp = BigEndianBitConverter.ToUInt32(sector, 0x60);
- rdb.Reducedwrite = BigEndianBitConverter.ToUInt32(sector, 0x64);
- rdb.Steprate = BigEndianBitConverter.ToUInt32(sector, 0x68);
- rdb.Reserved10 = BigEndianBitConverter.ToUInt32(sector, 0x6C);
- rdb.Reserved11 = BigEndianBitConverter.ToUInt32(sector, 0x70);
- rdb.Reserved12 = BigEndianBitConverter.ToUInt32(sector, 0x74);
- rdb.Reserved13 = BigEndianBitConverter.ToUInt32(sector, 0x78);
- rdb.Reserved14 = BigEndianBitConverter.ToUInt32(sector, 0x7C);
- rdb.RdbBlockLow = BigEndianBitConverter.ToUInt32(sector, 0x80);
- rdb.RdbBlockHigh = BigEndianBitConverter.ToUInt32(sector, 0x84);
- rdb.LowCylinder = BigEndianBitConverter.ToUInt32(sector, 0x88);
- rdb.HighCylinder = BigEndianBitConverter.ToUInt32(sector, 0x8C);
- rdb.CylBlocks = BigEndianBitConverter.ToUInt32(sector, 0x90);
+ rdb.Magic = BigEndianBitConverter.ToUInt32(sector, 0x00);
+ rdb.Size = BigEndianBitConverter.ToUInt32(sector, 0x04);
+ rdb.Checksum = BigEndianBitConverter.ToInt32(sector, 0x08);
+ rdb.TargetId = BigEndianBitConverter.ToUInt32(sector, 0x0C);
+ rdb.BlockSize = BigEndianBitConverter.ToUInt32(sector, 0x10);
+ rdb.Flags = BigEndianBitConverter.ToUInt32(sector, 0x04);
+ rdb.BadblockPtr = BigEndianBitConverter.ToUInt32(sector, 0x18);
+ rdb.PartitionPtr = BigEndianBitConverter.ToUInt32(sector, 0x1C);
+ rdb.FsheaderPtr = BigEndianBitConverter.ToUInt32(sector, 0x20);
+ rdb.Driveinitcode = BigEndianBitConverter.ToUInt32(sector, 0x24);
+ rdb.Reserved1 = BigEndianBitConverter.ToUInt32(sector, 0x28);
+ rdb.Reserved2 = BigEndianBitConverter.ToUInt32(sector, 0x2C);
+ rdb.Reserved3 = BigEndianBitConverter.ToUInt32(sector, 0x30);
+ rdb.Reserved4 = BigEndianBitConverter.ToUInt32(sector, 0x34);
+ rdb.Reserved5 = BigEndianBitConverter.ToUInt32(sector, 0x38);
+ rdb.Reserved6 = BigEndianBitConverter.ToUInt32(sector, 0x3C);
+ rdb.Cylinders = BigEndianBitConverter.ToUInt32(sector, 0x40);
+ rdb.Spt = BigEndianBitConverter.ToUInt32(sector, 0x44);
+ rdb.Heads = BigEndianBitConverter.ToUInt32(sector, 0x48);
+ rdb.Interleave = BigEndianBitConverter.ToUInt32(sector, 0x4C);
+ rdb.Parking = BigEndianBitConverter.ToUInt32(sector, 0x50);
+ rdb.Reserved7 = BigEndianBitConverter.ToUInt32(sector, 0x54);
+ rdb.Reserved8 = BigEndianBitConverter.ToUInt32(sector, 0x58);
+ rdb.Reserved9 = BigEndianBitConverter.ToUInt32(sector, 0x5C);
+ rdb.Writeprecomp = BigEndianBitConverter.ToUInt32(sector, 0x60);
+ rdb.Reducedwrite = BigEndianBitConverter.ToUInt32(sector, 0x64);
+ rdb.Steprate = BigEndianBitConverter.ToUInt32(sector, 0x68);
+ rdb.Reserved10 = BigEndianBitConverter.ToUInt32(sector, 0x6C);
+ rdb.Reserved11 = BigEndianBitConverter.ToUInt32(sector, 0x70);
+ rdb.Reserved12 = BigEndianBitConverter.ToUInt32(sector, 0x74);
+ rdb.Reserved13 = BigEndianBitConverter.ToUInt32(sector, 0x78);
+ rdb.Reserved14 = BigEndianBitConverter.ToUInt32(sector, 0x7C);
+ rdb.RdbBlockLow = BigEndianBitConverter.ToUInt32(sector, 0x80);
+ rdb.RdbBlockHigh = BigEndianBitConverter.ToUInt32(sector, 0x84);
+ rdb.LowCylinder = BigEndianBitConverter.ToUInt32(sector, 0x88);
+ rdb.HighCylinder = BigEndianBitConverter.ToUInt32(sector, 0x8C);
+ rdb.CylBlocks = BigEndianBitConverter.ToUInt32(sector, 0x90);
rdb.AutoParkSeconds = BigEndianBitConverter.ToUInt32(sector, 0x94);
- rdb.HighCylinder = BigEndianBitConverter.ToUInt32(sector, 0x98);
- rdb.Reserved15 = BigEndianBitConverter.ToUInt32(sector, 0x9C);
+ rdb.HighCylinder = BigEndianBitConverter.ToUInt32(sector, 0x98);
+ rdb.Reserved15 = BigEndianBitConverter.ToUInt32(sector, 0x9C);
byte[] tmpString = new byte[8];
Array.Copy(sector, 0xA0, tmpString, 0, 8);
rdb.DiskVendor = StringHandlers.SpacePaddedToString(tmpString);
- tmpString = new byte[16];
+ tmpString = new byte[16];
Array.Copy(sector, 0xA8, tmpString, 0, 16);
rdb.DiskProduct = StringHandlers.SpacePaddedToString(tmpString);
- tmpString = new byte[4];
+ tmpString = new byte[4];
Array.Copy(sector, 0xB8, tmpString, 0, 4);
rdb.DiskRevision = StringHandlers.SpacePaddedToString(tmpString);
tmpString = new byte[8];
Array.Copy(sector, 0xBC, tmpString, 0, 8);
rdb.ControllerVendor = StringHandlers.SpacePaddedToString(tmpString);
- tmpString = new byte[16];
+ tmpString = new byte[16];
Array.Copy(sector, 0xC4, tmpString, 0, 16);
rdb.ControllerProduct = StringHandlers.SpacePaddedToString(tmpString);
- tmpString = new byte[4];
+ tmpString = new byte[4];
Array.Copy(sector, 0xD4, tmpString, 0, 4);
rdb.ControllerRevision = StringHandlers.SpacePaddedToString(tmpString);
@@ -388,73 +388,73 @@ namespace DiscImageChef.Partitions
rdb.Reserved24 = BigEndianBitConverter.ToUInt32(sector, 0xF8);
rdb.Reserved25 = BigEndianBitConverter.ToUInt32(sector, 0xFC);
- DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.magic = 0x{0:X8}", rdb.Magic);
- DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.size = {0} longs, {1} bytes", rdb.Size, rdb.Size * 4);
- DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.checksum = 0x{0:X8}", rdb.Checksum);
- DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.targetID = {0}", rdb.TargetId);
- DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.block_size = {0}", rdb.BlockSize);
- DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.badblock_ptr = {0}", rdb.BadblockPtr);
- DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.partition_ptr = {0}", rdb.PartitionPtr);
- DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.fsheader_ptr = {0}", rdb.FsheaderPtr);
- DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.driveinitcode = {0}", rdb.Driveinitcode);
- DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.reserved1 = 0x{0:X8}", rdb.Reserved1);
- DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.reserved2 = 0x{0:X8}", rdb.Reserved2);
- DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.reserved3 = 0x{0:X8}", rdb.Reserved3);
- DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.reserved4 = 0x{0:X8}", rdb.Reserved4);
- DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.reserved5 = 0x{0:X8}", rdb.Reserved5);
- DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.reserved6 = 0x{0:X8}", rdb.Reserved6);
- DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.cylinders = {0}", rdb.Cylinders);
- DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.spt = {0}", rdb.Spt);
- DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.heads = {0}", rdb.Heads);
- DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.interleave = {0}", rdb.Interleave);
- DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.parking = {0}", rdb.Parking);
- DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.reserved7 = 0x{0:X8}", rdb.Reserved7);
- DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.reserved8 = 0x{0:X8}", rdb.Reserved8);
- DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.reserved9 = 0x{0:X8}", rdb.Reserved9);
- DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.writeprecomp = {0}", rdb.Writeprecomp);
- DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.reducedwrite = {0}", rdb.Reducedwrite);
- DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.steprate = {0}", rdb.Steprate);
- DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.reserved10 = 0x{0:X8}", rdb.Reserved10);
- DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.reserved11 = 0x{0:X8}", rdb.Reserved11);
- DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.reserved12 = 0x{0:X8}", rdb.Reserved12);
- DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.reserved13 = 0x{0:X8}", rdb.Reserved13);
- DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.reserved14 = 0x{0:X8}", rdb.Reserved14);
- DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.RDBBlockLow = {0}", rdb.RdbBlockLow);
- DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.RDBBlockHigh = {0}", rdb.RdbBlockHigh);
- DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.LowCylinder = {0}", rdb.LowCylinder);
- DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.HighCylinder = {0}", rdb.HighCylinder);
- DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.CylBlocks = {0}", rdb.CylBlocks);
- DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.AutoParkSeconds = {0}", rdb.AutoParkSeconds);
- DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.HighCylinder = {0}", rdb.HighCylinder);
- DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.reserved15 = 0x{0:X8}", rdb.Reserved15);
- DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.diskVendor = \"{0}\"", rdb.DiskVendor);
- DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.diskProduct = \"{0}\"", rdb.DiskProduct);
- DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.diskRevision = \"{0}\"", rdb.DiskRevision);
- DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.controllerVendor = \"{0}\"", rdb.ControllerVendor);
- DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.controllerProduct = \"{0}\"", rdb.ControllerProduct);
+ DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.magic = 0x{0:X8}", rdb.Magic);
+ DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.size = {0} longs, {1} bytes", rdb.Size, rdb.Size * 4);
+ DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.checksum = 0x{0:X8}", rdb.Checksum);
+ DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.targetID = {0}", rdb.TargetId);
+ DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.block_size = {0}", rdb.BlockSize);
+ DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.badblock_ptr = {0}", rdb.BadblockPtr);
+ DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.partition_ptr = {0}", rdb.PartitionPtr);
+ DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.fsheader_ptr = {0}", rdb.FsheaderPtr);
+ DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.driveinitcode = {0}", rdb.Driveinitcode);
+ DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.reserved1 = 0x{0:X8}", rdb.Reserved1);
+ DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.reserved2 = 0x{0:X8}", rdb.Reserved2);
+ DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.reserved3 = 0x{0:X8}", rdb.Reserved3);
+ DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.reserved4 = 0x{0:X8}", rdb.Reserved4);
+ DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.reserved5 = 0x{0:X8}", rdb.Reserved5);
+ DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.reserved6 = 0x{0:X8}", rdb.Reserved6);
+ DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.cylinders = {0}", rdb.Cylinders);
+ DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.spt = {0}", rdb.Spt);
+ DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.heads = {0}", rdb.Heads);
+ DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.interleave = {0}", rdb.Interleave);
+ DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.parking = {0}", rdb.Parking);
+ DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.reserved7 = 0x{0:X8}", rdb.Reserved7);
+ DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.reserved8 = 0x{0:X8}", rdb.Reserved8);
+ DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.reserved9 = 0x{0:X8}", rdb.Reserved9);
+ DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.writeprecomp = {0}", rdb.Writeprecomp);
+ DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.reducedwrite = {0}", rdb.Reducedwrite);
+ DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.steprate = {0}", rdb.Steprate);
+ DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.reserved10 = 0x{0:X8}", rdb.Reserved10);
+ DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.reserved11 = 0x{0:X8}", rdb.Reserved11);
+ DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.reserved12 = 0x{0:X8}", rdb.Reserved12);
+ DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.reserved13 = 0x{0:X8}", rdb.Reserved13);
+ DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.reserved14 = 0x{0:X8}", rdb.Reserved14);
+ DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.RDBBlockLow = {0}", rdb.RdbBlockLow);
+ DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.RDBBlockHigh = {0}", rdb.RdbBlockHigh);
+ DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.LowCylinder = {0}", rdb.LowCylinder);
+ DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.HighCylinder = {0}", rdb.HighCylinder);
+ DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.CylBlocks = {0}", rdb.CylBlocks);
+ DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.AutoParkSeconds = {0}", rdb.AutoParkSeconds);
+ DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.HighCylinder = {0}", rdb.HighCylinder);
+ DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.reserved15 = 0x{0:X8}", rdb.Reserved15);
+ DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.diskVendor = \"{0}\"", rdb.DiskVendor);
+ DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.diskProduct = \"{0}\"", rdb.DiskProduct);
+ DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.diskRevision = \"{0}\"", rdb.DiskRevision);
+ DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.controllerVendor = \"{0}\"", rdb.ControllerVendor);
+ DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.controllerProduct = \"{0}\"", rdb.ControllerProduct);
DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.controllerRevision = \"{0}\"", rdb.ControllerRevision);
- DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.reserved16 = 0x{0:X8}", rdb.Reserved16);
- DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.reserved17 = 0x{0:X8}", rdb.Reserved17);
- DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.reserved18 = 0x{0:X8}", rdb.Reserved18);
- DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.reserved19 = 0x{0:X8}", rdb.Reserved19);
- DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.reserved20 = 0x{0:X8}", rdb.Reserved20);
- DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.reserved21 = 0x{0:X8}", rdb.Reserved21);
- DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.reserved22 = 0x{0:X8}", rdb.Reserved22);
- DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.reserved23 = 0x{0:X8}", rdb.Reserved23);
- DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.reserved24 = 0x{0:X8}", rdb.Reserved24);
- DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.reserved25 = 0x{0:X8}", rdb.Reserved25);
+ DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.reserved16 = 0x{0:X8}", rdb.Reserved16);
+ DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.reserved17 = 0x{0:X8}", rdb.Reserved17);
+ DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.reserved18 = 0x{0:X8}", rdb.Reserved18);
+ DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.reserved19 = 0x{0:X8}", rdb.Reserved19);
+ DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.reserved20 = 0x{0:X8}", rdb.Reserved20);
+ DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.reserved21 = 0x{0:X8}", rdb.Reserved21);
+ DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.reserved22 = 0x{0:X8}", rdb.Reserved22);
+ DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.reserved23 = 0x{0:X8}", rdb.Reserved23);
+ DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.reserved24 = 0x{0:X8}", rdb.Reserved24);
+ DicConsole.DebugWriteLine("Amiga RDB plugin", "RDB.reserved25 = 0x{0:X8}", rdb.Reserved25);
ulong nextBlock;
// Reading BadBlock list
List badBlockChain = new List();
- nextBlock = rdb.BadblockPtr;
+ nextBlock = rdb.BadblockPtr;
while(nextBlock != 0xFFFFFFFF)
{
DicConsole.DebugWriteLine("Amiga RDB plugin", "Going to block {0} in search of a BadBlock block",
nextBlock);
- sector = imagePlugin.ReadSector(nextBlock);
+ sector = imagePlugin.ReadSector(nextBlock);
uint magic = BigEndianBitConverter.ToUInt32(sector, 0);
if(magic != BAD_BLOCK_LIST_MAGIC) break;
@@ -463,27 +463,28 @@ namespace DiscImageChef.Partitions
BadBlockList chainEntry = new BadBlockList
{
- Magic = BigEndianBitConverter.ToUInt32(sector, 0x00),
- Size = BigEndianBitConverter.ToUInt32(sector, 0x04),
+ Magic = BigEndianBitConverter.ToUInt32(sector, 0x00),
+ Size = BigEndianBitConverter.ToUInt32(sector, 0x04),
Checksum = BigEndianBitConverter.ToInt32(sector, 0x08),
TargetId = BigEndianBitConverter.ToUInt32(sector, 0x0C),
- NextPtr = BigEndianBitConverter.ToUInt32(sector, 0x10),
+ NextPtr = BigEndianBitConverter.ToUInt32(sector, 0x10),
Reserved = BigEndianBitConverter.ToUInt32(sector, 0x14)
};
- ulong entries = (chainEntry.Size - 6) / 2;
+ ulong entries = (chainEntry.Size - 6) / 2;
chainEntry.BlockPairs = new BadBlockEntry[entries];
DicConsole.DebugWriteLine("Amiga RDB plugin", "chainEntry.magic = 0x{0:X8}", chainEntry.Magic);
DicConsole.DebugWriteLine("Amiga RDB plugin", "chainEntry.size = {0} longs, {1} bytes", chainEntry.Size,
chainEntry.Size * 4);
DicConsole.DebugWriteLine("Amiga RDB plugin", "chainEntry.checksum = 0x{0:X8}", chainEntry.Checksum);
- DicConsole.DebugWriteLine("Amiga RDB plugin", "chainEntry.targetID = {0}", chainEntry.TargetId);
- DicConsole.DebugWriteLine("Amiga RDB plugin", "chainEntry.next_ptr = {0}", chainEntry.NextPtr);
+ DicConsole.DebugWriteLine("Amiga RDB plugin", "chainEntry.targetID = {0}", chainEntry.TargetId);
+ DicConsole.DebugWriteLine("Amiga RDB plugin", "chainEntry.next_ptr = {0}", chainEntry.NextPtr);
DicConsole.DebugWriteLine("Amiga RDB plugin", "chainEntry.reserved = 0x{0:X8}", chainEntry.Reserved);
for(ulong i = 0; i < entries; i++)
{
- chainEntry.BlockPairs[i].BadBlock = BigEndianBitConverter.ToUInt32(sector, (int)(0x18 + i * 8 + 0));
+ chainEntry.BlockPairs[i].BadBlock =
+ BigEndianBitConverter.ToUInt32(sector, (int)(0x18 + i * 8 + 0));
chainEntry.BlockPairs[i].GoodBlock =
BigEndianBitConverter.ToUInt32(sector, (int)(0x18 + i * 8 + 4));
@@ -497,13 +498,13 @@ namespace DiscImageChef.Partitions
// Reading BadBlock list
List partitionEntries = new List();
- nextBlock = rdb.PartitionPtr;
+ nextBlock = rdb.PartitionPtr;
while(nextBlock != 0xFFFFFFFF)
{
DicConsole.DebugWriteLine("Amiga RDB plugin", "Going to block {0} in search of a PartitionEntry block",
nextBlock + sectorOffset);
- sector = imagePlugin.ReadSector(nextBlock + sectorOffset);
+ sector = imagePlugin.ReadSector(nextBlock + sectorOffset);
uint magic = BigEndianBitConverter.ToUInt32(sector, 0);
if(magic != PARTITION_BLOCK_MAGIC) break;
@@ -512,53 +513,53 @@ namespace DiscImageChef.Partitions
PartitionEntry partEntry = new PartitionEntry
{
- Magic = BigEndianBitConverter.ToUInt32(sector, 0x00),
- Size = BigEndianBitConverter.ToUInt32(sector, 0x04),
- Checksum = BigEndianBitConverter.ToInt32(sector, 0x08),
- TargetId = BigEndianBitConverter.ToUInt32(sector, 0x0C),
- NextPtr = BigEndianBitConverter.ToUInt32(sector, 0x10),
- Flags = BigEndianBitConverter.ToUInt32(sector, 0x14),
- Reserved1 = BigEndianBitConverter.ToUInt32(sector, 0x18),
- Reserved2 = BigEndianBitConverter.ToUInt32(sector, 0x1C),
- DevFlags = BigEndianBitConverter.ToUInt32(sector, 0x20),
+ Magic = BigEndianBitConverter.ToUInt32(sector, 0x00),
+ Size = BigEndianBitConverter.ToUInt32(sector, 0x04),
+ Checksum = BigEndianBitConverter.ToInt32(sector, 0x08),
+ TargetId = BigEndianBitConverter.ToUInt32(sector, 0x0C),
+ NextPtr = BigEndianBitConverter.ToUInt32(sector, 0x10),
+ Flags = BigEndianBitConverter.ToUInt32(sector, 0x14),
+ Reserved1 = BigEndianBitConverter.ToUInt32(sector, 0x18),
+ Reserved2 = BigEndianBitConverter.ToUInt32(sector, 0x1C),
+ DevFlags = BigEndianBitConverter.ToUInt32(sector, 0x20),
DriveNameLen = sector[0x24],
- Reserved3 = BigEndianBitConverter.ToUInt32(sector, 0x44),
- Reserved4 = BigEndianBitConverter.ToUInt32(sector, 0x48),
- Reserved5 = BigEndianBitConverter.ToUInt32(sector, 0x4C),
- Reserved6 = BigEndianBitConverter.ToUInt32(sector, 0x50),
- Reserved7 = BigEndianBitConverter.ToUInt32(sector, 0x54),
- Reserved8 = BigEndianBitConverter.ToUInt32(sector, 0x58),
- Reserved9 = BigEndianBitConverter.ToUInt32(sector, 0x5C),
- Reserved10 = BigEndianBitConverter.ToUInt32(sector, 0x60),
- Reserved11 = BigEndianBitConverter.ToUInt32(sector, 0x64),
- Reserved12 = BigEndianBitConverter.ToUInt32(sector, 0x68),
- Reserved13 = BigEndianBitConverter.ToUInt32(sector, 0x6C),
- Reserved14 = BigEndianBitConverter.ToUInt32(sector, 0x70),
- Reserved15 = BigEndianBitConverter.ToUInt32(sector, 0x74),
- Reserved16 = BigEndianBitConverter.ToUInt32(sector, 0x78),
- Reserved17 = BigEndianBitConverter.ToUInt32(sector, 0x7C),
- DosEnvVec = new DosEnvironmentVector
+ Reserved3 = BigEndianBitConverter.ToUInt32(sector, 0x44),
+ Reserved4 = BigEndianBitConverter.ToUInt32(sector, 0x48),
+ Reserved5 = BigEndianBitConverter.ToUInt32(sector, 0x4C),
+ Reserved6 = BigEndianBitConverter.ToUInt32(sector, 0x50),
+ Reserved7 = BigEndianBitConverter.ToUInt32(sector, 0x54),
+ Reserved8 = BigEndianBitConverter.ToUInt32(sector, 0x58),
+ Reserved9 = BigEndianBitConverter.ToUInt32(sector, 0x5C),
+ Reserved10 = BigEndianBitConverter.ToUInt32(sector, 0x60),
+ Reserved11 = BigEndianBitConverter.ToUInt32(sector, 0x64),
+ Reserved12 = BigEndianBitConverter.ToUInt32(sector, 0x68),
+ Reserved13 = BigEndianBitConverter.ToUInt32(sector, 0x6C),
+ Reserved14 = BigEndianBitConverter.ToUInt32(sector, 0x70),
+ Reserved15 = BigEndianBitConverter.ToUInt32(sector, 0x74),
+ Reserved16 = BigEndianBitConverter.ToUInt32(sector, 0x78),
+ Reserved17 = BigEndianBitConverter.ToUInt32(sector, 0x7C),
+ DosEnvVec = new DosEnvironmentVector
{
- Size = BigEndianBitConverter.ToUInt32(sector, 0x80),
- BlockSize = BigEndianBitConverter.ToUInt32(sector, 0x84),
- SecOrg = BigEndianBitConverter.ToUInt32(sector, 0x88),
- Surfaces = BigEndianBitConverter.ToUInt32(sector, 0x8C),
- Spb = BigEndianBitConverter.ToUInt32(sector, 0x90),
- Bpt = BigEndianBitConverter.ToUInt32(sector, 0x94),
+ Size = BigEndianBitConverter.ToUInt32(sector, 0x80),
+ BlockSize = BigEndianBitConverter.ToUInt32(sector, 0x84),
+ SecOrg = BigEndianBitConverter.ToUInt32(sector, 0x88),
+ Surfaces = BigEndianBitConverter.ToUInt32(sector, 0x8C),
+ Spb = BigEndianBitConverter.ToUInt32(sector, 0x90),
+ Bpt = BigEndianBitConverter.ToUInt32(sector, 0x94),
Reservedblocks = BigEndianBitConverter.ToUInt32(sector, 0x98),
- Prealloc = BigEndianBitConverter.ToUInt32(sector, 0x9C),
- Interleave = BigEndianBitConverter.ToUInt32(sector, 0xA0),
- LowCylinder = BigEndianBitConverter.ToUInt32(sector, 0xA4),
- HighCylinder = BigEndianBitConverter.ToUInt32(sector, 0xA8),
- NumBuffer = BigEndianBitConverter.ToUInt32(sector, 0xAC),
- BufMemType = BigEndianBitConverter.ToUInt32(sector, 0xB0),
- MaxTransfer = BigEndianBitConverter.ToUInt32(sector, 0xB4),
- Mask = BigEndianBitConverter.ToUInt32(sector, 0xB8),
- BootPriority = BigEndianBitConverter.ToUInt32(sector, 0xBC),
- DosType = BigEndianBitConverter.ToUInt32(sector, 0xC0),
- Baud = BigEndianBitConverter.ToUInt32(sector, 0xC4),
- Control = BigEndianBitConverter.ToUInt32(sector, 0xC8),
- BootBlocks = BigEndianBitConverter.ToUInt32(sector, 0xCC)
+ Prealloc = BigEndianBitConverter.ToUInt32(sector, 0x9C),
+ Interleave = BigEndianBitConverter.ToUInt32(sector, 0xA0),
+ LowCylinder = BigEndianBitConverter.ToUInt32(sector, 0xA4),
+ HighCylinder = BigEndianBitConverter.ToUInt32(sector, 0xA8),
+ NumBuffer = BigEndianBitConverter.ToUInt32(sector, 0xAC),
+ BufMemType = BigEndianBitConverter.ToUInt32(sector, 0xB0),
+ MaxTransfer = BigEndianBitConverter.ToUInt32(sector, 0xB4),
+ Mask = BigEndianBitConverter.ToUInt32(sector, 0xB8),
+ BootPriority = BigEndianBitConverter.ToUInt32(sector, 0xBC),
+ DosType = BigEndianBitConverter.ToUInt32(sector, 0xC0),
+ Baud = BigEndianBitConverter.ToUInt32(sector, 0xC4),
+ Control = BigEndianBitConverter.ToUInt32(sector, 0xC8),
+ BootBlocks = BigEndianBitConverter.ToUInt32(sector, 0xCC)
}
};
@@ -569,22 +570,23 @@ namespace DiscImageChef.Partitions
DicConsole.DebugWriteLine("Amiga RDB plugin", "partEntry.magic = 0x{0:X8}", partEntry.Magic);
DicConsole.DebugWriteLine("Amiga RDB plugin", "partEntry.size = {0} longs, {1} bytes", partEntry.Size,
partEntry.Size * 4);
- DicConsole.DebugWriteLine("Amiga RDB plugin", "partEntry.checksum = 0x{0:X8}", partEntry.Checksum);
- DicConsole.DebugWriteLine("Amiga RDB plugin", "partEntry.targetID = {0}", partEntry.TargetId);
- DicConsole.DebugWriteLine("Amiga RDB plugin", "partEntry.next_ptr = {0}", partEntry.NextPtr);
- DicConsole.DebugWriteLine("Amiga RDB plugin", "partEntry.flags = 0x{0:X8}", partEntry.Flags);
+ DicConsole.DebugWriteLine("Amiga RDB plugin", "partEntry.checksum = 0x{0:X8}", partEntry.Checksum);
+ DicConsole.DebugWriteLine("Amiga RDB plugin", "partEntry.targetID = {0}", partEntry.TargetId);
+ DicConsole.DebugWriteLine("Amiga RDB plugin", "partEntry.next_ptr = {0}", partEntry.NextPtr);
+ DicConsole.DebugWriteLine("Amiga RDB plugin", "partEntry.flags = 0x{0:X8}", partEntry.Flags);
DicConsole.DebugWriteLine("Amiga RDB plugin", "partEntry.reserved1 = 0x{0:X8}", partEntry.Reserved1);
DicConsole.DebugWriteLine("Amiga RDB plugin", "partEntry.reserved2 = 0x{0:X8}", partEntry.Reserved2);
- DicConsole.DebugWriteLine("Amiga RDB plugin", "partEntry.devFlags = 0x{0:X8}", partEntry.DevFlags);
- DicConsole.DebugWriteLine("Amiga RDB plugin", "partEntry.driveNameLen = {0}", partEntry.DriveNameLen);
- DicConsole.DebugWriteLine("Amiga RDB plugin", "partEntry.driveName = \"{0}\"", partEntry.DriveName);
- DicConsole.DebugWriteLine("Amiga RDB plugin", "partEntry.reserved3 = 0x{0:X8}", partEntry.Reserved3);
- DicConsole.DebugWriteLine("Amiga RDB plugin", "partEntry.reserved4 = 0x{0:X8}", partEntry.Reserved4);
- DicConsole.DebugWriteLine("Amiga RDB plugin", "partEntry.reserved5 = 0x{0:X8}", partEntry.Reserved5);
- DicConsole.DebugWriteLine("Amiga RDB plugin", "partEntry.reserved6 = 0x{0:X8}", partEntry.Reserved6);
- DicConsole.DebugWriteLine("Amiga RDB plugin", "partEntry.reserved7 = 0x{0:X8}", partEntry.Reserved7);
- DicConsole.DebugWriteLine("Amiga RDB plugin", "partEntry.reserved8 = 0x{0:X8}", partEntry.Reserved8);
- DicConsole.DebugWriteLine("Amiga RDB plugin", "partEntry.reserved9 = 0x{0:X8}", partEntry.Reserved9);
+ DicConsole.DebugWriteLine("Amiga RDB plugin", "partEntry.devFlags = 0x{0:X8}", partEntry.DevFlags);
+ DicConsole.DebugWriteLine("Amiga RDB plugin", "partEntry.driveNameLen = {0}",
+ partEntry.DriveNameLen);
+ DicConsole.DebugWriteLine("Amiga RDB plugin", "partEntry.driveName = \"{0}\"", partEntry.DriveName);
+ DicConsole.DebugWriteLine("Amiga RDB plugin", "partEntry.reserved3 = 0x{0:X8}", partEntry.Reserved3);
+ DicConsole.DebugWriteLine("Amiga RDB plugin", "partEntry.reserved4 = 0x{0:X8}", partEntry.Reserved4);
+ DicConsole.DebugWriteLine("Amiga RDB plugin", "partEntry.reserved5 = 0x{0:X8}", partEntry.Reserved5);
+ DicConsole.DebugWriteLine("Amiga RDB plugin", "partEntry.reserved6 = 0x{0:X8}", partEntry.Reserved6);
+ DicConsole.DebugWriteLine("Amiga RDB plugin", "partEntry.reserved7 = 0x{0:X8}", partEntry.Reserved7);
+ DicConsole.DebugWriteLine("Amiga RDB plugin", "partEntry.reserved8 = 0x{0:X8}", partEntry.Reserved8);
+ DicConsole.DebugWriteLine("Amiga RDB plugin", "partEntry.reserved9 = 0x{0:X8}", partEntry.Reserved9);
DicConsole.DebugWriteLine("Amiga RDB plugin", "partEntry.reserved10 = 0x{0:X8}", partEntry.Reserved10);
DicConsole.DebugWriteLine("Amiga RDB plugin", "partEntry.reserved11 = 0x{0:X8}", partEntry.Reserved11);
DicConsole.DebugWriteLine("Amiga RDB plugin", "partEntry.reserved12 = 0x{0:X8}", partEntry.Reserved12);
@@ -638,15 +640,15 @@ namespace DiscImageChef.Partitions
}
// Reading BadBlock list
- List fshdEntries = new List();
- List segmentEntries = new List();
- nextBlock = rdb.FsheaderPtr;
+ List fshdEntries = new List();
+ List segmentEntries = new List();
+ nextBlock = rdb.FsheaderPtr;
while(nextBlock != 0xFFFFFFFF)
{
DicConsole.DebugWriteLine("Amiga RDB plugin",
"Going to block {0} in search of a FileSystemHeader block", nextBlock);
- sector = imagePlugin.ReadSector(nextBlock);
+ sector = imagePlugin.ReadSector(nextBlock);
uint magic = BigEndianBitConverter.ToUInt32(sector, 0);
if(magic != FILESYSTEM_HEADER_MAGIC) break;
@@ -655,65 +657,66 @@ namespace DiscImageChef.Partitions
FileSystemHeader fshd = new FileSystemHeader
{
- Magic = BigEndianBitConverter.ToUInt32(sector, 0x00),
- Size = BigEndianBitConverter.ToUInt32(sector, 0x04),
- Checksum = BigEndianBitConverter.ToInt32(sector, 0x08),
- TargetId = BigEndianBitConverter.ToUInt32(sector, 0x0C),
- NextPtr = BigEndianBitConverter.ToUInt32(sector, 0x10),
- Flags = BigEndianBitConverter.ToUInt32(sector, 0x14),
- Reserved1 = BigEndianBitConverter.ToUInt32(sector, 0x18),
- Reserved2 = BigEndianBitConverter.ToUInt32(sector, 0x1C),
- DosType = BigEndianBitConverter.ToUInt32(sector, 0x20),
- Version = BigEndianBitConverter.ToUInt32(sector, 0x24),
+ Magic = BigEndianBitConverter.ToUInt32(sector, 0x00),
+ Size = BigEndianBitConverter.ToUInt32(sector, 0x04),
+ Checksum = BigEndianBitConverter.ToInt32(sector, 0x08),
+ TargetId = BigEndianBitConverter.ToUInt32(sector, 0x0C),
+ NextPtr = BigEndianBitConverter.ToUInt32(sector, 0x10),
+ Flags = BigEndianBitConverter.ToUInt32(sector, 0x14),
+ Reserved1 = BigEndianBitConverter.ToUInt32(sector, 0x18),
+ Reserved2 = BigEndianBitConverter.ToUInt32(sector, 0x1C),
+ DosType = BigEndianBitConverter.ToUInt32(sector, 0x20),
+ Version = BigEndianBitConverter.ToUInt32(sector, 0x24),
PatchFlags = BigEndianBitConverter.ToUInt32(sector, 0x28),
- Dnode = new DeviceNode
+ Dnode = new DeviceNode
{
- Type = BigEndianBitConverter.ToUInt32(sector, 0x2C),
- Task = BigEndianBitConverter.ToUInt32(sector, 0x30),
- Locked = BigEndianBitConverter.ToUInt32(sector, 0x34),
- Handler = BigEndianBitConverter.ToUInt32(sector, 0x38),
- StackSize = BigEndianBitConverter.ToUInt32(sector, 0x3C),
- Priority = BigEndianBitConverter.ToUInt32(sector, 0x40),
- Startup = BigEndianBitConverter.ToUInt32(sector, 0x44),
+ Type = BigEndianBitConverter.ToUInt32(sector, 0x2C),
+ Task = BigEndianBitConverter.ToUInt32(sector, 0x30),
+ Locked = BigEndianBitConverter.ToUInt32(sector, 0x34),
+ Handler = BigEndianBitConverter.ToUInt32(sector, 0x38),
+ StackSize = BigEndianBitConverter.ToUInt32(sector, 0x3C),
+ Priority = BigEndianBitConverter.ToUInt32(sector, 0x40),
+ Startup = BigEndianBitConverter.ToUInt32(sector, 0x44),
SeglistPtr = BigEndianBitConverter.ToUInt32(sector, 0x48),
- GlobalVec = BigEndianBitConverter.ToUInt32(sector, 0x4C)
+ GlobalVec = BigEndianBitConverter.ToUInt32(sector, 0x4C)
}
};
DicConsole.DebugWriteLine("Amiga RDB plugin", "FSHD.magic = 0x{0:X8}", fshd.Magic);
DicConsole.DebugWriteLine("Amiga RDB plugin", "FSHD.size = {0} longs, {1} bytes", fshd.Size,
fshd.Size * 4);
- DicConsole.DebugWriteLine("Amiga RDB plugin", "FSHD.checksum = 0x{0:X8}", fshd.Checksum);
- DicConsole.DebugWriteLine("Amiga RDB plugin", "FSHD.targetID = {0}", fshd.TargetId);
- DicConsole.DebugWriteLine("Amiga RDB plugin", "FSHD.next_ptr = {0}", fshd.NextPtr);
- DicConsole.DebugWriteLine("Amiga RDB plugin", "FSHD.flags = 0x{0:X8}", fshd.Flags);
+ DicConsole.DebugWriteLine("Amiga RDB plugin", "FSHD.checksum = 0x{0:X8}", fshd.Checksum);
+ DicConsole.DebugWriteLine("Amiga RDB plugin", "FSHD.targetID = {0}", fshd.TargetId);
+ DicConsole.DebugWriteLine("Amiga RDB plugin", "FSHD.next_ptr = {0}", fshd.NextPtr);
+ DicConsole.DebugWriteLine("Amiga RDB plugin", "FSHD.flags = 0x{0:X8}", fshd.Flags);
DicConsole.DebugWriteLine("Amiga RDB plugin", "FSHD.reserved1 = 0x{0:X8}", fshd.Reserved1);
DicConsole.DebugWriteLine("Amiga RDB plugin", "FSHD.reserved2 = 0x{0:X8}", fshd.Reserved2);
- DicConsole.DebugWriteLine("Amiga RDB plugin", "FSHD.dosType = {0}", AmigaDosTypeToString(fshd.DosType));
+ DicConsole.DebugWriteLine("Amiga RDB plugin", "FSHD.dosType = {0}",
+ AmigaDosTypeToString(fshd.DosType));
DicConsole.DebugWriteLine("Amiga RDB plugin", "FSHD.version = {0:D2}.{1:D2} (0x{2:X8})",
(fshd.Version & 0xFFFF0000) >> 16, fshd.Version & 0xFFFF, fshd.Version);
DicConsole.DebugWriteLine("Amiga RDB plugin", "FSHD.patchFlags = 0x{0:X8}", fshd.PatchFlags);
- DicConsole.DebugWriteLine("Amiga RDB plugin", "FSHD.dnode.type = {0}", fshd.Dnode.Type);
- DicConsole.DebugWriteLine("Amiga RDB plugin", "FSHD.dnode.task = {0}", fshd.Dnode.Task);
- DicConsole.DebugWriteLine("Amiga RDB plugin", "FSHD.dnode.locked = {0}", fshd.Dnode.Locked);
- DicConsole.DebugWriteLine("Amiga RDB plugin", "FSHD.dnode.handler = {0}", fshd.Dnode.Handler);
+ DicConsole.DebugWriteLine("Amiga RDB plugin", "FSHD.dnode.type = {0}", fshd.Dnode.Type);
+ DicConsole.DebugWriteLine("Amiga RDB plugin", "FSHD.dnode.task = {0}", fshd.Dnode.Task);
+ DicConsole.DebugWriteLine("Amiga RDB plugin", "FSHD.dnode.locked = {0}", fshd.Dnode.Locked);
+ DicConsole.DebugWriteLine("Amiga RDB plugin", "FSHD.dnode.handler = {0}", fshd.Dnode.Handler);
DicConsole.DebugWriteLine("Amiga RDB plugin", "FSHD.dnode.stackSize = {0}", fshd.Dnode.StackSize);
- DicConsole.DebugWriteLine("Amiga RDB plugin", "FSHD.dnode.priority = {0}", fshd.Dnode.Priority);
- DicConsole.DebugWriteLine("Amiga RDB plugin", "FSHD.dnode.startup = {0}", fshd.Dnode.Startup);
- DicConsole.DebugWriteLine("Amiga RDB plugin", "FSHD.dnode.seglist_ptr = {0}", fshd.Dnode.SeglistPtr);
+ DicConsole.DebugWriteLine("Amiga RDB plugin", "FSHD.dnode.priority = {0}", fshd.Dnode.Priority);
+ DicConsole.DebugWriteLine("Amiga RDB plugin", "FSHD.dnode.startup = {0}", fshd.Dnode.Startup);
+ DicConsole.DebugWriteLine("Amiga RDB plugin", "FSHD.dnode.seglist_ptr = {0}",
+ fshd.Dnode.SeglistPtr);
DicConsole.DebugWriteLine("Amiga RDB plugin", "FSHD.dnode.global_vec = 0x{0:X8}", fshd.Dnode.GlobalVec);
- nextBlock = fshd.Dnode.SeglistPtr;
- bool thereAreLoadSegments = false;
- Sha1Context sha1Ctx = new Sha1Context();
- sha1Ctx.Init();
+ nextBlock = fshd.Dnode.SeglistPtr;
+ bool thereAreLoadSegments = false;
+ Sha1Context sha1Ctx = new Sha1Context();
while(nextBlock != 0xFFFFFFFF)
{
DicConsole.DebugWriteLine("Amiga RDB plugin", "Going to block {0} in search of a LoadSegment block",
nextBlock);
- sector = imagePlugin.ReadSector(nextBlock);
+ sector = imagePlugin.ReadSector(nextBlock);
uint magicSeg = BigEndianBitConverter.ToUInt32(sector, 0);
if(magicSeg != LOAD_SEG_MAGIC) break;
@@ -721,23 +724,23 @@ namespace DiscImageChef.Partitions
DicConsole.DebugWriteLine("Amiga RDB plugin", "Found LoadSegment block");
thereAreLoadSegments = true;
- LoadSegment loadSeg = new LoadSegment
+ LoadSegment loadSeg = new LoadSegment
{
- Magic = BigEndianBitConverter.ToUInt32(sector, 0x00),
- Size = BigEndianBitConverter.ToUInt32(sector, 0x04),
+ Magic = BigEndianBitConverter.ToUInt32(sector, 0x00),
+ Size = BigEndianBitConverter.ToUInt32(sector, 0x04),
Checksum = BigEndianBitConverter.ToInt32(sector, 0x08),
TargetId = BigEndianBitConverter.ToUInt32(sector, 0x0C),
- NextPtr = BigEndianBitConverter.ToUInt32(sector, 0x10)
+ NextPtr = BigEndianBitConverter.ToUInt32(sector, 0x10)
};
- loadSeg.LoadData = new byte[(loadSeg.Size - 5) * 4];
+ loadSeg.LoadData = new byte[(loadSeg.Size - 5) * 4];
Array.Copy(sector, 0x14, loadSeg.LoadData, 0, (loadSeg.Size - 5) * 4);
DicConsole.DebugWriteLine("Amiga RDB plugin", "loadSeg.magic = 0x{0:X8}", loadSeg.Magic);
DicConsole.DebugWriteLine("Amiga RDB plugin", "loadSeg.size = {0} longs, {1} bytes", loadSeg.Size,
loadSeg.Size * 4);
DicConsole.DebugWriteLine("Amiga RDB plugin", "loadSeg.checksum = 0x{0:X8}", loadSeg.Checksum);
- DicConsole.DebugWriteLine("Amiga RDB plugin", "loadSeg.targetID = {0}", loadSeg.TargetId);
- DicConsole.DebugWriteLine("Amiga RDB plugin", "loadSeg.next_ptr = {0}", loadSeg.NextPtr);
+ DicConsole.DebugWriteLine("Amiga RDB plugin", "loadSeg.targetID = {0}", loadSeg.TargetId);
+ DicConsole.DebugWriteLine("Amiga RDB plugin", "loadSeg.next_ptr = {0}", loadSeg.NextPtr);
segmentEntries.Add(loadSeg);
nextBlock = loadSeg.NextPtr;
@@ -759,21 +762,23 @@ namespace DiscImageChef.Partitions
foreach(Partition entry in partitionEntries.Select(rdbEntry => new Partition
{
Description = AmigaDosTypeToDescriptionString(rdbEntry.DosEnvVec.DosType),
- Name = rdbEntry.DriveName,
- Sequence = sequence,
- Length =
+ Name = rdbEntry.DriveName,
+ Sequence = sequence,
+ Length =
(rdbEntry.DosEnvVec.HighCylinder + 1 - rdbEntry.DosEnvVec.LowCylinder) *
- rdbEntry.DosEnvVec.Surfaces * rdbEntry.DosEnvVec.Bpt,
+ rdbEntry.DosEnvVec.Surfaces * rdbEntry.DosEnvVec.Bpt,
Start =
rdbEntry.DosEnvVec.LowCylinder * rdbEntry.DosEnvVec.Surfaces * rdbEntry.DosEnvVec.Bpt +
sectorOffset,
- Type = AmigaDosTypeToString(rdbEntry.DosEnvVec.DosType),
+ Type = AmigaDosTypeToString(rdbEntry.DosEnvVec.DosType),
Scheme = Name,
Offset =
- (rdbEntry.DosEnvVec.LowCylinder * rdbEntry.DosEnvVec.Surfaces * rdbEntry.DosEnvVec.Bpt +
- sectorOffset) * rdb.BlockSize,
+ (rdbEntry.DosEnvVec.LowCylinder *
+ rdbEntry.DosEnvVec.Surfaces * rdbEntry.DosEnvVec.Bpt +
+ sectorOffset) * rdb.BlockSize,
Size = (rdbEntry.DosEnvVec.HighCylinder + 1 - rdbEntry.DosEnvVec.LowCylinder) *
- rdbEntry.DosEnvVec.Surfaces * rdbEntry.DosEnvVec.Bpt * rdb.BlockSize
+ rdbEntry.DosEnvVec.Surfaces * rdbEntry.DosEnvVec.Bpt *
+ rdb.BlockSize
}))
{
partitions.Add(entry);
@@ -787,28 +792,28 @@ namespace DiscImageChef.Partitions
{
switch(amigaDosType)
{
- case TYPEID_OFS: return "Amiga Original File System";
- case TYPEID_FFS: return "Amiga Fast File System";
- case TYPEID_OFS_INTL: return "Amiga Original File System with international characters";
- case TYPEID_FFS_INTL: return "Amiga Fast File System with international characters";
- case TYPEID_OFS_CACHE: return "Amiga Original File System with directory cache";
- case TYPEID_FFS_CACHE: return "Amiga Fast File System with directory cache";
- case TYPEID_OFS2: return "Amiga Original File System with long filenames";
- case TYPEID_FFS2: return "Amiga Fast File System with long filenames";
- case TYPEID_AMIX_SYSV: return "Amiga UNIX System V filesystem";
- case TYPEID_AMIX_BOOT: return "Amiga UNIX boot filesystem";
- case TYPEID_AMIX_FFS: return "Amiga UNIX BSD filesystem";
+ case TYPEID_OFS: return "Amiga Original File System";
+ case TYPEID_FFS: return "Amiga Fast File System";
+ case TYPEID_OFS_INTL: return "Amiga Original File System with international characters";
+ case TYPEID_FFS_INTL: return "Amiga Fast File System with international characters";
+ case TYPEID_OFS_CACHE: return "Amiga Original File System with directory cache";
+ case TYPEID_FFS_CACHE: return "Amiga Fast File System with directory cache";
+ case TYPEID_OFS2: return "Amiga Original File System with long filenames";
+ case TYPEID_FFS2: return "Amiga Fast File System with long filenames";
+ case TYPEID_AMIX_SYSV: return "Amiga UNIX System V filesystem";
+ case TYPEID_AMIX_BOOT: return "Amiga UNIX boot filesystem";
+ case TYPEID_AMIX_FFS: return "Amiga UNIX BSD filesystem";
case TYPEID_AMIX_RESERVED: return "Amiga UNIX Reserved partition (swap)";
case TYPEID_PFS:
case TYPEID_PFS2:
case TYPEID_PFS_MUSER:
- case TYPEID_AFS: return "ProfessionalFileSystem";
- case TYPEID_SFS: return "SmartFileSystem v1";
- case TYPEID_SFS2: return "SmartFileSystem v2";
- case TYPEID_JXFS: return "JXFS";
+ case TYPEID_AFS: return "ProfessionalFileSystem";
+ case TYPEID_SFS: return "SmartFileSystem v1";
+ case TYPEID_SFS2: return "SmartFileSystem v2";
+ case TYPEID_JXFS: return "JXFS";
case TYPEID_CROSS_DOS: return "FAT, as set by CrossDOS";
case TYPEID_CROSS_MAC: return "HFS, as set by CrossMac";
- case TYPEID_BFFS: return "4.2UFS, for BFFS";
+ case TYPEID_BFFS: return "4.2UFS, for BFFS";
case TYPEID_OFS_MUSER: return "Amiga Original File System with multi-user patches";
case TYPEID_FFS_MUSER: return "Amiga Fast File System with multi-user patches";
case TYPEID_OFS_INTL_MUSER:
@@ -819,19 +824,19 @@ namespace DiscImageChef.Partitions
return "Amiga Original File System with directory cache and multi-user patches";
case TYPEID_FFS_CACHE_MUSER:
return "Amiga Fast File System with directory cache and multi-user patches";
- case TYPEID_OLD_BSD_UNUSED: return "BSD unused";
- case TYPEID_OLD_BSD_SWAP: return "BSD swap";
- case TYPEID_OLD_BSD42_FFS: return "BSD 4.2 FFS";
- case TYPEID_OLD_BSD44_LFS: return "BSD 4.4 LFS";
+ case TYPEID_OLD_BSD_UNUSED: return "BSD unused";
+ case TYPEID_OLD_BSD_SWAP: return "BSD swap";
+ case TYPEID_OLD_BSD42_FFS: return "BSD 4.2 FFS";
+ case TYPEID_OLD_BSD44_LFS: return "BSD 4.4 LFS";
case TYPEID_NETBSD_ROOT_UNUSED: return "NetBSD unused root partition";
- case TYPEID_NETBSD_ROOT_42FFS: return "NetBSD 4.2 FFS root partition";
- case TYPEID_NETBSD_ROOT_44LFS: return "NetBSD 4.4 LFS root partition";
+ case TYPEID_NETBSD_ROOT_42FFS: return "NetBSD 4.2 FFS root partition";
+ case TYPEID_NETBSD_ROOT_44LFS: return "NetBSD 4.4 LFS root partition";
case TYPEID_NETBSD_USER_UNUSED: return "NetBSD unused user partition";
- case TYPEID_NETBSD_USER_42FFS: return "NetBSD 4.2 FFS user partition";
- case TYPEID_NETBSD_USER_44LFS: return "NetBSD 4.4 LFS user partition";
- case TYPEID_NETBSD_SWAP: return "NetBSD swap partition";
- case TYPEID_LINUX: return "Linux filesystem partition";
- case TYPEID_LINUX_SWAP: return "Linux swap partition";
+ case TYPEID_NETBSD_USER_42FFS: return "NetBSD 4.2 FFS user partition";
+ case TYPEID_NETBSD_USER_44LFS: return "NetBSD 4.4 LFS user partition";
+ case TYPEID_NETBSD_SWAP: return "NetBSD swap partition";
+ case TYPEID_LINUX: return "Linux filesystem partition";
+ case TYPEID_LINUX_SWAP: return "Linux swap partition";
case TYPEID_RAID_FRAME:
case TYPEID_RAID_FRAME0: return "RaidFrame partition";
@@ -864,7 +869,7 @@ namespace DiscImageChef.Partitions
if((amigaDosType & TYPEID_NETBSD_SWAP) == TYPEID_NETBSD_SWAP)
return $"Unknown NetBSD swap filesystem type {AmigaDosTypeToString(amigaDosType)}";
- if((amigaDosType & TYPEID_LINUX) == TYPEID_LINUX ||
+ if((amigaDosType & TYPEID_LINUX) == TYPEID_LINUX ||
(amigaDosType & TYPEID_LINUX_SWAP) == TYPEID_LINUX_SWAP)
return $"Unknown Linux filesystem type {AmigaDosTypeToString(amigaDosType)}";
diff --git a/DiscImageChef.Tests/Checksums/Adler32.cs b/DiscImageChef.Tests/Checksums/Adler32.cs
index 88101d15..ea726ead 100644
--- a/DiscImageChef.Tests/Checksums/Adler32.cs
+++ b/DiscImageChef.Tests/Checksums/Adler32.cs
@@ -35,7 +35,7 @@ namespace DiscImageChef.Tests.Checksums
[TestFixture]
public class Adler32
{
- static readonly byte[] ExpectedEmpty = {0x00, 0xf0, 0x00, 0x01};
+ static readonly byte[] ExpectedEmpty = {0x00, 0xf0, 0x00, 0x01};
static readonly byte[] ExpectedRandom = {0x37, 0x28, 0xd1, 0x86};
[Test]
@@ -48,9 +48,9 @@ namespace DiscImageChef.Tests.Checksums
[Test]
public void Adler32EmptyData()
{
- byte[] data = new byte[1048576];
- FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "empty"), FileMode.Open,
- FileAccess.Read);
+ byte[] data = new byte[1048576];
+ FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "empty"), FileMode.Open,
+ FileAccess.Read);
fs.Read(data, 0, 1048576);
fs.Close();
fs.Dispose();
@@ -61,14 +61,13 @@ namespace DiscImageChef.Tests.Checksums
[Test]
public void Adler32EmptyInstance()
{
- byte[] data = new byte[1048576];
- FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "empty"), FileMode.Open,
- FileAccess.Read);
+ byte[] data = new byte[1048576];
+ FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "empty"), FileMode.Open,
+ FileAccess.Read);
fs.Read(data, 0, 1048576);
fs.Close();
fs.Dispose();
IChecksum ctx = new Adler32Context();
- ctx.Init();
ctx.Update(data);
byte[] result = ctx.Final();
Assert.AreEqual(ExpectedEmpty, result);
@@ -84,9 +83,9 @@ namespace DiscImageChef.Tests.Checksums
[Test]
public void Adler32RandomData()
{
- byte[] data = new byte[1048576];
- FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "random"), FileMode.Open,
- FileAccess.Read);
+ byte[] data = new byte[1048576];
+ FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "random"), FileMode.Open,
+ FileAccess.Read);
fs.Read(data, 0, 1048576);
fs.Close();
fs.Dispose();
@@ -97,14 +96,13 @@ namespace DiscImageChef.Tests.Checksums
[Test]
public void Adler32RandomInstance()
{
- byte[] data = new byte[1048576];
- FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "random"), FileMode.Open,
- FileAccess.Read);
+ byte[] data = new byte[1048576];
+ FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "random"), FileMode.Open,
+ FileAccess.Read);
fs.Read(data, 0, 1048576);
fs.Close();
fs.Dispose();
IChecksum ctx = new Adler32Context();
- ctx.Init();
ctx.Update(data);
byte[] result = ctx.Final();
Assert.AreEqual(ExpectedRandom, result);
diff --git a/DiscImageChef.Tests/Checksums/CRC16.cs b/DiscImageChef.Tests/Checksums/CRC16.cs
index a7a1bda2..e3f64814 100644
--- a/DiscImageChef.Tests/Checksums/CRC16.cs
+++ b/DiscImageChef.Tests/Checksums/CRC16.cs
@@ -35,7 +35,7 @@ namespace DiscImageChef.Tests.Checksums
[TestFixture]
public class Crc16
{
- static readonly byte[] ExpectedEmpty = {0x00, 0x00};
+ static readonly byte[] ExpectedEmpty = {0x00, 0x00};
static readonly byte[] ExpectedRandom = {0x2d, 0x6d};
[Test]
@@ -48,9 +48,9 @@ namespace DiscImageChef.Tests.Checksums
[Test]
public void Crc16EmptyData()
{
- byte[] data = new byte[1048576];
- FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "empty"), FileMode.Open,
- FileAccess.Read);
+ byte[] data = new byte[1048576];
+ FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "empty"), FileMode.Open,
+ FileAccess.Read);
fs.Read(data, 0, 1048576);
fs.Close();
fs.Dispose();
@@ -61,14 +61,13 @@ namespace DiscImageChef.Tests.Checksums
[Test]
public void Crc16EmptyInstance()
{
- byte[] data = new byte[1048576];
- FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "empty"), FileMode.Open,
- FileAccess.Read);
+ byte[] data = new byte[1048576];
+ FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "empty"), FileMode.Open,
+ FileAccess.Read);
fs.Read(data, 0, 1048576);
fs.Close();
fs.Dispose();
IChecksum ctx = new Crc16Context();
- ctx.Init();
ctx.Update(data);
byte[] result = ctx.Final();
Assert.AreEqual(ExpectedEmpty, result);
@@ -84,9 +83,9 @@ namespace DiscImageChef.Tests.Checksums
[Test]
public void Crc16RandomData()
{
- byte[] data = new byte[1048576];
- FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "random"), FileMode.Open,
- FileAccess.Read);
+ byte[] data = new byte[1048576];
+ FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "random"), FileMode.Open,
+ FileAccess.Read);
fs.Read(data, 0, 1048576);
fs.Close();
fs.Dispose();
@@ -97,14 +96,13 @@ namespace DiscImageChef.Tests.Checksums
[Test]
public void Crc16RandomInstance()
{
- byte[] data = new byte[1048576];
- FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "random"), FileMode.Open,
- FileAccess.Read);
+ byte[] data = new byte[1048576];
+ FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "random"), FileMode.Open,
+ FileAccess.Read);
fs.Read(data, 0, 1048576);
fs.Close();
fs.Dispose();
IChecksum ctx = new Crc16Context();
- ctx.Init();
ctx.Update(data);
byte[] result = ctx.Final();
Assert.AreEqual(ExpectedRandom, result);
diff --git a/DiscImageChef.Tests/Checksums/CRC32.cs b/DiscImageChef.Tests/Checksums/CRC32.cs
index 6c11746c..a941f2ad 100644
--- a/DiscImageChef.Tests/Checksums/CRC32.cs
+++ b/DiscImageChef.Tests/Checksums/CRC32.cs
@@ -35,7 +35,7 @@ namespace DiscImageChef.Tests.Checksums
[TestFixture]
public class Crc32
{
- static readonly byte[] ExpectedEmpty = {0xa7, 0x38, 0xea, 0x1c};
+ static readonly byte[] ExpectedEmpty = {0xa7, 0x38, 0xea, 0x1c};
static readonly byte[] ExpectedRandom = {0x2b, 0x6e, 0x68, 0x54};
[Test]
@@ -48,9 +48,9 @@ namespace DiscImageChef.Tests.Checksums
[Test]
public void Crc32EmptyData()
{
- byte[] data = new byte[1048576];
- FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "empty"), FileMode.Open,
- FileAccess.Read);
+ byte[] data = new byte[1048576];
+ FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "empty"), FileMode.Open,
+ FileAccess.Read);
fs.Read(data, 0, 1048576);
fs.Close();
fs.Dispose();
@@ -61,14 +61,13 @@ namespace DiscImageChef.Tests.Checksums
[Test]
public void Crc32EmptyInstance()
{
- byte[] data = new byte[1048576];
- FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "empty"), FileMode.Open,
- FileAccess.Read);
+ byte[] data = new byte[1048576];
+ FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "empty"), FileMode.Open,
+ FileAccess.Read);
fs.Read(data, 0, 1048576);
fs.Close();
fs.Dispose();
IChecksum ctx = new Crc32Context();
- ctx.Init();
ctx.Update(data);
byte[] result = ctx.Final();
Assert.AreEqual(ExpectedEmpty, result);
@@ -84,9 +83,9 @@ namespace DiscImageChef.Tests.Checksums
[Test]
public void Crc32RandomData()
{
- byte[] data = new byte[1048576];
- FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "random"), FileMode.Open,
- FileAccess.Read);
+ byte[] data = new byte[1048576];
+ FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "random"), FileMode.Open,
+ FileAccess.Read);
fs.Read(data, 0, 1048576);
fs.Close();
fs.Dispose();
@@ -97,14 +96,13 @@ namespace DiscImageChef.Tests.Checksums
[Test]
public void Crc32RandomInstance()
{
- byte[] data = new byte[1048576];
- FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "random"), FileMode.Open,
- FileAccess.Read);
+ byte[] data = new byte[1048576];
+ FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "random"), FileMode.Open,
+ FileAccess.Read);
fs.Read(data, 0, 1048576);
fs.Close();
fs.Dispose();
IChecksum ctx = new Crc32Context();
- ctx.Init();
ctx.Update(data);
byte[] result = ctx.Final();
Assert.AreEqual(ExpectedRandom, result);
diff --git a/DiscImageChef.Tests/Checksums/CRC64.cs b/DiscImageChef.Tests/Checksums/CRC64.cs
index 4c4aab1d..2a7e2cc3 100644
--- a/DiscImageChef.Tests/Checksums/CRC64.cs
+++ b/DiscImageChef.Tests/Checksums/CRC64.cs
@@ -35,7 +35,7 @@ namespace DiscImageChef.Tests.Checksums
[TestFixture]
public class Crc64
{
- static readonly byte[] ExpectedEmpty = {0x60, 0x6b, 0x70, 0xa2, 0x3e, 0xba, 0xf6, 0xc2};
+ static readonly byte[] ExpectedEmpty = {0x60, 0x6b, 0x70, 0xa2, 0x3e, 0xba, 0xf6, 0xc2};
static readonly byte[] ExpectedRandom = {0xbf, 0x09, 0x99, 0x2c, 0xc5, 0xed, 0xe3, 0x8e};
[Test]
@@ -48,9 +48,9 @@ namespace DiscImageChef.Tests.Checksums
[Test]
public void Crc64EmptyData()
{
- byte[] data = new byte[1048576];
- FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "empty"), FileMode.Open,
- FileAccess.Read);
+ byte[] data = new byte[1048576];
+ FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "empty"), FileMode.Open,
+ FileAccess.Read);
fs.Read(data, 0, 1048576);
fs.Close();
fs.Dispose();
@@ -61,14 +61,13 @@ namespace DiscImageChef.Tests.Checksums
[Test]
public void Crc64EmptyInstance()
{
- byte[] data = new byte[1048576];
- FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "empty"), FileMode.Open,
- FileAccess.Read);
+ byte[] data = new byte[1048576];
+ FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "empty"), FileMode.Open,
+ FileAccess.Read);
fs.Read(data, 0, 1048576);
fs.Close();
fs.Dispose();
IChecksum ctx = new Crc64Context();
- ctx.Init();
ctx.Update(data);
byte[] result = ctx.Final();
Assert.AreEqual(ExpectedEmpty, result);
@@ -84,9 +83,9 @@ namespace DiscImageChef.Tests.Checksums
[Test]
public void Crc64RandomData()
{
- byte[] data = new byte[1048576];
- FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "random"), FileMode.Open,
- FileAccess.Read);
+ byte[] data = new byte[1048576];
+ FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "random"), FileMode.Open,
+ FileAccess.Read);
fs.Read(data, 0, 1048576);
fs.Close();
fs.Dispose();
@@ -97,14 +96,13 @@ namespace DiscImageChef.Tests.Checksums
[Test]
public void Crc64RandomInstance()
{
- byte[] data = new byte[1048576];
- FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "random"), FileMode.Open,
- FileAccess.Read);
+ byte[] data = new byte[1048576];
+ FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "random"), FileMode.Open,
+ FileAccess.Read);
fs.Read(data, 0, 1048576);
fs.Close();
fs.Dispose();
IChecksum ctx = new Crc64Context();
- ctx.Init();
ctx.Update(data);
byte[] result = ctx.Final();
Assert.AreEqual(ExpectedRandom, result);
diff --git a/DiscImageChef.Tests/Checksums/MD5.cs b/DiscImageChef.Tests/Checksums/MD5.cs
index ba9bd6f0..291b7e2d 100644
--- a/DiscImageChef.Tests/Checksums/MD5.cs
+++ b/DiscImageChef.Tests/Checksums/MD5.cs
@@ -43,23 +43,21 @@ namespace DiscImageChef.Tests.Checksums
[Test]
public void Md5EmptyFile()
{
- Md5Context ctx = new Md5Context();
- ctx.Init();
- byte[] result = ctx.File(Path.Combine(Consts.TestFilesRoot, "checksums", "empty"));
+ Md5Context ctx = new Md5Context();
+ byte[] result = ctx.File(Path.Combine(Consts.TestFilesRoot, "checksums", "empty"));
Assert.AreEqual(ExpectedEmpty, result);
}
[Test]
public void Md5EmptyData()
{
- byte[] data = new byte[1048576];
- FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "empty"), FileMode.Open,
- FileAccess.Read);
+ byte[] data = new byte[1048576];
+ FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "empty"), FileMode.Open,
+ FileAccess.Read);
fs.Read(data, 0, 1048576);
fs.Close();
fs.Dispose();
Md5Context ctx = new Md5Context();
- ctx.Init();
ctx.Data(data, out byte[] result);
Assert.AreEqual(ExpectedEmpty, result);
}
@@ -67,14 +65,13 @@ namespace DiscImageChef.Tests.Checksums
[Test]
public void Md5EmptyInstance()
{
- byte[] data = new byte[1048576];
- FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "empty"), FileMode.Open,
- FileAccess.Read);
+ byte[] data = new byte[1048576];
+ FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "empty"), FileMode.Open,
+ FileAccess.Read);
fs.Read(data, 0, 1048576);
fs.Close();
fs.Dispose();
IChecksum ctx = new Md5Context();
- ctx.Init();
ctx.Update(data);
byte[] result = ctx.Final();
Assert.AreEqual(ExpectedEmpty, result);
@@ -83,23 +80,21 @@ namespace DiscImageChef.Tests.Checksums
[Test]
public void Md5RandomFile()
{
- Md5Context ctx = new Md5Context();
- ctx.Init();
- byte[] result = ctx.File(Path.Combine(Consts.TestFilesRoot, "checksums", "random"));
+ Md5Context ctx = new Md5Context();
+ byte[] result = ctx.File(Path.Combine(Consts.TestFilesRoot, "checksums", "random"));
Assert.AreEqual(ExpectedRandom, result);
}
[Test]
public void Md5RandomData()
{
- byte[] data = new byte[1048576];
- FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "random"), FileMode.Open,
- FileAccess.Read);
+ byte[] data = new byte[1048576];
+ FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "random"), FileMode.Open,
+ FileAccess.Read);
fs.Read(data, 0, 1048576);
fs.Close();
fs.Dispose();
Md5Context ctx = new Md5Context();
- ctx.Init();
ctx.Data(data, out byte[] result);
Assert.AreEqual(ExpectedRandom, result);
}
@@ -107,14 +102,13 @@ namespace DiscImageChef.Tests.Checksums
[Test]
public void Md5RandomInstance()
{
- byte[] data = new byte[1048576];
- FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "random"), FileMode.Open,
- FileAccess.Read);
+ byte[] data = new byte[1048576];
+ FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "random"), FileMode.Open,
+ FileAccess.Read);
fs.Read(data, 0, 1048576);
fs.Close();
fs.Dispose();
IChecksum ctx = new Md5Context();
- ctx.Init();
ctx.Update(data);
byte[] result = ctx.Final();
Assert.AreEqual(ExpectedRandom, result);
diff --git a/DiscImageChef.Tests/Checksums/RIPEMD160.cs b/DiscImageChef.Tests/Checksums/RIPEMD160.cs
index 018d645a..2c592752 100644
--- a/DiscImageChef.Tests/Checksums/RIPEMD160.cs
+++ b/DiscImageChef.Tests/Checksums/RIPEMD160.cs
@@ -49,23 +49,21 @@ namespace DiscImageChef.Tests.Checksums
[Test]
public void Ripemd160EmptyFile()
{
- Ripemd160Context ctx = new Ripemd160Context();
- ctx.Init();
- byte[] result = ctx.File(Path.Combine(Consts.TestFilesRoot, "checksums", "empty"));
+ Ripemd160Context ctx = new Ripemd160Context();
+ byte[] result = ctx.File(Path.Combine(Consts.TestFilesRoot, "checksums", "empty"));
Assert.AreEqual(ExpectedEmpty, result);
}
[Test]
public void Ripemd160EmptyData()
{
- byte[] data = new byte[1048576];
- FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "empty"), FileMode.Open,
- FileAccess.Read);
+ byte[] data = new byte[1048576];
+ FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "empty"), FileMode.Open,
+ FileAccess.Read);
fs.Read(data, 0, 1048576);
fs.Close();
fs.Dispose();
Ripemd160Context ctx = new Ripemd160Context();
- ctx.Init();
ctx.Data(data, out byte[] result);
Assert.AreEqual(ExpectedEmpty, result);
}
@@ -73,14 +71,13 @@ namespace DiscImageChef.Tests.Checksums
[Test]
public void Ripemd160EmptyInstance()
{
- byte[] data = new byte[1048576];
- FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "empty"), FileMode.Open,
- FileAccess.Read);
+ byte[] data = new byte[1048576];
+ FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "empty"), FileMode.Open,
+ FileAccess.Read);
fs.Read(data, 0, 1048576);
fs.Close();
fs.Dispose();
IChecksum ctx = new Ripemd160Context();
- ctx.Init();
ctx.Update(data);
byte[] result = ctx.Final();
Assert.AreEqual(ExpectedEmpty, result);
@@ -89,23 +86,21 @@ namespace DiscImageChef.Tests.Checksums
[Test]
public void Ripemd160RandomFile()
{
- Ripemd160Context ctx = new Ripemd160Context();
- ctx.Init();
- byte[] result = ctx.File(Path.Combine(Consts.TestFilesRoot, "checksums", "random"));
+ Ripemd160Context ctx = new Ripemd160Context();
+ byte[] result = ctx.File(Path.Combine(Consts.TestFilesRoot, "checksums", "random"));
Assert.AreEqual(ExpectedRandom, result);
}
[Test]
public void Ripemd160RandomData()
{
- byte[] data = new byte[1048576];
- FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "random"), FileMode.Open,
- FileAccess.Read);
+ byte[] data = new byte[1048576];
+ FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "random"), FileMode.Open,
+ FileAccess.Read);
fs.Read(data, 0, 1048576);
fs.Close();
fs.Dispose();
Ripemd160Context ctx = new Ripemd160Context();
- ctx.Init();
ctx.Data(data, out byte[] result);
Assert.AreEqual(ExpectedRandom, result);
}
@@ -113,14 +108,13 @@ namespace DiscImageChef.Tests.Checksums
[Test]
public void Ripemd160RandomInstance()
{
- byte[] data = new byte[1048576];
- FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "random"), FileMode.Open,
- FileAccess.Read);
+ byte[] data = new byte[1048576];
+ FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "random"), FileMode.Open,
+ FileAccess.Read);
fs.Read(data, 0, 1048576);
fs.Close();
fs.Dispose();
IChecksum ctx = new Ripemd160Context();
- ctx.Init();
ctx.Update(data);
byte[] result = ctx.Final();
Assert.AreEqual(ExpectedRandom, result);
diff --git a/DiscImageChef.Tests/Checksums/SHA1.cs b/DiscImageChef.Tests/Checksums/SHA1.cs
index 8f984261..5881ed45 100644
--- a/DiscImageChef.Tests/Checksums/SHA1.cs
+++ b/DiscImageChef.Tests/Checksums/SHA1.cs
@@ -49,23 +49,21 @@ namespace DiscImageChef.Tests.Checksums
[Test]
public void Sha1EmptyFile()
{
- Sha1Context ctx = new Sha1Context();
- ctx.Init();
- byte[] result = ctx.File(Path.Combine(Consts.TestFilesRoot, "checksums", "empty"));
+ Sha1Context ctx = new Sha1Context();
+ byte[] result = ctx.File(Path.Combine(Consts.TestFilesRoot, "checksums", "empty"));
Assert.AreEqual(ExpectedEmpty, result);
}
[Test]
public void Sha1EmptyData()
{
- byte[] data = new byte[1048576];
- FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "empty"), FileMode.Open,
- FileAccess.Read);
+ byte[] data = new byte[1048576];
+ FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "empty"), FileMode.Open,
+ FileAccess.Read);
fs.Read(data, 0, 1048576);
fs.Close();
fs.Dispose();
Sha1Context ctx = new Sha1Context();
- ctx.Init();
ctx.Data(data, out byte[] result);
Assert.AreEqual(ExpectedEmpty, result);
}
@@ -73,14 +71,13 @@ namespace DiscImageChef.Tests.Checksums
[Test]
public void Sha1EmptyInstance()
{
- byte[] data = new byte[1048576];
- FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "empty"), FileMode.Open,
- FileAccess.Read);
+ byte[] data = new byte[1048576];
+ FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "empty"), FileMode.Open,
+ FileAccess.Read);
fs.Read(data, 0, 1048576);
fs.Close();
fs.Dispose();
IChecksum ctx = new Sha1Context();
- ctx.Init();
ctx.Update(data);
byte[] result = ctx.Final();
Assert.AreEqual(ExpectedEmpty, result);
@@ -89,23 +86,21 @@ namespace DiscImageChef.Tests.Checksums
[Test]
public void Sha1RandomFile()
{
- Sha1Context ctx = new Sha1Context();
- ctx.Init();
- byte[] result = ctx.File(Path.Combine(Consts.TestFilesRoot, "checksums", "random"));
+ Sha1Context ctx = new Sha1Context();
+ byte[] result = ctx.File(Path.Combine(Consts.TestFilesRoot, "checksums", "random"));
Assert.AreEqual(ExpectedRandom, result);
}
[Test]
public void Sha1RandomData()
{
- byte[] data = new byte[1048576];
- FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "random"), FileMode.Open,
- FileAccess.Read);
+ byte[] data = new byte[1048576];
+ FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "random"), FileMode.Open,
+ FileAccess.Read);
fs.Read(data, 0, 1048576);
fs.Close();
fs.Dispose();
Sha1Context ctx = new Sha1Context();
- ctx.Init();
ctx.Data(data, out byte[] result);
Assert.AreEqual(ExpectedRandom, result);
}
@@ -113,14 +108,13 @@ namespace DiscImageChef.Tests.Checksums
[Test]
public void Sha1RandomInstance()
{
- byte[] data = new byte[1048576];
- FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "random"), FileMode.Open,
- FileAccess.Read);
+ byte[] data = new byte[1048576];
+ FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "random"), FileMode.Open,
+ FileAccess.Read);
fs.Read(data, 0, 1048576);
fs.Close();
fs.Dispose();
IChecksum ctx = new Sha1Context();
- ctx.Init();
ctx.Update(data);
byte[] result = ctx.Final();
Assert.AreEqual(ExpectedRandom, result);
diff --git a/DiscImageChef.Tests/Checksums/SHA256.cs b/DiscImageChef.Tests/Checksums/SHA256.cs
index 648e5203..9ecd82e8 100644
--- a/DiscImageChef.Tests/Checksums/SHA256.cs
+++ b/DiscImageChef.Tests/Checksums/SHA256.cs
@@ -49,23 +49,21 @@ namespace DiscImageChef.Tests.Checksums
[Test]
public void Sha256EmptyFile()
{
- Sha256Context ctx = new Sha256Context();
- ctx.Init();
- byte[] result = ctx.File(Path.Combine(Consts.TestFilesRoot, "checksums", "empty"));
+ Sha256Context ctx = new Sha256Context();
+ byte[] result = ctx.File(Path.Combine(Consts.TestFilesRoot, "checksums", "empty"));
Assert.AreEqual(ExpectedEmpty, result);
}
[Test]
public void Sha256EmptyData()
{
- byte[] data = new byte[1048576];
- FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "empty"), FileMode.Open,
- FileAccess.Read);
+ byte[] data = new byte[1048576];
+ FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "empty"), FileMode.Open,
+ FileAccess.Read);
fs.Read(data, 0, 1048576);
fs.Close();
fs.Dispose();
Sha256Context ctx = new Sha256Context();
- ctx.Init();
ctx.Data(data, out byte[] result);
Assert.AreEqual(ExpectedEmpty, result);
}
@@ -73,14 +71,13 @@ namespace DiscImageChef.Tests.Checksums
[Test]
public void Sha256EmptyInstance()
{
- byte[] data = new byte[1048576];
- FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "empty"), FileMode.Open,
- FileAccess.Read);
+ byte[] data = new byte[1048576];
+ FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "empty"), FileMode.Open,
+ FileAccess.Read);
fs.Read(data, 0, 1048576);
fs.Close();
fs.Dispose();
IChecksum ctx = new Sha256Context();
- ctx.Init();
ctx.Update(data);
byte[] result = ctx.Final();
Assert.AreEqual(ExpectedEmpty, result);
@@ -89,23 +86,21 @@ namespace DiscImageChef.Tests.Checksums
[Test]
public void Sha256RandomFile()
{
- Sha256Context ctx = new Sha256Context();
- ctx.Init();
- byte[] result = ctx.File(Path.Combine(Consts.TestFilesRoot, "checksums", "random"));
+ Sha256Context ctx = new Sha256Context();
+ byte[] result = ctx.File(Path.Combine(Consts.TestFilesRoot, "checksums", "random"));
Assert.AreEqual(ExpectedRandom, result);
}
[Test]
public void Sha256RandomData()
{
- byte[] data = new byte[1048576];
- FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "random"), FileMode.Open,
- FileAccess.Read);
+ byte[] data = new byte[1048576];
+ FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "random"), FileMode.Open,
+ FileAccess.Read);
fs.Read(data, 0, 1048576);
fs.Close();
fs.Dispose();
Sha256Context ctx = new Sha256Context();
- ctx.Init();
ctx.Data(data, out byte[] result);
Assert.AreEqual(ExpectedRandom, result);
}
@@ -113,14 +108,13 @@ namespace DiscImageChef.Tests.Checksums
[Test]
public void Sha256RandomInstance()
{
- byte[] data = new byte[1048576];
- FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "random"), FileMode.Open,
- FileAccess.Read);
+ byte[] data = new byte[1048576];
+ FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "random"), FileMode.Open,
+ FileAccess.Read);
fs.Read(data, 0, 1048576);
fs.Close();
fs.Dispose();
IChecksum ctx = new Sha256Context();
- ctx.Init();
ctx.Update(data);
byte[] result = ctx.Final();
Assert.AreEqual(ExpectedRandom, result);
diff --git a/DiscImageChef.Tests/Checksums/SHA384.cs b/DiscImageChef.Tests/Checksums/SHA384.cs
index c2fbda41..5bef9901 100644
--- a/DiscImageChef.Tests/Checksums/SHA384.cs
+++ b/DiscImageChef.Tests/Checksums/SHA384.cs
@@ -51,23 +51,21 @@ namespace DiscImageChef.Tests.Checksums
[Test]
public void Sha384EmptyFile()
{
- Sha384Context ctx = new Sha384Context();
- ctx.Init();
- byte[] result = ctx.File(Path.Combine(Consts.TestFilesRoot, "checksums", "empty"));
+ Sha384Context ctx = new Sha384Context();
+ byte[] result = ctx.File(Path.Combine(Consts.TestFilesRoot, "checksums", "empty"));
Assert.AreEqual(ExpectedEmpty, result);
}
[Test]
public void Sha384EmptyData()
{
- byte[] data = new byte[1048576];
- FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "empty"), FileMode.Open,
- FileAccess.Read);
+ byte[] data = new byte[1048576];
+ FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "empty"), FileMode.Open,
+ FileAccess.Read);
fs.Read(data, 0, 1048576);
fs.Close();
fs.Dispose();
Sha384Context ctx = new Sha384Context();
- ctx.Init();
ctx.Data(data, out byte[] result);
Assert.AreEqual(ExpectedEmpty, result);
}
@@ -75,14 +73,13 @@ namespace DiscImageChef.Tests.Checksums
[Test]
public void Sha384EmptyInstance()
{
- byte[] data = new byte[1048576];
- FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "empty"), FileMode.Open,
- FileAccess.Read);
+ byte[] data = new byte[1048576];
+ FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "empty"), FileMode.Open,
+ FileAccess.Read);
fs.Read(data, 0, 1048576);
fs.Close();
fs.Dispose();
IChecksum ctx = new Sha384Context();
- ctx.Init();
ctx.Update(data);
byte[] result = ctx.Final();
Assert.AreEqual(ExpectedEmpty, result);
@@ -91,23 +88,21 @@ namespace DiscImageChef.Tests.Checksums
[Test]
public void Sha384RandomFile()
{
- Sha384Context ctx = new Sha384Context();
- ctx.Init();
- byte[] result = ctx.File(Path.Combine(Consts.TestFilesRoot, "checksums", "random"));
+ Sha384Context ctx = new Sha384Context();
+ byte[] result = ctx.File(Path.Combine(Consts.TestFilesRoot, "checksums", "random"));
Assert.AreEqual(ExpectedRandom, result);
}
[Test]
public void Sha384RandomData()
{
- byte[] data = new byte[1048576];
- FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "random"), FileMode.Open,
- FileAccess.Read);
+ byte[] data = new byte[1048576];
+ FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "random"), FileMode.Open,
+ FileAccess.Read);
fs.Read(data, 0, 1048576);
fs.Close();
fs.Dispose();
Sha384Context ctx = new Sha384Context();
- ctx.Init();
ctx.Data(data, out byte[] result);
Assert.AreEqual(ExpectedRandom, result);
}
@@ -115,14 +110,13 @@ namespace DiscImageChef.Tests.Checksums
[Test]
public void Sha384RandomInstance()
{
- byte[] data = new byte[1048576];
- FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "random"), FileMode.Open,
- FileAccess.Read);
+ byte[] data = new byte[1048576];
+ FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "random"), FileMode.Open,
+ FileAccess.Read);
fs.Read(data, 0, 1048576);
fs.Close();
fs.Dispose();
IChecksum ctx = new Sha384Context();
- ctx.Init();
ctx.Update(data);
byte[] result = ctx.Final();
Assert.AreEqual(ExpectedRandom, result);
diff --git a/DiscImageChef.Tests/Checksums/SHA512.cs b/DiscImageChef.Tests/Checksums/SHA512.cs
index 835c5501..2f493f8c 100644
--- a/DiscImageChef.Tests/Checksums/SHA512.cs
+++ b/DiscImageChef.Tests/Checksums/SHA512.cs
@@ -53,23 +53,21 @@ namespace DiscImageChef.Tests.Checksums
[Test]
public void Sha512EmptyFile()
{
- Sha512Context ctx = new Sha512Context();
- ctx.Init();
- byte[] result = ctx.File(Path.Combine(Consts.TestFilesRoot, "checksums", "empty"));
+ Sha512Context ctx = new Sha512Context();
+ byte[] result = ctx.File(Path.Combine(Consts.TestFilesRoot, "checksums", "empty"));
Assert.AreEqual(ExpectedEmpty, result);
}
[Test]
public void Sha512EmptyData()
{
- byte[] data = new byte[1048576];
- FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "empty"), FileMode.Open,
- FileAccess.Read);
+ byte[] data = new byte[1048576];
+ FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "empty"), FileMode.Open,
+ FileAccess.Read);
fs.Read(data, 0, 1048576);
fs.Close();
fs.Dispose();
Sha512Context ctx = new Sha512Context();
- ctx.Init();
ctx.Data(data, out byte[] result);
Assert.AreEqual(ExpectedEmpty, result);
}
@@ -77,14 +75,13 @@ namespace DiscImageChef.Tests.Checksums
[Test]
public void Sha512EmptyInstance()
{
- byte[] data = new byte[1048576];
- FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "empty"), FileMode.Open,
- FileAccess.Read);
+ byte[] data = new byte[1048576];
+ FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "empty"), FileMode.Open,
+ FileAccess.Read);
fs.Read(data, 0, 1048576);
fs.Close();
fs.Dispose();
IChecksum ctx = new Sha512Context();
- ctx.Init();
ctx.Update(data);
byte[] result = ctx.Final();
Assert.AreEqual(ExpectedEmpty, result);
@@ -93,23 +90,21 @@ namespace DiscImageChef.Tests.Checksums
[Test]
public void Sha512RandomFile()
{
- Sha512Context ctx = new Sha512Context();
- ctx.Init();
- byte[] result = ctx.File(Path.Combine(Consts.TestFilesRoot, "checksums", "random"));
+ Sha512Context ctx = new Sha512Context();
+ byte[] result = ctx.File(Path.Combine(Consts.TestFilesRoot, "checksums", "random"));
Assert.AreEqual(ExpectedRandom, result);
}
[Test]
public void Sha512RandomData()
{
- byte[] data = new byte[1048576];
- FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "random"), FileMode.Open,
- FileAccess.Read);
+ byte[] data = new byte[1048576];
+ FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "random"), FileMode.Open,
+ FileAccess.Read);
fs.Read(data, 0, 1048576);
fs.Close();
fs.Dispose();
Sha512Context ctx = new Sha512Context();
- ctx.Init();
ctx.Data(data, out byte[] result);
Assert.AreEqual(ExpectedRandom, result);
}
@@ -117,14 +112,13 @@ namespace DiscImageChef.Tests.Checksums
[Test]
public void Sha512RandomInstance()
{
- byte[] data = new byte[1048576];
- FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "random"), FileMode.Open,
- FileAccess.Read);
+ byte[] data = new byte[1048576];
+ FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "random"), FileMode.Open,
+ FileAccess.Read);
fs.Read(data, 0, 1048576);
fs.Close();
fs.Dispose();
IChecksum ctx = new Sha512Context();
- ctx.Init();
ctx.Update(data);
byte[] result = ctx.Final();
Assert.AreEqual(ExpectedRandom, result);
diff --git a/DiscImageChef.Tests/Checksums/SpamSum.cs b/DiscImageChef.Tests/Checksums/SpamSum.cs
index eb8ec9bd..db7c164a 100644
--- a/DiscImageChef.Tests/Checksums/SpamSum.cs
+++ b/DiscImageChef.Tests/Checksums/SpamSum.cs
@@ -35,15 +35,15 @@ namespace DiscImageChef.Tests.Checksums
[TestFixture]
public class SpamSum
{
- const string EXPECTED_EMPTY = "3::";
+ const string EXPECTED_EMPTY = "3::";
const string EXPECTED_RANDOM = "24576:3dvzuAsHTQ16pc7O1Q/gS9qze+Swwn9s6IX:8/TQQpaVqze+JN6IX";
[Test]
public void SpamSumEmptyData()
{
- byte[] data = new byte[1048576];
- FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "empty"), FileMode.Open,
- FileAccess.Read);
+ byte[] data = new byte[1048576];
+ FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "empty"), FileMode.Open,
+ FileAccess.Read);
fs.Read(data, 0, 1048576);
fs.Close();
fs.Dispose();
@@ -54,14 +54,13 @@ namespace DiscImageChef.Tests.Checksums
[Test]
public void SpamSumEmptyInstance()
{
- byte[] data = new byte[1048576];
- FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "empty"), FileMode.Open,
- FileAccess.Read);
+ byte[] data = new byte[1048576];
+ FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "empty"), FileMode.Open,
+ FileAccess.Read);
fs.Read(data, 0, 1048576);
fs.Close();
fs.Dispose();
IChecksum ctx = new SpamSumContext();
- ctx.Init();
ctx.Update(data);
string result = ctx.End();
Assert.AreEqual(EXPECTED_EMPTY, result);
@@ -70,9 +69,9 @@ namespace DiscImageChef.Tests.Checksums
[Test]
public void SpamSumRandomData()
{
- byte[] data = new byte[1048576];
- FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "random"), FileMode.Open,
- FileAccess.Read);
+ byte[] data = new byte[1048576];
+ FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "random"), FileMode.Open,
+ FileAccess.Read);
fs.Read(data, 0, 1048576);
fs.Close();
fs.Dispose();
@@ -83,14 +82,13 @@ namespace DiscImageChef.Tests.Checksums
[Test]
public void SpamSumRandomInstance()
{
- byte[] data = new byte[1048576];
- FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "random"), FileMode.Open,
- FileAccess.Read);
+ byte[] data = new byte[1048576];
+ FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "random"), FileMode.Open,
+ FileAccess.Read);
fs.Read(data, 0, 1048576);
fs.Close();
fs.Dispose();
IChecksum ctx = new SpamSumContext();
- ctx.Init();
ctx.Update(data);
string result = ctx.End();
Assert.AreEqual(EXPECTED_RANDOM, result);
diff --git a/DiscImageChef.Tests/Filters/AppleDoubleDave.cs b/DiscImageChef.Tests/Filters/AppleDoubleDave.cs
index 17ec83bb..ae59ba5c 100644
--- a/DiscImageChef.Tests/Filters/AppleDoubleDave.cs
+++ b/DiscImageChef.Tests/Filters/AppleDoubleDave.cs
@@ -36,30 +36,28 @@ namespace DiscImageChef.Tests.Filters
[TestFixture]
public class AppleDoubleDave
{
- const string EXPECTED_FILE = "c2be571406cf6353269faa59a4a8c0a4";
- const string EXPECTED_SIDECAR = "7b0c25bf8cb70f6fb1a15eca31585250";
- const string EXPECTED_CONTENTS = "c2be571406cf6353269faa59a4a8c0a4";
- const string EXPECTED_RESOURCE = "a972d27c44193a7587b21416c0953cc3";
+ const string EXPECTED_FILE = "c2be571406cf6353269faa59a4a8c0a4";
+ const string EXPECTED_SIDECAR = "7b0c25bf8cb70f6fb1a15eca31585250";
+ const string EXPECTED_CONTENTS = "c2be571406cf6353269faa59a4a8c0a4";
+ const string EXPECTED_RESOURCE = "a972d27c44193a7587b21416c0953cc3";
readonly string location;
readonly string sidecar;
public AppleDoubleDave()
{
location = Path.Combine(Consts.TestFilesRoot, "filters", "appledouble", "dave", "DOS_720.dmg");
- sidecar = Path.Combine(Consts.TestFilesRoot, "filters", "appledouble", "dave", "resource.frk",
- "DOS_720.dmg");
+ sidecar = Path.Combine(Consts.TestFilesRoot, "filters", "appledouble", "dave", "resource.frk",
+ "DOS_720.dmg");
}
[Test]
public void CheckCorrectFile()
{
- Md5Context ctx = new Md5Context();
- ctx.Init();
- string result = ctx.File(location, out _);
+ Md5Context ctx = new Md5Context();
+ string result = ctx.File(location, out _);
Assert.AreEqual(EXPECTED_FILE, result);
- ctx = new Md5Context();
- ctx.Init();
+ ctx = new Md5Context();
result = ctx.File(sidecar, out _);
Assert.AreEqual(EXPECTED_SIDECAR, result);
}
@@ -76,7 +74,7 @@ namespace DiscImageChef.Tests.Filters
{
IFilter filter = new AppleDouble();
filter.Open(location);
- Assert.AreEqual(true, filter.IsOpened());
+ Assert.AreEqual(true, filter.IsOpened());
Assert.AreEqual(737280, filter.GetDataForkLength());
Assert.AreNotEqual(null, filter.GetDataForkStream());
Assert.AreEqual(286, filter.GetResourceForkLength());
@@ -90,15 +88,14 @@ namespace DiscImageChef.Tests.Filters
{
IFilter filter = new AppleDouble();
filter.Open(location);
- Stream str = filter.GetDataForkStream();
+ Stream str = filter.GetDataForkStream();
byte[] data = new byte[737280];
str.Read(data, 0, 737280);
str.Close();
str.Dispose();
filter.Close();
- Md5Context ctx = new Md5Context();
- ctx.Init();
- string result = ctx.Data(data, out _);
+ Md5Context ctx = new Md5Context();
+ string result = ctx.Data(data, out _);
Assert.AreEqual(EXPECTED_CONTENTS, result);
}
@@ -107,15 +104,14 @@ namespace DiscImageChef.Tests.Filters
{
IFilter filter = new AppleDouble();
filter.Open(location);
- Stream str = filter.GetResourceForkStream();
+ Stream str = filter.GetResourceForkStream();
byte[] data = new byte[286];
str.Read(data, 0, 286);
str.Close();
str.Dispose();
filter.Close();
- Md5Context ctx = new Md5Context();
- ctx.Init();
- string result = ctx.Data(data, out _);
+ Md5Context ctx = new Md5Context();
+ string result = ctx.Data(data, out _);
Assert.AreEqual(EXPECTED_RESOURCE, result);
}
}
diff --git a/DiscImageChef.Tests/Filters/AppleDoubleDos.cs b/DiscImageChef.Tests/Filters/AppleDoubleDos.cs
index 8c490955..e7f298a4 100644
--- a/DiscImageChef.Tests/Filters/AppleDoubleDos.cs
+++ b/DiscImageChef.Tests/Filters/AppleDoubleDos.cs
@@ -36,29 +36,27 @@ namespace DiscImageChef.Tests.Filters
[TestFixture]
public class AppleDoubleDos
{
- const string EXPECTED_FILE = "c2be571406cf6353269faa59a4a8c0a4";
- const string EXPECTED_SIDECAR = "7b0c25bf8cb70f6fb1a15eca31585250";
- const string EXPECTED_CONTENTS = "c2be571406cf6353269faa59a4a8c0a4";
- const string EXPECTED_RESOURCE = "a972d27c44193a7587b21416c0953cc3";
+ const string EXPECTED_FILE = "c2be571406cf6353269faa59a4a8c0a4";
+ const string EXPECTED_SIDECAR = "7b0c25bf8cb70f6fb1a15eca31585250";
+ const string EXPECTED_CONTENTS = "c2be571406cf6353269faa59a4a8c0a4";
+ const string EXPECTED_RESOURCE = "a972d27c44193a7587b21416c0953cc3";
readonly string location;
readonly string sidecar;
public AppleDoubleDos()
{
location = Path.Combine(Consts.TestFilesRoot, "filters", "appledouble", "dos", "DOS_720.dmg");
- sidecar = Path.Combine(Consts.TestFilesRoot, "filters", "appledouble", "dos", "DOS_720.adf");
+ sidecar = Path.Combine(Consts.TestFilesRoot, "filters", "appledouble", "dos", "DOS_720.adf");
}
[Test]
public void CheckCorrectFile()
{
- Md5Context ctx = new Md5Context();
- ctx.Init();
- string result = ctx.File(location, out _);
+ Md5Context ctx = new Md5Context();
+ string result = ctx.File(location, out _);
Assert.AreEqual(EXPECTED_FILE, result);
- ctx = new Md5Context();
- ctx.Init();
+ ctx = new Md5Context();
result = ctx.File(sidecar, out _);
Assert.AreEqual(EXPECTED_SIDECAR, result);
}
@@ -75,7 +73,7 @@ namespace DiscImageChef.Tests.Filters
{
IFilter filter = new AppleDouble();
filter.Open(location);
- Assert.AreEqual(true, filter.IsOpened());
+ Assert.AreEqual(true, filter.IsOpened());
Assert.AreEqual(737280, filter.GetDataForkLength());
Assert.AreNotEqual(null, filter.GetDataForkStream());
Assert.AreEqual(286, filter.GetResourceForkLength());
@@ -89,15 +87,14 @@ namespace DiscImageChef.Tests.Filters
{
IFilter filter = new AppleDouble();
filter.Open(location);
- Stream str = filter.GetDataForkStream();
+ Stream str = filter.GetDataForkStream();
byte[] data = new byte[737280];
str.Read(data, 0, 737280);
str.Close();
str.Dispose();
filter.Close();
- Md5Context ctx = new Md5Context();
- ctx.Init();
- string result = ctx.Data(data, out _);
+ Md5Context ctx = new Md5Context();
+ string result = ctx.Data(data, out _);
Assert.AreEqual(EXPECTED_CONTENTS, result);
}
@@ -106,15 +103,14 @@ namespace DiscImageChef.Tests.Filters
{
IFilter filter = new AppleDouble();
filter.Open(location);
- Stream str = filter.GetResourceForkStream();
+ Stream str = filter.GetResourceForkStream();
byte[] data = new byte[286];
str.Read(data, 0, 286);
str.Close();
str.Dispose();
filter.Close();
- Md5Context ctx = new Md5Context();
- ctx.Init();
- string result = ctx.Data(data, out _);
+ Md5Context ctx = new Md5Context();
+ string result = ctx.Data(data, out _);
Assert.AreEqual(EXPECTED_RESOURCE, result);
}
}
diff --git a/DiscImageChef.Tests/Filters/AppleDoubleNetatalk.cs b/DiscImageChef.Tests/Filters/AppleDoubleNetatalk.cs
index c8ce4bf6..e0edc641 100644
--- a/DiscImageChef.Tests/Filters/AppleDoubleNetatalk.cs
+++ b/DiscImageChef.Tests/Filters/AppleDoubleNetatalk.cs
@@ -36,30 +36,28 @@ namespace DiscImageChef.Tests.Filters
[TestFixture]
public class AppleDoubleNetatalk
{
- const string EXPECTED_FILE = "c2be571406cf6353269faa59a4a8c0a4";
- const string EXPECTED_SIDECAR = "7b0c25bf8cb70f6fb1a15eca31585250";
- const string EXPECTED_CONTENTS = "c2be571406cf6353269faa59a4a8c0a4";
- const string EXPECTED_RESOURCE = "a972d27c44193a7587b21416c0953cc3";
+ const string EXPECTED_FILE = "c2be571406cf6353269faa59a4a8c0a4";
+ const string EXPECTED_SIDECAR = "7b0c25bf8cb70f6fb1a15eca31585250";
+ const string EXPECTED_CONTENTS = "c2be571406cf6353269faa59a4a8c0a4";
+ const string EXPECTED_RESOURCE = "a972d27c44193a7587b21416c0953cc3";
readonly string location;
readonly string sidecar;
public AppleDoubleNetatalk()
{
location = Path.Combine(Consts.TestFilesRoot, "filters", "appledouble", "netatalk", "DOS_720.dmg");
- sidecar = Path.Combine(Consts.TestFilesRoot, "filters", "appledouble", "netatalk", ".AppleDouble",
- "DOS_720.dmg");
+ sidecar = Path.Combine(Consts.TestFilesRoot, "filters", "appledouble", "netatalk", ".AppleDouble",
+ "DOS_720.dmg");
}
[Test]
public void CheckCorrectFile()
{
- Md5Context ctx = new Md5Context();
- ctx.Init();
- string result = ctx.File(location, out _);
+ Md5Context ctx = new Md5Context();
+ string result = ctx.File(location, out _);
Assert.AreEqual(EXPECTED_FILE, result);
- ctx = new Md5Context();
- ctx.Init();
+ ctx = new Md5Context();
result = ctx.File(sidecar, out _);
Assert.AreEqual(EXPECTED_SIDECAR, result);
}
@@ -76,7 +74,7 @@ namespace DiscImageChef.Tests.Filters
{
IFilter filter = new AppleDouble();
filter.Open(location);
- Assert.AreEqual(true, filter.IsOpened());
+ Assert.AreEqual(true, filter.IsOpened());
Assert.AreEqual(737280, filter.GetDataForkLength());
Assert.AreNotEqual(null, filter.GetDataForkStream());
Assert.AreEqual(286, filter.GetResourceForkLength());
@@ -90,15 +88,14 @@ namespace DiscImageChef.Tests.Filters
{
IFilter filter = new AppleDouble();
filter.Open(location);
- Stream str = filter.GetDataForkStream();
+ Stream str = filter.GetDataForkStream();
byte[] data = new byte[737280];
str.Read(data, 0, 737280);
str.Close();
str.Dispose();
filter.Close();
- Md5Context ctx = new Md5Context();
- ctx.Init();
- string result = ctx.Data(data, out _);
+ Md5Context ctx = new Md5Context();
+ string result = ctx.Data(data, out _);
Assert.AreEqual(EXPECTED_CONTENTS, result);
}
@@ -107,15 +104,14 @@ namespace DiscImageChef.Tests.Filters
{
IFilter filter = new AppleDouble();
filter.Open(location);
- Stream str = filter.GetResourceForkStream();
+ Stream str = filter.GetResourceForkStream();
byte[] data = new byte[286];
str.Read(data, 0, 286);
str.Close();
str.Dispose();
filter.Close();
- Md5Context ctx = new Md5Context();
- ctx.Init();
- string result = ctx.Data(data, out _);
+ Md5Context ctx = new Md5Context();
+ string result = ctx.Data(data, out _);
Assert.AreEqual(EXPECTED_RESOURCE, result);
}
}
diff --git a/DiscImageChef.Tests/Filters/AppleDoubleOsX.cs b/DiscImageChef.Tests/Filters/AppleDoubleOsX.cs
index a5365249..254a9777 100644
--- a/DiscImageChef.Tests/Filters/AppleDoubleOsX.cs
+++ b/DiscImageChef.Tests/Filters/AppleDoubleOsX.cs
@@ -36,29 +36,27 @@ namespace DiscImageChef.Tests.Filters
[TestFixture]
public class AppleDoubleOsX
{
- const string EXPECTED_FILE = "c2be571406cf6353269faa59a4a8c0a4";
- const string EXPECTED_SIDECAR = "7b0c25bf8cb70f6fb1a15eca31585250";
- const string EXPECTED_CONTENTS = "c2be571406cf6353269faa59a4a8c0a4";
- const string EXPECTED_RESOURCE = "a972d27c44193a7587b21416c0953cc3";
+ const string EXPECTED_FILE = "c2be571406cf6353269faa59a4a8c0a4";
+ const string EXPECTED_SIDECAR = "7b0c25bf8cb70f6fb1a15eca31585250";
+ const string EXPECTED_CONTENTS = "c2be571406cf6353269faa59a4a8c0a4";
+ const string EXPECTED_RESOURCE = "a972d27c44193a7587b21416c0953cc3";
readonly string location;
readonly string sidecar;
public AppleDoubleOsX()
{
location = Path.Combine(Consts.TestFilesRoot, "filters", "appledouble", "osx", "DOS_720.dmg");
- sidecar = Path.Combine(Consts.TestFilesRoot, "filters", "appledouble", "osx", "._DOS_720.dmg");
+ sidecar = Path.Combine(Consts.TestFilesRoot, "filters", "appledouble", "osx", "._DOS_720.dmg");
}
[Test]
public void CheckCorrectFile()
{
- Md5Context ctx = new Md5Context();
- ctx.Init();
- string result = ctx.File(location, out _);
+ Md5Context ctx = new Md5Context();
+ string result = ctx.File(location, out _);
Assert.AreEqual(EXPECTED_FILE, result);
- ctx = new Md5Context();
- ctx.Init();
+ ctx = new Md5Context();
result = ctx.File(sidecar, out _);
Assert.AreEqual(EXPECTED_SIDECAR, result);
}
@@ -75,7 +73,7 @@ namespace DiscImageChef.Tests.Filters
{
IFilter filter = new AppleDouble();
filter.Open(location);
- Assert.AreEqual(true, filter.IsOpened());
+ Assert.AreEqual(true, filter.IsOpened());
Assert.AreEqual(737280, filter.GetDataForkLength());
Assert.AreNotEqual(null, filter.GetDataForkStream());
Assert.AreEqual(286, filter.GetResourceForkLength());
@@ -89,15 +87,14 @@ namespace DiscImageChef.Tests.Filters
{
IFilter filter = new AppleDouble();
filter.Open(location);
- Stream str = filter.GetDataForkStream();
+ Stream str = filter.GetDataForkStream();
byte[] data = new byte[737280];
str.Read(data, 0, 737280);
str.Close();
str.Dispose();
filter.Close();
- Md5Context ctx = new Md5Context();
- ctx.Init();
- string result = ctx.Data(data, out _);
+ Md5Context ctx = new Md5Context();
+ string result = ctx.Data(data, out _);
Assert.AreEqual(EXPECTED_CONTENTS, result);
}
@@ -106,15 +103,14 @@ namespace DiscImageChef.Tests.Filters
{
IFilter filter = new AppleDouble();
filter.Open(location);
- Stream str = filter.GetResourceForkStream();
+ Stream str = filter.GetResourceForkStream();
byte[] data = new byte[286];
str.Read(data, 0, 286);
str.Close();
str.Dispose();
filter.Close();
- Md5Context ctx = new Md5Context();
- ctx.Init();
- string result = ctx.Data(data, out _);
+ Md5Context ctx = new Md5Context();
+ string result = ctx.Data(data, out _);
Assert.AreEqual(EXPECTED_RESOURCE, result);
}
}
diff --git a/DiscImageChef.Tests/Filters/AppleDoubleProDos.cs b/DiscImageChef.Tests/Filters/AppleDoubleProDos.cs
index 12f0071f..7c8a3e07 100644
--- a/DiscImageChef.Tests/Filters/AppleDoubleProDos.cs
+++ b/DiscImageChef.Tests/Filters/AppleDoubleProDos.cs
@@ -36,29 +36,27 @@ namespace DiscImageChef.Tests.Filters
[TestFixture]
public class AppleDoubleProDos
{
- const string EXPECTED_FILE = "c2be571406cf6353269faa59a4a8c0a4";
- const string EXPECTED_SIDECAR = "7b0c25bf8cb70f6fb1a15eca31585250";
- const string EXPECTED_CONTENTS = "c2be571406cf6353269faa59a4a8c0a4";
- const string EXPECTED_RESOURCE = "a972d27c44193a7587b21416c0953cc3";
+ const string EXPECTED_FILE = "c2be571406cf6353269faa59a4a8c0a4";
+ const string EXPECTED_SIDECAR = "7b0c25bf8cb70f6fb1a15eca31585250";
+ const string EXPECTED_CONTENTS = "c2be571406cf6353269faa59a4a8c0a4";
+ const string EXPECTED_RESOURCE = "a972d27c44193a7587b21416c0953cc3";
readonly string location;
readonly string sidecar;
public AppleDoubleProDos()
{
location = Path.Combine(Consts.TestFilesRoot, "filters", "appledouble", "prodos", "DOS_720.dmg");
- sidecar = Path.Combine(Consts.TestFilesRoot, "filters", "appledouble", "prodos", "R.DOS_720.dmg");
+ sidecar = Path.Combine(Consts.TestFilesRoot, "filters", "appledouble", "prodos", "R.DOS_720.dmg");
}
[Test]
public void CheckCorrectFile()
{
- Md5Context ctx = new Md5Context();
- ctx.Init();
- string result = ctx.File(location, out _);
+ Md5Context ctx = new Md5Context();
+ string result = ctx.File(location, out _);
Assert.AreEqual(EXPECTED_FILE, result);
- ctx = new Md5Context();
- ctx.Init();
+ ctx = new Md5Context();
result = ctx.File(sidecar, out _);
Assert.AreEqual(EXPECTED_SIDECAR, result);
}
@@ -75,7 +73,7 @@ namespace DiscImageChef.Tests.Filters
{
IFilter filter = new AppleDouble();
filter.Open(location);
- Assert.AreEqual(true, filter.IsOpened());
+ Assert.AreEqual(true, filter.IsOpened());
Assert.AreEqual(737280, filter.GetDataForkLength());
Assert.AreNotEqual(null, filter.GetDataForkStream());
Assert.AreEqual(286, filter.GetResourceForkLength());
@@ -89,15 +87,14 @@ namespace DiscImageChef.Tests.Filters
{
IFilter filter = new AppleDouble();
filter.Open(location);
- Stream str = filter.GetDataForkStream();
+ Stream str = filter.GetDataForkStream();
byte[] data = new byte[737280];
str.Read(data, 0, 737280);
str.Close();
str.Dispose();
filter.Close();
- Md5Context ctx = new Md5Context();
- ctx.Init();
- string result = ctx.Data(data, out _);
+ Md5Context ctx = new Md5Context();
+ string result = ctx.Data(data, out _);
Assert.AreEqual(EXPECTED_CONTENTS, result);
}
@@ -106,15 +103,14 @@ namespace DiscImageChef.Tests.Filters
{
IFilter filter = new AppleDouble();
filter.Open(location);
- Stream str = filter.GetResourceForkStream();
+ Stream str = filter.GetResourceForkStream();
byte[] data = new byte[286];
str.Read(data, 0, 286);
str.Close();
str.Dispose();
filter.Close();
- Md5Context ctx = new Md5Context();
- ctx.Init();
- string result = ctx.Data(data, out _);
+ Md5Context ctx = new Md5Context();
+ string result = ctx.Data(data, out _);
Assert.AreEqual(EXPECTED_RESOURCE, result);
}
}
diff --git a/DiscImageChef.Tests/Filters/AppleDoubleUnAr.cs b/DiscImageChef.Tests/Filters/AppleDoubleUnAr.cs
index 8586a9b4..0556df63 100644
--- a/DiscImageChef.Tests/Filters/AppleDoubleUnAr.cs
+++ b/DiscImageChef.Tests/Filters/AppleDoubleUnAr.cs
@@ -36,29 +36,27 @@ namespace DiscImageChef.Tests.Filters
[TestFixture]
public class AppleDoubleUnAr
{
- const string EXPECTED_FILE = "c2be571406cf6353269faa59a4a8c0a4";
- const string EXPECTED_SIDECAR = "7b0c25bf8cb70f6fb1a15eca31585250";
- const string EXPECTED_CONTENTS = "c2be571406cf6353269faa59a4a8c0a4";
- const string EXPECTED_RESOURCE = "a972d27c44193a7587b21416c0953cc3";
+ const string EXPECTED_FILE = "c2be571406cf6353269faa59a4a8c0a4";
+ const string EXPECTED_SIDECAR = "7b0c25bf8cb70f6fb1a15eca31585250";
+ const string EXPECTED_CONTENTS = "c2be571406cf6353269faa59a4a8c0a4";
+ const string EXPECTED_RESOURCE = "a972d27c44193a7587b21416c0953cc3";
readonly string location;
readonly string sidecar;
public AppleDoubleUnAr()
{
location = Path.Combine(Consts.TestFilesRoot, "filters", "appledouble", "unar", "DOS_720.dmg");
- sidecar = Path.Combine(Consts.TestFilesRoot, "filters", "appledouble", "unar", "DOS_720.dmg.rsrc");
+ sidecar = Path.Combine(Consts.TestFilesRoot, "filters", "appledouble", "unar", "DOS_720.dmg.rsrc");
}
[Test]
public void CheckCorrectFile()
{
- Md5Context ctx = new Md5Context();
- ctx.Init();
- string result = ctx.File(location, out _);
+ Md5Context ctx = new Md5Context();
+ string result = ctx.File(location, out _);
Assert.AreEqual(EXPECTED_FILE, result);
- ctx = new Md5Context();
- ctx.Init();
+ ctx = new Md5Context();
result = ctx.File(sidecar, out _);
Assert.AreEqual(EXPECTED_SIDECAR, result);
}
@@ -75,7 +73,7 @@ namespace DiscImageChef.Tests.Filters
{
IFilter filter = new AppleDouble();
filter.Open(location);
- Assert.AreEqual(true, filter.IsOpened());
+ Assert.AreEqual(true, filter.IsOpened());
Assert.AreEqual(737280, filter.GetDataForkLength());
Assert.AreNotEqual(null, filter.GetDataForkStream());
Assert.AreEqual(286, filter.GetResourceForkLength());
@@ -89,15 +87,14 @@ namespace DiscImageChef.Tests.Filters
{
IFilter filter = new AppleDouble();
filter.Open(location);
- Stream str = filter.GetDataForkStream();
+ Stream str = filter.GetDataForkStream();
byte[] data = new byte[737280];
str.Read(data, 0, 737280);
str.Close();
str.Dispose();
filter.Close();
- Md5Context ctx = new Md5Context();
- ctx.Init();
- string result = ctx.Data(data, out _);
+ Md5Context ctx = new Md5Context();
+ string result = ctx.Data(data, out _);
Assert.AreEqual(EXPECTED_CONTENTS, result);
}
@@ -106,15 +103,14 @@ namespace DiscImageChef.Tests.Filters
{
IFilter filter = new AppleDouble();
filter.Open(location);
- Stream str = filter.GetResourceForkStream();
+ Stream str = filter.GetResourceForkStream();
byte[] data = new byte[286];
str.Read(data, 0, 286);
str.Close();
str.Dispose();
filter.Close();
- Md5Context ctx = new Md5Context();
- ctx.Init();
- string result = ctx.Data(data, out _);
+ Md5Context ctx = new Md5Context();
+ string result = ctx.Data(data, out _);
Assert.AreEqual(EXPECTED_RESOURCE, result);
}
}
diff --git a/DiscImageChef.Tests/Filters/AppleDoubleUnix.cs b/DiscImageChef.Tests/Filters/AppleDoubleUnix.cs
index 78995ce5..09af0e15 100644
--- a/DiscImageChef.Tests/Filters/AppleDoubleUnix.cs
+++ b/DiscImageChef.Tests/Filters/AppleDoubleUnix.cs
@@ -36,29 +36,27 @@ namespace DiscImageChef.Tests.Filters
[TestFixture]
public class AppleDoubleUnix
{
- const string EXPECTED_FILE = "c2be571406cf6353269faa59a4a8c0a4";
- const string EXPECTED_SIDECAR = "7b0c25bf8cb70f6fb1a15eca31585250";
- const string EXPECTED_CONTENTS = "c2be571406cf6353269faa59a4a8c0a4";
- const string EXPECTED_RESOURCE = "a972d27c44193a7587b21416c0953cc3";
+ const string EXPECTED_FILE = "c2be571406cf6353269faa59a4a8c0a4";
+ const string EXPECTED_SIDECAR = "7b0c25bf8cb70f6fb1a15eca31585250";
+ const string EXPECTED_CONTENTS = "c2be571406cf6353269faa59a4a8c0a4";
+ const string EXPECTED_RESOURCE = "a972d27c44193a7587b21416c0953cc3";
readonly string location;
readonly string sidecar;
public AppleDoubleUnix()
{
location = Path.Combine(Consts.TestFilesRoot, "filters", "appledouble", "unix", "DOS_720.dmg");
- sidecar = Path.Combine(Consts.TestFilesRoot, "filters", "appledouble", "unix", "%DOS_720.dmg");
+ sidecar = Path.Combine(Consts.TestFilesRoot, "filters", "appledouble", "unix", "%DOS_720.dmg");
}
[Test]
public void CheckCorrectFile()
{
- Md5Context ctx = new Md5Context();
- ctx.Init();
- string result = ctx.File(location, out _);
+ Md5Context ctx = new Md5Context();
+ string result = ctx.File(location, out _);
Assert.AreEqual(EXPECTED_FILE, result);
- ctx = new Md5Context();
- ctx.Init();
+ ctx = new Md5Context();
result = ctx.File(sidecar, out _);
Assert.AreEqual(EXPECTED_SIDECAR, result);
}
@@ -75,7 +73,7 @@ namespace DiscImageChef.Tests.Filters
{
IFilter filter = new AppleDouble();
filter.Open(location);
- Assert.AreEqual(true, filter.IsOpened());
+ Assert.AreEqual(true, filter.IsOpened());
Assert.AreEqual(737280, filter.GetDataForkLength());
Assert.AreNotEqual(null, filter.GetDataForkStream());
Assert.AreEqual(286, filter.GetResourceForkLength());
@@ -89,15 +87,14 @@ namespace DiscImageChef.Tests.Filters
{
IFilter filter = new AppleDouble();
filter.Open(location);
- Stream str = filter.GetDataForkStream();
+ Stream str = filter.GetDataForkStream();
byte[] data = new byte[737280];
str.Read(data, 0, 737280);
str.Close();
str.Dispose();
filter.Close();
- Md5Context ctx = new Md5Context();
- ctx.Init();
- string result = ctx.Data(data, out _);
+ Md5Context ctx = new Md5Context();
+ string result = ctx.Data(data, out _);
Assert.AreEqual(EXPECTED_CONTENTS, result);
}
@@ -106,15 +103,14 @@ namespace DiscImageChef.Tests.Filters
{
IFilter filter = new AppleDouble();
filter.Open(location);
- Stream str = filter.GetResourceForkStream();
+ Stream str = filter.GetResourceForkStream();
byte[] data = new byte[286];
str.Read(data, 0, 286);
str.Close();
str.Dispose();
filter.Close();
- Md5Context ctx = new Md5Context();
- ctx.Init();
- string result = ctx.Data(data, out _);
+ Md5Context ctx = new Md5Context();
+ string result = ctx.Data(data, out _);
Assert.AreEqual(EXPECTED_RESOURCE, result);
}
}
diff --git a/DiscImageChef.Tests/Filters/AppleSingle.cs b/DiscImageChef.Tests/Filters/AppleSingle.cs
index cddc2713..432819c4 100644
--- a/DiscImageChef.Tests/Filters/AppleSingle.cs
+++ b/DiscImageChef.Tests/Filters/AppleSingle.cs
@@ -36,9 +36,9 @@ namespace DiscImageChef.Tests.Filters
[TestFixture]
public class AppleSingle
{
- const string EXPECTED_FILE = "7497a3b156dcd0c1046a1ab12e188ab7";
- const string EXPECTED_CONTENTS = "c2be571406cf6353269faa59a4a8c0a4";
- const string EXPECTED_RESOURCE = "a972d27c44193a7587b21416c0953cc3";
+ const string EXPECTED_FILE = "7497a3b156dcd0c1046a1ab12e188ab7";
+ const string EXPECTED_CONTENTS = "c2be571406cf6353269faa59a4a8c0a4";
+ const string EXPECTED_RESOURCE = "a972d27c44193a7587b21416c0953cc3";
readonly string location;
public AppleSingle()
@@ -49,9 +49,8 @@ namespace DiscImageChef.Tests.Filters
[Test]
public void CheckCorrectFile()
{
- Md5Context ctx = new Md5Context();
- ctx.Init();
- string result = ctx.File(location, out _);
+ Md5Context ctx = new Md5Context();
+ string result = ctx.File(location, out _);
Assert.AreEqual(EXPECTED_FILE, result);
}
@@ -67,7 +66,7 @@ namespace DiscImageChef.Tests.Filters
{
IFilter filter = new DiscImageChef.Filters.AppleSingle();
filter.Open(location);
- Assert.AreEqual(true, filter.IsOpened());
+ Assert.AreEqual(true, filter.IsOpened());
Assert.AreEqual(737280, filter.GetDataForkLength());
Assert.AreNotEqual(null, filter.GetDataForkStream());
Assert.AreEqual(286, filter.GetResourceForkLength());
@@ -81,15 +80,14 @@ namespace DiscImageChef.Tests.Filters
{
IFilter filter = new DiscImageChef.Filters.AppleSingle();
filter.Open(location);
- Stream str = filter.GetDataForkStream();
+ Stream str = filter.GetDataForkStream();
byte[] data = new byte[737280];
str.Read(data, 0, 737280);
str.Close();
str.Dispose();
filter.Close();
- Md5Context ctx = new Md5Context();
- ctx.Init();
- string result = ctx.Data(data, out _);
+ Md5Context ctx = new Md5Context();
+ string result = ctx.Data(data, out _);
Assert.AreEqual(EXPECTED_CONTENTS, result);
}
@@ -98,15 +96,14 @@ namespace DiscImageChef.Tests.Filters
{
IFilter filter = new DiscImageChef.Filters.AppleSingle();
filter.Open(location);
- Stream str = filter.GetResourceForkStream();
+ Stream str = filter.GetResourceForkStream();
byte[] data = new byte[286];
str.Read(data, 0, 286);
str.Close();
str.Dispose();
filter.Close();
- Md5Context ctx = new Md5Context();
- ctx.Init();
- string result = ctx.Data(data, out _);
+ Md5Context ctx = new Md5Context();
+ string result = ctx.Data(data, out _);
Assert.AreEqual(EXPECTED_RESOURCE, result);
}
}
diff --git a/DiscImageChef.Tests/Filters/BZip2.cs b/DiscImageChef.Tests/Filters/BZip2.cs
index 60a34808..ce8edf1f 100644
--- a/DiscImageChef.Tests/Filters/BZip2.cs
+++ b/DiscImageChef.Tests/Filters/BZip2.cs
@@ -50,9 +50,8 @@ namespace DiscImageChef.Tests.Filters
[Test]
public void CheckCorrectFile()
{
- Md5Context ctx = new Md5Context();
- ctx.Init();
- byte[] result = ctx.File(location);
+ Md5Context ctx = new Md5Context();
+ byte[] result = ctx.File(location);
Assert.AreEqual(ExpectedFile, result);
}
@@ -68,11 +67,11 @@ namespace DiscImageChef.Tests.Filters
{
IFilter filter = new DiscImageChef.Filters.BZip2();
filter.Open(location);
- Assert.AreEqual(true, filter.IsOpened());
+ Assert.AreEqual(true, filter.IsOpened());
Assert.AreEqual(1048576, filter.GetDataForkLength());
Assert.AreNotEqual(null, filter.GetDataForkStream());
- Assert.AreEqual(0, filter.GetResourceForkLength());
- Assert.AreEqual(null, filter.GetResourceForkStream());
+ Assert.AreEqual(0, filter.GetResourceForkLength());
+ Assert.AreEqual(null, filter.GetResourceForkStream());
Assert.AreEqual(false, filter.HasResourceFork());
filter.Close();
}
@@ -82,14 +81,13 @@ namespace DiscImageChef.Tests.Filters
{
IFilter filter = new DiscImageChef.Filters.BZip2();
filter.Open(location);
- Stream str = filter.GetDataForkStream();
+ Stream str = filter.GetDataForkStream();
byte[] data = new byte[1048576];
str.Read(data, 0, 1048576);
str.Close();
str.Dispose();
filter.Close();
Md5Context ctx = new Md5Context();
- ctx.Init();
ctx.Data(data, out byte[] result);
Assert.AreEqual(ExpectedContents, result);
}
diff --git a/DiscImageChef.Tests/Filters/GZip.cs b/DiscImageChef.Tests/Filters/GZip.cs
index 4f4a6653..cb610662 100644
--- a/DiscImageChef.Tests/Filters/GZip.cs
+++ b/DiscImageChef.Tests/Filters/GZip.cs
@@ -50,9 +50,8 @@ namespace DiscImageChef.Tests.Filters
[Test]
public void CheckCorrectFile()
{
- Md5Context ctx = new Md5Context();
- ctx.Init();
- byte[] result = ctx.File(location);
+ Md5Context ctx = new Md5Context();
+ byte[] result = ctx.File(location);
Assert.AreEqual(ExpectedFile, result);
}
@@ -68,11 +67,11 @@ namespace DiscImageChef.Tests.Filters
{
IFilter filter = new DiscImageChef.Filters.GZip();
filter.Open(location);
- Assert.AreEqual(true, filter.IsOpened());
+ Assert.AreEqual(true, filter.IsOpened());
Assert.AreEqual(1048576, filter.GetDataForkLength());
Assert.AreNotEqual(null, filter.GetDataForkStream());
- Assert.AreEqual(0, filter.GetResourceForkLength());
- Assert.AreEqual(null, filter.GetResourceForkStream());
+ Assert.AreEqual(0, filter.GetResourceForkLength());
+ Assert.AreEqual(null, filter.GetResourceForkStream());
Assert.AreEqual(false, filter.HasResourceFork());
filter.Close();
}
@@ -82,14 +81,13 @@ namespace DiscImageChef.Tests.Filters
{
IFilter filter = new DiscImageChef.Filters.GZip();
filter.Open(location);
- Stream str = filter.GetDataForkStream();
+ Stream str = filter.GetDataForkStream();
byte[] data = new byte[1048576];
str.Read(data, 0, 1048576);
str.Close();
str.Dispose();
filter.Close();
Md5Context ctx = new Md5Context();
- ctx.Init();
ctx.Data(data, out byte[] result);
Assert.AreEqual(ExpectedContents, result);
}
diff --git a/DiscImageChef.Tests/Filters/LZip.cs b/DiscImageChef.Tests/Filters/LZip.cs
index 4cf29287..6c5e6f44 100644
--- a/DiscImageChef.Tests/Filters/LZip.cs
+++ b/DiscImageChef.Tests/Filters/LZip.cs
@@ -50,9 +50,8 @@ namespace DiscImageChef.Tests.Filters
[Test]
public void CheckCorrectFile()
{
- Md5Context ctx = new Md5Context();
- ctx.Init();
- byte[] result = ctx.File(location);
+ Md5Context ctx = new Md5Context();
+ byte[] result = ctx.File(location);
Assert.AreEqual(ExpectedFile, result);
}
@@ -68,11 +67,11 @@ namespace DiscImageChef.Tests.Filters
{
IFilter filter = new DiscImageChef.Filters.LZip();
filter.Open(location);
- Assert.AreEqual(true, filter.IsOpened());
+ Assert.AreEqual(true, filter.IsOpened());
Assert.AreEqual(1048576, filter.GetDataForkLength());
Assert.AreNotEqual(null, filter.GetDataForkStream());
- Assert.AreEqual(0, filter.GetResourceForkLength());
- Assert.AreEqual(null, filter.GetResourceForkStream());
+ Assert.AreEqual(0, filter.GetResourceForkLength());
+ Assert.AreEqual(null, filter.GetResourceForkStream());
Assert.AreEqual(false, filter.HasResourceFork());
filter.Close();
}
@@ -82,14 +81,13 @@ namespace DiscImageChef.Tests.Filters
{
IFilter filter = new DiscImageChef.Filters.LZip();
filter.Open(location);
- Stream str = filter.GetDataForkStream();
+ Stream str = filter.GetDataForkStream();
byte[] data = new byte[1048576];
str.Read(data, 0, 1048576);
str.Close();
str.Dispose();
filter.Close();
Md5Context ctx = new Md5Context();
- ctx.Init();
ctx.Data(data, out byte[] result);
Assert.AreEqual(ExpectedContents, result);
}
diff --git a/DiscImageChef.Tests/Filters/MacBinary1.cs b/DiscImageChef.Tests/Filters/MacBinary1.cs
index 25ada52e..b01e3e38 100644
--- a/DiscImageChef.Tests/Filters/MacBinary1.cs
+++ b/DiscImageChef.Tests/Filters/MacBinary1.cs
@@ -36,9 +36,9 @@ namespace DiscImageChef.Tests.Filters
[TestFixture]
public class MacBinary1
{
- const string EXPECTED_FILE = "596c38555bc7ba284648d1ce57700884";
- const string EXPECTED_CONTENTS = "c2be571406cf6353269faa59a4a8c0a4";
- const string EXPECTED_RESOURCE = "a972d27c44193a7587b21416c0953cc3";
+ const string EXPECTED_FILE = "596c38555bc7ba284648d1ce57700884";
+ const string EXPECTED_CONTENTS = "c2be571406cf6353269faa59a4a8c0a4";
+ const string EXPECTED_RESOURCE = "a972d27c44193a7587b21416c0953cc3";
readonly string location;
public MacBinary1()
@@ -49,9 +49,8 @@ namespace DiscImageChef.Tests.Filters
[Test]
public void CheckCorrectFile()
{
- Md5Context ctx = new Md5Context();
- ctx.Init();
- string result = ctx.File(location, out _);
+ Md5Context ctx = new Md5Context();
+ string result = ctx.File(location, out _);
Assert.AreEqual(EXPECTED_FILE, result);
}
@@ -67,7 +66,7 @@ namespace DiscImageChef.Tests.Filters
{
IFilter filter = new DiscImageChef.Filters.AppleSingle();
filter.Open(location);
- Assert.AreEqual(true, filter.IsOpened());
+ Assert.AreEqual(true, filter.IsOpened());
Assert.AreEqual(737280, filter.GetDataForkLength());
Assert.AreNotEqual(null, filter.GetDataForkStream());
Assert.AreEqual(286, filter.GetResourceForkLength());
@@ -81,15 +80,14 @@ namespace DiscImageChef.Tests.Filters
{
IFilter filter = new DiscImageChef.Filters.AppleSingle();
filter.Open(location);
- Stream str = filter.GetDataForkStream();
+ Stream str = filter.GetDataForkStream();
byte[] data = new byte[737280];
str.Read(data, 0, 737280);
str.Close();
str.Dispose();
filter.Close();
- Md5Context ctx = new Md5Context();
- ctx.Init();
- string result = ctx.Data(data, out _);
+ Md5Context ctx = new Md5Context();
+ string result = ctx.Data(data, out _);
Assert.AreEqual(EXPECTED_CONTENTS, result);
}
@@ -98,15 +96,14 @@ namespace DiscImageChef.Tests.Filters
{
IFilter filter = new DiscImageChef.Filters.AppleSingle();
filter.Open(location);
- Stream str = filter.GetResourceForkStream();
+ Stream str = filter.GetResourceForkStream();
byte[] data = new byte[286];
str.Read(data, 0, 286);
str.Close();
str.Dispose();
filter.Close();
- Md5Context ctx = new Md5Context();
- ctx.Init();
- string result = ctx.Data(data, out _);
+ Md5Context ctx = new Md5Context();
+ string result = ctx.Data(data, out _);
Assert.AreEqual(EXPECTED_RESOURCE, result);
}
}
diff --git a/DiscImageChef.Tests/Filters/MacBinary2.cs b/DiscImageChef.Tests/Filters/MacBinary2.cs
index 4e02a1f5..41c84b2d 100644
--- a/DiscImageChef.Tests/Filters/MacBinary2.cs
+++ b/DiscImageChef.Tests/Filters/MacBinary2.cs
@@ -36,9 +36,9 @@ namespace DiscImageChef.Tests.Filters
[TestFixture]
public class MacBinary2
{
- const string EXPECTED_FILE = "a8daa55a65432353e95dc4c61d42660f";
- const string EXPECTED_CONTENTS = "c2be571406cf6353269faa59a4a8c0a4";
- const string EXPECTED_RESOURCE = "a972d27c44193a7587b21416c0953cc3";
+ const string EXPECTED_FILE = "a8daa55a65432353e95dc4c61d42660f";
+ const string EXPECTED_CONTENTS = "c2be571406cf6353269faa59a4a8c0a4";
+ const string EXPECTED_RESOURCE = "a972d27c44193a7587b21416c0953cc3";
readonly string location;
public MacBinary2()
@@ -49,9 +49,8 @@ namespace DiscImageChef.Tests.Filters
[Test]
public void CheckCorrectFile()
{
- Md5Context ctx = new Md5Context();
- ctx.Init();
- string result = ctx.File(location, out _);
+ Md5Context ctx = new Md5Context();
+ string result = ctx.File(location, out _);
Assert.AreEqual(EXPECTED_FILE, result);
}
@@ -67,7 +66,7 @@ namespace DiscImageChef.Tests.Filters
{
IFilter filter = new MacBinary();
filter.Open(location);
- Assert.AreEqual(true, filter.IsOpened());
+ Assert.AreEqual(true, filter.IsOpened());
Assert.AreEqual(737280, filter.GetDataForkLength());
Assert.AreNotEqual(null, filter.GetDataForkStream());
Assert.AreEqual(286, filter.GetResourceForkLength());
@@ -81,15 +80,14 @@ namespace DiscImageChef.Tests.Filters
{
IFilter filter = new MacBinary();
filter.Open(location);
- Stream str = filter.GetDataForkStream();
+ Stream str = filter.GetDataForkStream();
byte[] data = new byte[737280];
str.Read(data, 0, 737280);
str.Close();
str.Dispose();
filter.Close();
- Md5Context ctx = new Md5Context();
- ctx.Init();
- string result = ctx.Data(data, out _);
+ Md5Context ctx = new Md5Context();
+ string result = ctx.Data(data, out _);
Assert.AreEqual(EXPECTED_CONTENTS, result);
}
@@ -98,15 +96,14 @@ namespace DiscImageChef.Tests.Filters
{
IFilter filter = new MacBinary();
filter.Open(location);
- Stream str = filter.GetResourceForkStream();
+ Stream str = filter.GetResourceForkStream();
byte[] data = new byte[286];
str.Read(data, 0, 286);
str.Close();
str.Dispose();
filter.Close();
- Md5Context ctx = new Md5Context();
- ctx.Init();
- string result = ctx.Data(data, out _);
+ Md5Context ctx = new Md5Context();
+ string result = ctx.Data(data, out _);
Assert.AreEqual(EXPECTED_RESOURCE, result);
}
}
diff --git a/DiscImageChef.Tests/Filters/MacBinary3.cs b/DiscImageChef.Tests/Filters/MacBinary3.cs
index 8fe846bf..f5f01969 100644
--- a/DiscImageChef.Tests/Filters/MacBinary3.cs
+++ b/DiscImageChef.Tests/Filters/MacBinary3.cs
@@ -36,9 +36,9 @@ namespace DiscImageChef.Tests.Filters
[TestFixture]
public class MacBinary3
{
- const string EXPECTED_FILE = "3a7363a6109fb52a264b0b45dfa16694";
- const string EXPECTED_CONTENTS = "c2be571406cf6353269faa59a4a8c0a4";
- const string EXPECTED_RESOURCE = "a972d27c44193a7587b21416c0953cc3";
+ const string EXPECTED_FILE = "3a7363a6109fb52a264b0b45dfa16694";
+ const string EXPECTED_CONTENTS = "c2be571406cf6353269faa59a4a8c0a4";
+ const string EXPECTED_RESOURCE = "a972d27c44193a7587b21416c0953cc3";
readonly string location;
public MacBinary3()
@@ -49,9 +49,8 @@ namespace DiscImageChef.Tests.Filters
[Test]
public void CheckCorrectFile()
{
- Md5Context ctx = new Md5Context();
- ctx.Init();
- string result = ctx.File(location, out _);
+ Md5Context ctx = new Md5Context();
+ string result = ctx.File(location, out _);
Assert.AreEqual(EXPECTED_FILE, result);
}
@@ -67,7 +66,7 @@ namespace DiscImageChef.Tests.Filters
{
IFilter filter = new MacBinary();
filter.Open(location);
- Assert.AreEqual(true, filter.IsOpened());
+ Assert.AreEqual(true, filter.IsOpened());
Assert.AreEqual(737280, filter.GetDataForkLength());
Assert.AreNotEqual(null, filter.GetDataForkStream());
Assert.AreEqual(286, filter.GetResourceForkLength());
@@ -81,15 +80,14 @@ namespace DiscImageChef.Tests.Filters
{
IFilter filter = new MacBinary();
filter.Open(location);
- Stream str = filter.GetDataForkStream();
+ Stream str = filter.GetDataForkStream();
byte[] data = new byte[737280];
str.Read(data, 0, 737280);
str.Close();
str.Dispose();
filter.Close();
- Md5Context ctx = new Md5Context();
- ctx.Init();
- string result = ctx.Data(data, out _);
+ Md5Context ctx = new Md5Context();
+ string result = ctx.Data(data, out _);
Assert.AreEqual(EXPECTED_CONTENTS, result);
}
@@ -98,15 +96,14 @@ namespace DiscImageChef.Tests.Filters
{
IFilter filter = new MacBinary();
filter.Open(location);
- Stream str = filter.GetResourceForkStream();
+ Stream str = filter.GetResourceForkStream();
byte[] data = new byte[286];
str.Read(data, 0, 286);
str.Close();
str.Dispose();
filter.Close();
- Md5Context ctx = new Md5Context();
- ctx.Init();
- string result = ctx.Data(data, out _);
+ Md5Context ctx = new Md5Context();
+ string result = ctx.Data(data, out _);
Assert.AreEqual(EXPECTED_RESOURCE, result);
}
}
diff --git a/DiscImageChef.Tests/Filters/PCExchange.cs b/DiscImageChef.Tests/Filters/PCExchange.cs
index a2c9d060..b507158f 100644
--- a/DiscImageChef.Tests/Filters/PCExchange.cs
+++ b/DiscImageChef.Tests/Filters/PCExchange.cs
@@ -36,9 +36,9 @@ namespace DiscImageChef.Tests.Filters
[TestFixture]
public class PcExchange
{
- const string EXPECTED_FILE = "348825a08fa84766d20b91ed917012b9";
- const string EXPECTED_CONTENTS = "c2be571406cf6353269faa59a4a8c0a4";
- const string EXPECTED_RESOURCE = "5cb168d60ce8b2b1b3133c2faaf47165";
+ const string EXPECTED_FILE = "348825a08fa84766d20b91ed917012b9";
+ const string EXPECTED_CONTENTS = "c2be571406cf6353269faa59a4a8c0a4";
+ const string EXPECTED_RESOURCE = "5cb168d60ce8b2b1b3133c2faaf47165";
readonly string location;
public PcExchange()
@@ -49,9 +49,9 @@ namespace DiscImageChef.Tests.Filters
[Test]
public void CheckCorrectFile()
{
- Md5Context ctx = new Md5Context();
- ctx.Init();
- string result = ctx.File(Path.Combine(Consts.TestFilesRoot, "filters", "pcexchange", "FINDER.DAT"), out _);
+ Md5Context ctx = new Md5Context();
+ string result = ctx.File(Path.Combine(Consts.TestFilesRoot, "filters", "pcexchange", "FINDER.DAT"),
+ out _);
Assert.AreEqual(EXPECTED_FILE, result);
}
@@ -67,7 +67,7 @@ namespace DiscImageChef.Tests.Filters
{
IFilter filter = new PCExchange();
filter.Open(location);
- Assert.AreEqual(true, filter.IsOpened());
+ Assert.AreEqual(true, filter.IsOpened());
Assert.AreEqual(737280, filter.GetDataForkLength());
Assert.AreNotEqual(null, filter.GetDataForkStream());
Assert.AreEqual(546, filter.GetResourceForkLength());
@@ -81,15 +81,14 @@ namespace DiscImageChef.Tests.Filters
{
IFilter filter = new PCExchange();
filter.Open(location);
- Stream str = filter.GetDataForkStream();
+ Stream str = filter.GetDataForkStream();
byte[] data = new byte[737280];
str.Read(data, 0, 737280);
str.Close();
str.Dispose();
filter.Close();
- Md5Context ctx = new Md5Context();
- ctx.Init();
- string result = ctx.Data(data, out _);
+ Md5Context ctx = new Md5Context();
+ string result = ctx.Data(data, out _);
Assert.AreEqual(EXPECTED_CONTENTS, result);
}
@@ -98,15 +97,14 @@ namespace DiscImageChef.Tests.Filters
{
IFilter filter = new PCExchange();
filter.Open(location);
- Stream str = filter.GetResourceForkStream();
+ Stream str = filter.GetResourceForkStream();
byte[] data = new byte[546];
str.Read(data, 0, 546);
str.Close();
str.Dispose();
filter.Close();
- Md5Context ctx = new Md5Context();
- ctx.Init();
- string result = ctx.Data(data, out _);
+ Md5Context ctx = new Md5Context();
+ string result = ctx.Data(data, out _);
Assert.AreEqual(EXPECTED_RESOURCE, result);
}
}
diff --git a/DiscImageChef.Tests/Filters/XZ.cs b/DiscImageChef.Tests/Filters/XZ.cs
index 25eea69c..f0267e91 100644
--- a/DiscImageChef.Tests/Filters/XZ.cs
+++ b/DiscImageChef.Tests/Filters/XZ.cs
@@ -50,9 +50,8 @@ namespace DiscImageChef.Tests.Filters
[Test]
public void CheckCorrectFile()
{
- Md5Context ctx = new Md5Context();
- ctx.Init();
- byte[] result = ctx.File(location);
+ Md5Context ctx = new Md5Context();
+ byte[] result = ctx.File(location);
Assert.AreEqual(ExpectedFile, result);
}
@@ -68,11 +67,11 @@ namespace DiscImageChef.Tests.Filters
{
IFilter filter = new XZ();
filter.Open(location);
- Assert.AreEqual(true, filter.IsOpened());
+ Assert.AreEqual(true, filter.IsOpened());
Assert.AreEqual(1048576, filter.GetDataForkLength());
Assert.AreNotEqual(null, filter.GetDataForkStream());
- Assert.AreEqual(0, filter.GetResourceForkLength());
- Assert.AreEqual(null, filter.GetResourceForkStream());
+ Assert.AreEqual(0, filter.GetResourceForkLength());
+ Assert.AreEqual(null, filter.GetResourceForkStream());
Assert.AreEqual(false, filter.HasResourceFork());
filter.Close();
}
@@ -82,14 +81,13 @@ namespace DiscImageChef.Tests.Filters
{
IFilter filter = new XZ();
filter.Open(location);
- Stream str = filter.GetDataForkStream();
+ Stream str = filter.GetDataForkStream();
byte[] data = new byte[1048576];
str.Read(data, 0, 1048576);
str.Close();
str.Dispose();
filter.Close();
Md5Context ctx = new Md5Context();
- ctx.Init();
ctx.Data(data, out byte[] result);
Assert.AreEqual(ExpectedContents, result);
}
diff --git a/DiscImageChef.Tests/Images/2MG.cs b/DiscImageChef.Tests/Images/2MG.cs
index 6036ac3f..5397b5ed 100644
--- a/DiscImageChef.Tests/Images/2MG.cs
+++ b/DiscImageChef.Tests/Images/2MG.cs
@@ -65,21 +65,20 @@ namespace DiscImageChef.Tests.Images
{
for(int i = 0; i < testfiles.Length; i++)
{
- string location = Path.Combine(Consts.TestFilesRoot, "images", "2mg", testfiles[i]);
- IFilter filter = new LZip();
+ string location = Path.Combine(Consts.TestFilesRoot, "images", "2mg", testfiles[i]);
+ IFilter filter = new LZip();
filter.Open(location);
IMediaImage image = new DiscImages.Apple2Mg();
- Assert.AreEqual(true, image.Open(filter), testfiles[i]);
- Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]);
+ Assert.AreEqual(true, image.Open(filter), testfiles[i]);
+ Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]);
Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]);
- Assert.AreEqual(mediatypes[i], image.Info.MediaType, testfiles[i]);
+ Assert.AreEqual(mediatypes[i], image.Info.MediaType, testfiles[i]);
// How many sectors to read at once
const uint SECTORS_TO_READ = 256;
- ulong doneSectors = 0;
+ ulong doneSectors = 0;
Md5Context ctx = new Md5Context();
- ctx.Init();
while(doneSectors < image.Info.Sectors)
{
@@ -87,13 +86,13 @@ namespace DiscImageChef.Tests.Images
if(image.Info.Sectors - doneSectors >= SECTORS_TO_READ)
{
- sector = image.ReadSectors(doneSectors, SECTORS_TO_READ);
+ sector = image.ReadSectors(doneSectors, SECTORS_TO_READ);
doneSectors += SECTORS_TO_READ;
}
else
{
- sector = image.ReadSectors(doneSectors, (uint)(image.Info.Sectors - doneSectors));
- doneSectors += image.Info.Sectors - doneSectors;
+ sector = image.ReadSectors(doneSectors, (uint)(image.Info.Sectors - doneSectors));
+ doneSectors += image.Info.Sectors - doneSectors;
}
ctx.Update(sector);
diff --git a/DiscImageChef.Tests/Images/Anex86.cs b/DiscImageChef.Tests/Images/Anex86.cs
index d42decbf..bf434cb6 100644
--- a/DiscImageChef.Tests/Images/Anex86.cs
+++ b/DiscImageChef.Tests/Images/Anex86.cs
@@ -69,21 +69,20 @@ namespace DiscImageChef.Tests.Images
{
for(int i = 0; i < testfiles.Length; i++)
{
- string location = Path.Combine(Consts.TestFilesRoot, "images", "anex86", testfiles[i]);
- IFilter filter = new LZip();
+ string location = Path.Combine(Consts.TestFilesRoot, "images", "anex86", testfiles[i]);
+ IFilter filter = new LZip();
filter.Open(location);
IMediaImage image = new DiscImages.Anex86();
- Assert.AreEqual(true, image.Open(filter), testfiles[i]);
- Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]);
+ Assert.AreEqual(true, image.Open(filter), testfiles[i]);
+ Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]);
Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]);
- Assert.AreEqual(mediatypes[i], image.Info.MediaType, testfiles[i]);
+ Assert.AreEqual(mediatypes[i], image.Info.MediaType, testfiles[i]);
// How many sectors to read at once
const uint SECTORS_TO_READ = 256;
- ulong doneSectors = 0;
+ ulong doneSectors = 0;
Md5Context ctx = new Md5Context();
- ctx.Init();
while(doneSectors < image.Info.Sectors)
{
@@ -91,13 +90,13 @@ namespace DiscImageChef.Tests.Images
if(image.Info.Sectors - doneSectors >= SECTORS_TO_READ)
{
- sector = image.ReadSectors(doneSectors, SECTORS_TO_READ);
+ sector = image.ReadSectors(doneSectors, SECTORS_TO_READ);
doneSectors += SECTORS_TO_READ;
}
else
{
- sector = image.ReadSectors(doneSectors, (uint)(image.Info.Sectors - doneSectors));
- doneSectors += image.Info.Sectors - doneSectors;
+ sector = image.ReadSectors(doneSectors, (uint)(image.Info.Sectors - doneSectors));
+ doneSectors += image.Info.Sectors - doneSectors;
}
ctx.Update(sector);
diff --git a/DiscImageChef.Tests/Images/CisCopy.cs b/DiscImageChef.Tests/Images/CisCopy.cs
index 3fad17d2..11a31d4b 100644
--- a/DiscImageChef.Tests/Images/CisCopy.cs
+++ b/DiscImageChef.Tests/Images/CisCopy.cs
@@ -83,21 +83,20 @@ namespace DiscImageChef.Tests.Images
{
for(int i = 0; i < testfiles.Length; i++)
{
- string location = Path.Combine(Consts.TestFilesRoot, "images", "ciscopy", testfiles[i]);
- IFilter filter = new LZip();
+ string location = Path.Combine(Consts.TestFilesRoot, "images", "ciscopy", testfiles[i]);
+ IFilter filter = new LZip();
filter.Open(location);
IMediaImage image = new DiscImages.CisCopy();
- Assert.AreEqual(true, image.Open(filter), testfiles[i]);
- Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]);
+ Assert.AreEqual(true, image.Open(filter), testfiles[i]);
+ Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]);
Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]);
- Assert.AreEqual(mediatypes[i], image.Info.MediaType, testfiles[i]);
+ Assert.AreEqual(mediatypes[i], image.Info.MediaType, testfiles[i]);
// How many sectors to read at once
const uint SECTORS_TO_READ = 256;
- ulong doneSectors = 0;
+ ulong doneSectors = 0;
Md5Context ctx = new Md5Context();
- ctx.Init();
while(doneSectors < image.Info.Sectors)
{
@@ -105,13 +104,13 @@ namespace DiscImageChef.Tests.Images
if(image.Info.Sectors - doneSectors >= SECTORS_TO_READ)
{
- sector = image.ReadSectors(doneSectors, SECTORS_TO_READ);
+ sector = image.ReadSectors(doneSectors, SECTORS_TO_READ);
doneSectors += SECTORS_TO_READ;
}
else
{
- sector = image.ReadSectors(doneSectors, (uint)(image.Info.Sectors - doneSectors));
- doneSectors += image.Info.Sectors - doneSectors;
+ sector = image.ReadSectors(doneSectors, (uint)(image.Info.Sectors - doneSectors));
+ doneSectors += image.Info.Sectors - doneSectors;
}
ctx.Update(sector);
diff --git a/DiscImageChef.Tests/Images/CopyQM.cs b/DiscImageChef.Tests/Images/CopyQM.cs
index b6dc1be4..33a2f7a3 100644
--- a/DiscImageChef.Tests/Images/CopyQM.cs
+++ b/DiscImageChef.Tests/Images/CopyQM.cs
@@ -71,17 +71,16 @@ namespace DiscImageChef.Tests.Images
IFilter filter = new LZip();
filter.Open(location);
IMediaImage image = new DiscImages.CopyQm();
- Assert.AreEqual(true, image.Open(filter), testfiles[i]);
- Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]);
- Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]);
- Assert.AreEqual(mediatypes[i], image.Info.MediaType, testfiles[i]);
+ Assert.AreEqual(true, image.Open(filter), testfiles[i]);
+ Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]);
+ Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]);
+ Assert.AreEqual(mediatypes[i], image.Info.MediaType, testfiles[i]);
// How many sectors to read at once
const uint SECTORS_TO_READ = 256;
ulong doneSectors = 0;
Md5Context ctx = new Md5Context();
- ctx.Init();
while(doneSectors < image.Info.Sectors)
{
diff --git a/DiscImageChef.Tests/Images/D88.cs b/DiscImageChef.Tests/Images/D88.cs
index e84fdb93..271e7a97 100644
--- a/DiscImageChef.Tests/Images/D88.cs
+++ b/DiscImageChef.Tests/Images/D88.cs
@@ -85,21 +85,20 @@ namespace DiscImageChef.Tests.Images
{
for(int i = 0; i < testfiles.Length; i++)
{
- string location = Path.Combine(Consts.TestFilesRoot, "images", "d88", testfiles[i]);
- IFilter filter = new LZip();
+ string location = Path.Combine(Consts.TestFilesRoot, "images", "d88", testfiles[i]);
+ IFilter filter = new LZip();
filter.Open(location);
IMediaImage image = new DiscImages.D88();
- Assert.AreEqual(true, image.Open(filter), testfiles[i]);
- Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]);
+ Assert.AreEqual(true, image.Open(filter), testfiles[i]);
+ Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]);
Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]);
- Assert.AreEqual(mediatypes[i], image.Info.MediaType, testfiles[i]);
+ Assert.AreEqual(mediatypes[i], image.Info.MediaType, testfiles[i]);
// How many sectors to read at once
const uint SECTORS_TO_READ = 256;
- ulong doneSectors = 0;
+ ulong doneSectors = 0;
Md5Context ctx = new Md5Context();
- ctx.Init();
while(doneSectors < image.Info.Sectors)
{
@@ -107,13 +106,13 @@ namespace DiscImageChef.Tests.Images
if(image.Info.Sectors - doneSectors >= SECTORS_TO_READ)
{
- sector = image.ReadSectors(doneSectors, SECTORS_TO_READ);
+ sector = image.ReadSectors(doneSectors, SECTORS_TO_READ);
doneSectors += SECTORS_TO_READ;
}
else
{
- sector = image.ReadSectors(doneSectors, (uint)(image.Info.Sectors - doneSectors));
- doneSectors += image.Info.Sectors - doneSectors;
+ sector = image.ReadSectors(doneSectors, (uint)(image.Info.Sectors - doneSectors));
+ doneSectors += image.Info.Sectors - doneSectors;
}
ctx.Update(sector);
diff --git a/DiscImageChef.Tests/Images/DART.cs b/DiscImageChef.Tests/Images/DART.cs
index 9f4c0bef..4c1c6cbf 100644
--- a/DiscImageChef.Tests/Images/DART.cs
+++ b/DiscImageChef.Tests/Images/DART.cs
@@ -66,21 +66,20 @@ namespace DiscImageChef.Tests.Images
{
for(int i = 0; i < testfiles.Length; i++)
{
- string location = Path.Combine(Consts.TestFilesRoot, "images", "dart", testfiles[i]);
- IFilter filter = new LZip();
+ string location = Path.Combine(Consts.TestFilesRoot, "images", "dart", testfiles[i]);
+ IFilter filter = new LZip();
filter.Open(location);
IMediaImage image = new DiscImages.D88();
- Assert.AreEqual(true, image.Open(filter), testfiles[i]);
- Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]);
+ Assert.AreEqual(true, image.Open(filter), testfiles[i]);
+ Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]);
Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]);
- Assert.AreEqual(mediatypes[i], image.Info.MediaType, testfiles[i]);
+ Assert.AreEqual(mediatypes[i], image.Info.MediaType, testfiles[i]);
// How many sectors to read at once
const uint SECTORS_TO_READ = 256;
- ulong doneSectors = 0;
+ ulong doneSectors = 0;
Md5Context ctx = new Md5Context();
- ctx.Init();
while(doneSectors < image.Info.Sectors)
{
@@ -88,13 +87,13 @@ namespace DiscImageChef.Tests.Images
if(image.Info.Sectors - doneSectors >= SECTORS_TO_READ)
{
- sector = image.ReadSectors(doneSectors, SECTORS_TO_READ);
+ sector = image.ReadSectors(doneSectors, SECTORS_TO_READ);
doneSectors += SECTORS_TO_READ;
}
else
{
- sector = image.ReadSectors(doneSectors, (uint)(image.Info.Sectors - doneSectors));
- doneSectors += image.Info.Sectors - doneSectors;
+ sector = image.ReadSectors(doneSectors, (uint)(image.Info.Sectors - doneSectors));
+ doneSectors += image.Info.Sectors - doneSectors;
}
ctx.Update(sector);
diff --git a/DiscImageChef.Tests/Images/DiskCopy42.cs b/DiscImageChef.Tests/Images/DiskCopy42.cs
index a1c2448e..e34a7d46 100644
--- a/DiscImageChef.Tests/Images/DiskCopy42.cs
+++ b/DiscImageChef.Tests/Images/DiskCopy42.cs
@@ -86,21 +86,20 @@ namespace DiscImageChef.Tests.Images
{
for(int i = 0; i < testfiles.Length; i++)
{
- string location = Path.Combine(Consts.TestFilesRoot, "images", "", testfiles[i]);
- IFilter filter = new LZip();
+ string location = Path.Combine(Consts.TestFilesRoot, "images", "", testfiles[i]);
+ IFilter filter = new LZip();
filter.Open(location);
IMediaImage image = new DiscImages.DiskCopy42();
- Assert.AreEqual(true, image.Open(filter), testfiles[i]);
- Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]);
+ Assert.AreEqual(true, image.Open(filter), testfiles[i]);
+ Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]);
Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]);
- Assert.AreEqual(mediatypes[i], image.Info.MediaType, testfiles[i]);
+ Assert.AreEqual(mediatypes[i], image.Info.MediaType, testfiles[i]);
// How many sectors to read at once
const uint SECTORS_TO_READ = 256;
- ulong doneSectors = 0;
+ ulong doneSectors = 0;
Md5Context ctx = new Md5Context();
- ctx.Init();
while(doneSectors < image.Info.Sectors)
{
@@ -108,13 +107,13 @@ namespace DiscImageChef.Tests.Images
if(image.Info.Sectors - doneSectors >= SECTORS_TO_READ)
{
- sector = image.ReadSectors(doneSectors, SECTORS_TO_READ);
+ sector = image.ReadSectors(doneSectors, SECTORS_TO_READ);
doneSectors += SECTORS_TO_READ;
}
else
{
- sector = image.ReadSectors(doneSectors, (uint)(image.Info.Sectors - doneSectors));
- doneSectors += image.Info.Sectors - doneSectors;
+ sector = image.ReadSectors(doneSectors, (uint)(image.Info.Sectors - doneSectors));
+ doneSectors += image.Info.Sectors - doneSectors;
}
ctx.Update(sector);
diff --git a/DiscImageChef/Commands/Entropy.cs b/DiscImageChef/Commands/Entropy.cs
index dca99346..37ab0f0d 100644
--- a/DiscImageChef/Commands/Entropy.cs
+++ b/DiscImageChef/Commands/Entropy.cs
@@ -45,15 +45,15 @@ namespace DiscImageChef.Commands
{
internal static void DoEntropy(EntropyOptions options)
{
- DicConsole.DebugWriteLine("Entropy command", "--debug={0}", options.Debug);
- DicConsole.DebugWriteLine("Entropy command", "--verbose={0}", options.Verbose);
- DicConsole.DebugWriteLine("Entropy command", "--separated-tracks={0}", options.SeparatedTracks);
- DicConsole.DebugWriteLine("Entropy command", "--whole-disc={0}", options.WholeDisc);
- DicConsole.DebugWriteLine("Entropy command", "--input={0}", options.InputFile);
+ DicConsole.DebugWriteLine("Entropy command", "--debug={0}", options.Debug);
+ DicConsole.DebugWriteLine("Entropy command", "--verbose={0}", options.Verbose);
+ DicConsole.DebugWriteLine("Entropy command", "--separated-tracks={0}", options.SeparatedTracks);
+ DicConsole.DebugWriteLine("Entropy command", "--whole-disc={0}", options.WholeDisc);
+ DicConsole.DebugWriteLine("Entropy command", "--input={0}", options.InputFile);
DicConsole.DebugWriteLine("Entropy command", "--duplicated-sectors={0}", options.DuplicatedSectors);
FiltersList filtersList = new FiltersList();
- IFilter inputFilter = filtersList.GetFilter(options.InputFile);
+ IFilter inputFilter = filtersList.GetFilter(options.InputFile);
if(inputFilter == null)
{
@@ -73,9 +73,9 @@ namespace DiscImageChef.Commands
Core.Statistics.AddMediaFormat(inputFormat.Format);
Core.Statistics.AddMedia(inputFormat.Info.MediaType, false);
Core.Statistics.AddFilter(inputFilter.Name);
- double entropy = 0;
+ double entropy = 0;
ulong[] entTable;
- ulong sectors;
+ ulong sectors;
if(options.SeparatedTracks)
try
@@ -84,9 +84,9 @@ namespace DiscImageChef.Commands
foreach(Track currentTrack in inputTracks)
{
- Sha1Context sha1CtxTrack = new Sha1Context();
- entTable = new ulong[256];
- ulong trackSize = 0;
+ Sha1Context sha1CtxTrack = new Sha1Context();
+ entTable = new ulong[256];
+ ulong trackSize = 0;
List uniqueSectorsPerTrack = new List();
sectors = currentTrack.TrackEndSector - currentTrack.TrackStartSector + 1;
@@ -108,7 +108,7 @@ namespace DiscImageChef.Commands
trackSize += (ulong)sector.LongLength;
}
- entropy += entTable.Select(l => (double)l / (double)trackSize)
+ entropy += entTable.Select(l => (double)l / (double)trackSize)
.Select(frequency => -(frequency * Math.Log(frequency, 2))).Sum();
DicConsole.WriteLine("Entropy for track {0} is {1:F4}.", currentTrack.TrackSequence, entropy);
@@ -129,16 +129,14 @@ namespace DiscImageChef.Commands
if(!options.WholeDisc) return;
- Sha1Context sha1Ctx = new Sha1Context();
- entTable = new ulong[256];
- ulong diskSize = 0;
+ Sha1Context sha1Ctx = new Sha1Context();
+ entTable = new ulong[256];
+ ulong diskSize = 0;
List uniqueSectors = new List();
sectors = inputFormat.Info.Sectors;
DicConsole.WriteLine("Sectors {0}", sectors);
- sha1Ctx.Init();
-
for(ulong i = 0; i < sectors; i++)
{
DicConsole.Write("\rEntropying sector {0}", i + 1);
@@ -155,7 +153,7 @@ namespace DiscImageChef.Commands
diskSize += (ulong)sector.LongLength;
}
- entropy += entTable.Select(l => (double)l / (double)diskSize)
+ entropy += entTable.Select(l => (double)l / (double)diskSize)
.Select(frequency => -(frequency * Math.Log(frequency, 2))).Sum();
DicConsole.WriteLine();