Skip to content

Commit

Permalink
fixed a typo & improved readability
Browse files Browse the repository at this point in the history
  • Loading branch information
backslashspace committed Mar 16, 2024
1 parent e6caede commit 3e19870
Show file tree
Hide file tree
Showing 14 changed files with 636 additions and 639 deletions.
2 changes: 2 additions & 0 deletions Debug.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ private void SoftDebug()

private void Button_Debug(object sender, RoutedEventArgs e)
{
Common.VerboseHashCheck(@"C:\Users\dev0\Desktop\Textdokument (neu).txt", "c9f89ad7b3027c25b273ba0aa3f8b9aaaaeb92daee571ef12b21f382b9b701ee9");

//Debug.Write("test\n");

//(_, Int32 ExitCode) = xProcess.Run(Resource_Assets.Host_INIT_PathName, "e22afd680ce7b8f23fad799fa3beef2dbce66e42e8877a9f2f0e3fd0b55619c9", WaitForExit: true);
Expand Down
59 changes: 57 additions & 2 deletions MainWindow/CommonLogic.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using System.Threading.Tasks;
using System;
using System.Threading.Tasks;
using BSS.HashTools;
using System.Windows.Media;
//
using BSS.Launcher;

Expand All @@ -12,8 +15,60 @@ internal static async Task RestartExplorer()
await Task.Delay(1000).ConfigureAwait(false);
xProcess.Run("C:\\Windows\\explorer.exe");
}


///<returns><see langword="bool"/>[] { IsValid, IsPresent }</returns>
internal static Boolean[] VerboseHashCheck(String filePath, String expectedHash, xHash.Algorithm algorithm = xHash.Algorithm.SHA256)
{
String fileName;
String path;

try
{
if (xHash.CompareHash(filePath, expectedHash, algorithm))
{
return new Boolean[] { true, true };
}
else
{
(path, fileName) = CreatePathString(ref filePath);

LogBox.Add(path, Brushes.Gray);
LogBox.Add(fileName, Brushes.OrangeRed, stayInLine: true);
LogBox.Add(" ── ", Brushes.Gray, stayInLine: true);
LogBox.Add("Invalide Hash", Brushes.Red, stayInLine: true);

return new Boolean[] { false, true };
}
}
catch
{
(path, fileName) = CreatePathString(ref filePath);

LogBox.Add(path, Brushes.Gray);
LogBox.Add(fileName, Brushes.OrangeRed, stayInLine: true);
LogBox.Add(" ── ", Brushes.Gray, stayInLine: true);
LogBox.Add("File missing", Brushes.Red, stayInLine: true);

return new Boolean[] { false, false };
}

static (String path, String fileName) CreatePathString(ref String filePath)
{
String fileName;
String path = "";

String[] pathParts = filePath.Split('\\');

fileName = pathParts[pathParts.Length - 1];

for (UInt16 i = 0; i < pathParts.Length - 1; ++i)
{
path += pathParts[i] + "\\";
}

return (path, fileName);
}
}


}
Expand Down
Loading

0 comments on commit 3e19870

Please sign in to comment.