Skip to content

Commit 3e19870

Browse files
fixed a typo & improved readability
1 parent e6caede commit 3e19870

File tree

14 files changed

+636
-639
lines changed

14 files changed

+636
-639
lines changed

Debug.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ private void SoftDebug()
6262

6363
private void Button_Debug(object sender, RoutedEventArgs e)
6464
{
65+
Common.VerboseHashCheck(@"C:\Users\dev0\Desktop\Textdokument (neu).txt", "c9f89ad7b3027c25b273ba0aa3f8b9aaaaeb92daee571ef12b21f382b9b701ee9");
66+
6567
//Debug.Write("test\n");
6668

6769
//(_, Int32 ExitCode) = xProcess.Run(Resource_Assets.Host_INIT_PathName, "e22afd680ce7b8f23fad799fa3beef2dbce66e42e8877a9f2f0e3fd0b55619c9", WaitForExit: true);

MainWindow/CommonLogic.cs

Lines changed: 57 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
using System.Threading.Tasks;
1+
using System;
2+
using System.Threading.Tasks;
3+
using BSS.HashTools;
4+
using System.Windows.Media;
25
//
36
using BSS.Launcher;
47

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

19+
///<returns><see langword="bool"/>[] { IsValid, IsPresent }</returns>
20+
internal static Boolean[] VerboseHashCheck(String filePath, String expectedHash, xHash.Algorithm algorithm = xHash.Algorithm.SHA256)
21+
{
22+
String fileName;
23+
String path;
24+
25+
try
26+
{
27+
if (xHash.CompareHash(filePath, expectedHash, algorithm))
28+
{
29+
return new Boolean[] { true, true };
30+
}
31+
else
32+
{
33+
(path, fileName) = CreatePathString(ref filePath);
34+
35+
LogBox.Add(path, Brushes.Gray);
36+
LogBox.Add(fileName, Brushes.OrangeRed, stayInLine: true);
37+
LogBox.Add(" ── ", Brushes.Gray, stayInLine: true);
38+
LogBox.Add("Invalide Hash", Brushes.Red, stayInLine: true);
39+
40+
return new Boolean[] { false, true };
41+
}
42+
}
43+
catch
44+
{
45+
(path, fileName) = CreatePathString(ref filePath);
46+
47+
LogBox.Add(path, Brushes.Gray);
48+
LogBox.Add(fileName, Brushes.OrangeRed, stayInLine: true);
49+
LogBox.Add(" ── ", Brushes.Gray, stayInLine: true);
50+
LogBox.Add("File missing", Brushes.Red, stayInLine: true);
51+
52+
return new Boolean[] { false, false };
53+
}
54+
55+
static (String path, String fileName) CreatePathString(ref String filePath)
56+
{
57+
String fileName;
58+
String path = "";
59+
60+
String[] pathParts = filePath.Split('\\');
61+
62+
fileName = pathParts[pathParts.Length - 1];
63+
64+
for (UInt16 i = 0; i < pathParts.Length - 1; ++i)
65+
{
66+
path += pathParts[i] + "\\";
67+
}
68+
69+
return (path, fileName);
70+
}
71+
}
1772

1873

1974
}

0 commit comments

Comments
 (0)