Minor code cleanup and some more stuff
This commit is contained in:
parent
38d4330892
commit
743e1eec20
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
|
43
Program.cs
43
Program.cs
@ -1,15 +1,19 @@
|
|||||||
public class Program {
|
public class Program {
|
||||||
static void Main(string[] args) {
|
static void Main(string[] args) {
|
||||||
|
|
||||||
if (args.Length == 0) {
|
|
||||||
Console.ForegroundColor = ConsoleColor.Red;
|
Console.ForegroundColor = ConsoleColor.Red;
|
||||||
|
if (args.Length == 0) {
|
||||||
Console.WriteLine("Please specify an option.");
|
Console.WriteLine("Please specify an option.");
|
||||||
Console.ResetColor();
|
PrintAvailableOptions();
|
||||||
Console.WriteLine("Options are: checksum, countmd5, deletemd5, compareChecksums");
|
return;
|
||||||
} else {
|
} else if (args.Length > 1) {
|
||||||
|
Console.WriteLine("Too many options.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Console.ForegroundColor = ConsoleColor.Green;
|
||||||
switch (args[0]) {
|
switch (args[0]) {
|
||||||
case "checksum":
|
case "checksum":
|
||||||
Console.ForegroundColor = ConsoleColor.Green;
|
|
||||||
Console.WriteLine("Starting the checksum process.");
|
Console.WriteLine("Starting the checksum process.");
|
||||||
Console.ResetColor();
|
Console.ResetColor();
|
||||||
|
|
||||||
@ -17,10 +21,8 @@
|
|||||||
|
|
||||||
Console.ForegroundColor = ConsoleColor.Green;
|
Console.ForegroundColor = ConsoleColor.Green;
|
||||||
Console.WriteLine("Checksum process finished");
|
Console.WriteLine("Checksum process finished");
|
||||||
Console.ResetColor();
|
|
||||||
break;
|
break;
|
||||||
case "countmd5":
|
case "countmd5":
|
||||||
Console.ForegroundColor = ConsoleColor.Green;
|
|
||||||
Console.WriteLine("Counting md5 checksum files.");
|
Console.WriteLine("Counting md5 checksum files.");
|
||||||
Console.ResetColor();
|
Console.ResetColor();
|
||||||
|
|
||||||
@ -28,10 +30,8 @@
|
|||||||
|
|
||||||
Console.ForegroundColor = ConsoleColor.Green;
|
Console.ForegroundColor = ConsoleColor.Green;
|
||||||
Console.WriteLine("Finished counting all md5 checksum files.");
|
Console.WriteLine("Finished counting all md5 checksum files.");
|
||||||
Console.ResetColor();
|
|
||||||
break;
|
break;
|
||||||
case "deletemd5":
|
case "deletemd5":
|
||||||
Console.ForegroundColor = ConsoleColor.Green;
|
|
||||||
Console.WriteLine("Deleting all md5 checksum files.");
|
Console.WriteLine("Deleting all md5 checksum files.");
|
||||||
Console.ResetColor();
|
Console.ResetColor();
|
||||||
|
|
||||||
@ -39,15 +39,38 @@
|
|||||||
|
|
||||||
Console.ForegroundColor = ConsoleColor.Green;
|
Console.ForegroundColor = ConsoleColor.Green;
|
||||||
Console.WriteLine("Deleted all md5 checksum files.");
|
Console.WriteLine("Deleted all md5 checksum files.");
|
||||||
Console.ResetColor();
|
|
||||||
break;
|
break;
|
||||||
case "compareChecksums":
|
case "compareChecksums":
|
||||||
|
Console.WriteLine("Comparing all md5 checksum files. If there is none, creating one.");
|
||||||
|
Console.ResetColor();
|
||||||
|
|
||||||
Chksum.compareChecksums();
|
Chksum.compareChecksums();
|
||||||
break;
|
break;
|
||||||
|
case "help":
|
||||||
|
PrintAvailableOptions();
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
|
Console.ForegroundColor = ConsoleColor.Red;
|
||||||
|
Console.WriteLine("Invalid option. Maybe you mistyped it?");
|
||||||
|
PrintAvailableOptions();
|
||||||
break;
|
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) {
|
private static string CalculateMD5(string filename) {
|
||||||
using (var md5 = System.Security.Cryptography.MD5.Create())
|
using (var md5 = System.Security.Cryptography.MD5.Create()) {
|
||||||
{
|
using (var stream = File.OpenRead(filename)) {
|
||||||
using (var stream = File.OpenRead(filename))
|
|
||||||
{
|
|
||||||
var hash = md5.ComputeHash(stream);
|
var hash = md5.ComputeHash(stream);
|
||||||
return BitConverter.ToString(hash).Replace("-", "").ToLowerInvariant();
|
return BitConverter.ToString(hash).Replace("-", "").ToLowerInvariant();
|
||||||
}
|
}
|
||||||
@ -110,5 +108,4 @@ public class Chksum {
|
|||||||
compareChecksums();
|
compareChecksums();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user