Merge http://192.168.0.69:3000/AustrianToast/chksum-fork into AustrianToast-main
This commit is contained in:
commit
6f295b0e06
26
.editorconfig
Normal file
26
.editorconfig
Normal file
@ -0,0 +1,26 @@
|
||||
# Remove the line below if you want to inherit .editorconfig settings from higher directories
|
||||
root = true
|
||||
|
||||
# C# files
|
||||
[*.cs]
|
||||
|
||||
# Indentation and spacing
|
||||
indent_size = 4
|
||||
indent_style = space
|
||||
tab_width = 4
|
||||
|
||||
# Naming Conventions
|
||||
dotnet_naming_style.pascal_case_style.capitalization = pascal_case
|
||||
|
||||
# New line preferences
|
||||
csharp_new_line_before_open_brace = none
|
||||
csharp_new_line_before_else = false
|
||||
csharp_new_line_before_catch = false
|
||||
csharp_new_line_before_finally = false
|
||||
|
||||
# Wrapping preferences
|
||||
csharp_preserve_single_line_statements = true
|
||||
csharp_preserve_single_line_blocks = true
|
||||
|
||||
# Switch case
|
||||
csharp_indent_case_contents = true
|
49
Program.cs
49
Program.cs
@ -1,15 +1,19 @@
|
||||
public class Program {
|
||||
static void Main(string[] args) {
|
||||
|
||||
Console.ForegroundColor = ConsoleColor.Red;
|
||||
if (args.Length == 0) {
|
||||
Console.ForegroundColor = ConsoleColor.Red;
|
||||
Console.WriteLine("Please specify an option.");
|
||||
Console.ResetColor();
|
||||
Console.WriteLine("Options are: checksum, countmd5, deletemd5, compareChecksums");
|
||||
} else {
|
||||
switch(args[0]) {
|
||||
PrintAvailableOptions();
|
||||
return;
|
||||
} else if (args.Length > 1) {
|
||||
Console.WriteLine("Too many options.");
|
||||
return;
|
||||
}
|
||||
|
||||
Console.ForegroundColor = ConsoleColor.Green;
|
||||
switch (args[0]) {
|
||||
case "checksum":
|
||||
Console.ForegroundColor = ConsoleColor.Green;
|
||||
Console.WriteLine("Starting the checksum process.");
|
||||
Console.ResetColor();
|
||||
|
||||
@ -17,10 +21,8 @@
|
||||
|
||||
Console.ForegroundColor = ConsoleColor.Green;
|
||||
Console.WriteLine("Checksum process finished");
|
||||
Console.ResetColor();
|
||||
break;
|
||||
case "countmd5":
|
||||
Console.ForegroundColor = ConsoleColor.Green;
|
||||
Console.WriteLine("Counting md5 checksum files.");
|
||||
Console.ResetColor();
|
||||
|
||||
@ -28,10 +30,8 @@
|
||||
|
||||
Console.ForegroundColor = ConsoleColor.Green;
|
||||
Console.WriteLine("Finished counting all md5 checksum files.");
|
||||
Console.ResetColor();
|
||||
break;
|
||||
case "deletemd5":
|
||||
Console.ForegroundColor = ConsoleColor.Green;
|
||||
Console.WriteLine("Deleting all md5 checksum files.");
|
||||
Console.ResetColor();
|
||||
|
||||
@ -39,15 +39,38 @@
|
||||
|
||||
Console.ForegroundColor = ConsoleColor.Green;
|
||||
Console.WriteLine("Deleted all md5 checksum files.");
|
||||
Console.ResetColor();
|
||||
break;
|
||||
case "compareChecksums":
|
||||
Console.WriteLine("Comparing all md5 checksum files. If there is none, creating one.");
|
||||
Console.ResetColor();
|
||||
|
||||
Chksum.compareChecksums();
|
||||
break;
|
||||
default:
|
||||
case "help":
|
||||
PrintAvailableOptions();
|
||||
break;
|
||||
default:
|
||||
Console.ForegroundColor = ConsoleColor.Red;
|
||||
Console.WriteLine("Invalid option. Maybe you mistyped it?");
|
||||
PrintAvailableOptions();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void PrintAvailableOptions() {
|
||||
String[] options = {
|
||||
"checksum",
|
||||
"countmd5",
|
||||
"deletemd5",
|
||||
"compareChecksums",
|
||||
"help"
|
||||
};
|
||||
|
||||
Console.ResetColor();
|
||||
Console.WriteLine("usage: chksum [option]");
|
||||
Console.WriteLine("Here is a list of all available options:");
|
||||
foreach (String option in options) {
|
||||
Console.WriteLine("\t" + option);
|
||||
}
|
||||
}
|
||||
}
|
@ -20,10 +20,8 @@ public class Chksum {
|
||||
// }
|
||||
|
||||
private static string CalculateMD5(string filename) {
|
||||
using (var md5 = System.Security.Cryptography.MD5.Create())
|
||||
{
|
||||
using (var stream = File.OpenRead(filename))
|
||||
{
|
||||
using (var md5 = System.Security.Cryptography.MD5.Create()) {
|
||||
using (var stream = File.OpenRead(filename)) {
|
||||
var hash = md5.ComputeHash(stream);
|
||||
return BitConverter.ToString(hash).Replace("-", "").ToLowerInvariant();
|
||||
}
|
||||
@ -110,5 +108,4 @@ public class Chksum {
|
||||
compareChecksums();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user