1
- using System . Threading . Tasks ;
1
+ using System ;
2
+ using System . Threading . Tasks ;
3
+ using BSS . HashTools ;
4
+ using System . Windows . Media ;
2
5
//
3
6
using BSS . Launcher ;
4
7
@@ -12,8 +15,60 @@ internal static async Task RestartExplorer()
12
15
await Task . Delay ( 1000 ) . ConfigureAwait ( false ) ;
13
16
xProcess . Run ( "C:\\ Windows\\ explorer.exe" ) ;
14
17
}
15
-
16
18
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
+ }
17
72
18
73
19
74
}
0 commit comments