General code refactor and reformat.

This commit is contained in:
2018-12-31 13:17:27 +00:00
parent 6b12cd1a8e
commit f2caa8c40f
413 changed files with 3554 additions and 6549 deletions

View File

@@ -60,10 +60,10 @@ namespace DiscImageChef.Checksums
//"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
readonly byte[] b64 =
{
0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52,
0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A,
0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x30, 0x31,
0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x2B, 0x2F
0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51,
0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68,
0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79,
0x7A, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x2B, 0x2F
};
FuzzyState self;
@@ -110,11 +110,7 @@ namespace DiscImageChef.Checksums
/// <summary>
/// Returns a byte array of the hash value.
/// </summary>
public byte[] Final()
{
// SpamSum does not have a binary representation, or so it seems
throw new NotImplementedException("SpamSum does not have a binary representation.");
}
public byte[] Final() => throw new NotImplementedException("SpamSum does not have a binary representation.");
/// <summary>
/// Returns a base64 representation of the hash value.
@@ -159,21 +155,12 @@ namespace DiscImageChef.Checksums
self.Roll.H3 ^= c;
}
uint roll_sum()
{
return self.Roll.H1 + self.Roll.H2 + self.Roll.H3;
}
uint roll_sum() => self.Roll.H1 + self.Roll.H2 + self.Roll.H3;
/* A simple non-rolling hash, based on the FNV hash. */
static uint sum_hash(byte c, uint h)
{
return (h * HASH_PRIME) ^ c;
}
static uint sum_hash(byte c, uint h) => (h * HASH_PRIME) ^ c;
static uint SSDEEP_BS(uint index)
{
return MIN_BLOCKSIZE << (int)index;
}
static uint SSDEEP_BS(uint index) => MIN_BLOCKSIZE << (int)index;
void fuzzy_try_fork_blockhash()
{
@@ -394,22 +381,16 @@ namespace DiscImageChef.Checksums
/// Gets the hash of a file
/// </summary>
/// <param name="filename">File path.</param>
public static byte[] File(string filename)
{
// SpamSum does not have a binary representation, or so it seems
public static byte[] File(string filename) =>
throw new NotImplementedException("SpamSum does not have a binary representation.");
}
/// <summary>
/// Gets the hash of a file in hexadecimal and as a byte array.
/// </summary>
/// <param name="filename">File path.</param>
/// <param name="hash">Byte array of the hash value.</param>
public static string File(string filename, out byte[] hash)
{
// SpamSum does not have a binary representation, or so it seems
public static string File(string filename, out byte[] hash) =>
throw new NotImplementedException("Not yet implemented.");
}
/// <summary>
/// Gets the hash of the specified data buffer.
@@ -435,10 +416,7 @@ namespace DiscImageChef.Checksums
/// <param name="data">Data buffer.</param>
/// <param name="hash">null</param>
/// <returns>Base64 representation of SpamSum $blocksize:$hash:$hash</returns>
public static string Data(byte[] data, out byte[] hash)
{
return Data(data, (uint)data.Length, out hash);
}
public static string Data(byte[] data, out byte[] hash) => Data(data, (uint)data.Length, out hash);
// Converts an ASCII null-terminated string to .NET string
static string CToString(byte[] cString)