55using System . IO ;
66using System . Runtime . InteropServices ;
77using System . Text ;
8- using static TinyNvidiaUpdateChecker . Handlers . LibaryHandler ;
8+ using static TinyNvidiaUpdateChecker . Handlers . LibraryHandler ;
99
1010namespace TinyNvidiaUpdateChecker . Handlers
1111{
1212
13- class LibaryHandler
13+ class LibraryHandler
1414 {
1515 private static bool is64 = Environment . Is64BitOperatingSystem ;
1616
17- static List < LibaryRegistryPath > libaryRegistryList =
17+ static List < LibraryRegistryPath > libraryRegistryList
18+ =
1819 [
1920 /* WinRAR */
2021
21- new ( Registry . LocalMachine , @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\WinRAR archiver" , "InstallLocation" , Libary . WINRAR ) ,
22- new ( Registry . LocalMachine , @"SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\WinRAR archiver" , "InstallLocation" , Libary . WINRAR ) ,
22+ new ( Registry . LocalMachine , @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\WinRAR archiver" , "InstallLocation" , Library . WINRAR ) ,
23+ new ( Registry . LocalMachine , @"SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\WinRAR archiver" , "InstallLocation" , Library . WINRAR ) ,
2324
2425 /* 7-Zip */
2526
2627 // amd64 installer on amd64 system, or x86 on x86 system
27- new ( Registry . LocalMachine , @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\7-Zip" , "InstallLocation" , Libary . SEVENZIP ) ,
28+ new ( Registry . LocalMachine , @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\7-Zip" , "InstallLocation" , Library . SEVENZIP ) ,
2829
2930 // x86 intaller on amd64 system
30- new ( Registry . LocalMachine , @"SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\7-Zip" , "InstallLocation" , Libary . SEVENZIP ) ,
31+ new ( Registry . LocalMachine , @"SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\7-Zip" , "InstallLocation" , Library . SEVENZIP ) ,
3132
3233 // MSI amd64 installer on amd64 system, or x86 on x86 system
33- new ( Registry . LocalMachine , @"SOFTWARE\7-Zip" , "Path" , Libary . SEVENZIP ) ,
34+ new ( Registry . LocalMachine , @"SOFTWARE\7-Zip" , "Path" , Library . SEVENZIP ) ,
3435
3536 // MSI x86 intaller on amd64 system
36- new ( Registry . LocalMachine , @"SOFTWARE\WOW6432Node\7-Zip" , "Path" , Libary . SEVENZIP ) ,
37+ new ( Registry . LocalMachine , @"SOFTWARE\WOW6432Node\7-Zip" , "Path" , Library . SEVENZIP ) ,
3738 ] ;
3839
39- static List < LibaryPath > libaryPathList =
40+ static List < LibraryPath > LibraryPathList =
4041 [
4142 /* 7-Zip */
4243
4344 // scoop in user profile
44- new ( [ Environment . GetFolderPath ( Environment . SpecialFolder . UserProfile ) , "scoop" , "apps" , "7zip" , "current" ] , Libary . SEVENZIP ) ,
45+ new ( [ Environment . GetFolderPath ( Environment . SpecialFolder . UserProfile ) , "scoop" , "apps" , "7zip" , "current" ] , Library . SEVENZIP ) ,
4546
4647 // scoop in Program Data
47- new ( [ Environment . GetFolderPath ( Environment . SpecialFolder . CommonApplicationData ) , "scoop" , "apps" , "7zip" , "current" ] , Libary . SEVENZIP ) ,
48+ new ( [ Environment . GetFolderPath ( Environment . SpecialFolder . CommonApplicationData ) , "scoop" , "apps" , "7zip" , "current" ] , Library . SEVENZIP ) ,
4849
4950 // scoop local environment variable
50- new ( [ Environment . GetEnvironmentVariable ( "SCOOP" , EnvironmentVariableTarget . User ) , "apps" , "7zip" , "current" ] , Libary . SEVENZIP ) ,
51+ new ( [ Environment . GetEnvironmentVariable ( "SCOOP" , EnvironmentVariableTarget . User ) , "apps" , "7zip" , "current" ] , Library . SEVENZIP ) ,
5152
5253 // scoop global environment variable
53- new ( [ Environment . GetEnvironmentVariable ( "SCOOP_GLOBAL" , EnvironmentVariableTarget . Machine ) , "apps" , "7zip" , "current" ] , Libary . SEVENZIP ) ,
54+ new ( [ Environment . GetEnvironmentVariable ( "SCOOP_GLOBAL" , EnvironmentVariableTarget . Machine ) , "apps" , "7zip" , "current" ] , Library . SEVENZIP ) ,
5455
5556 // amd64 on amd64 system, or x86 on x86 system
56- new ( [ Environment . GetFolderPath ( Environment . SpecialFolder . ProgramFiles ) , "7-Zip" ] , Libary . SEVENZIP ) ,
57+ new ( [ Environment . GetFolderPath ( Environment . SpecialFolder . ProgramFiles ) , "7-Zip" ] , Library . SEVENZIP ) ,
5758
5859 // x86 on amd64 system
59- new ( [ Environment . GetFolderPath ( Environment . SpecialFolder . ProgramFilesX86 ) , "7-Zip" ] , Libary . SEVENZIP ) ,
60+ new ( [ Environment . GetFolderPath ( Environment . SpecialFolder . ProgramFilesX86 ) , "7-Zip" ] , Library . SEVENZIP ) ,
6061
6162 // custom path defined in config file
62- new ( [ ConfigurationHandler . ReadSetting ( "Custom 7-ZIP Libary Path" , null , false ) ] , Libary . SEVENZIP ) ,
63+ new ( [ ConfigurationHandler . ReadSetting ( "Custom 7-ZIP Library Path" , null , false ) ] , Library . SEVENZIP ) ,
6364
6465 /* WinRAR */
65- new ( [ ConfigurationHandler . ReadSetting ( "Custom WinRAR Libary Path" , null , false ) ] , Libary . WINRAR )
66+ new ( [ ConfigurationHandler . ReadSetting ( "Custom WinRAR Library Path" , null , false ) ] , Library . WINRAR )
6667 ] ;
6768
68- static Dictionary < string , Libary > cliList = new ( ) {
69- { "NanaZipC" , Libary . NANAZIP } // NanaZip
69+ static Dictionary < string , Library > cliList = new ( ) {
70+ { "NanaZipC" , Library . NANAZIP } // NanaZip
7071 } ;
7172
72- public enum Libary
73+ public enum Library
7374 {
7475 SEVENZIP ,
7576 WINRAR ,
7677 NANAZIP
7778 }
7879
79- public static LibaryFile EvaluateLibary ( )
80+ public static LibraryFile EvaluateLibrary ( )
8081 {
8182 foreach ( var entry in cliList )
8283 {
@@ -98,13 +99,14 @@ public static LibaryFile EvaluateLibary()
9899 if ( process . ExitCode == 0 )
99100 {
100101 string directoryPath = Path . GetDirectoryName ( exePath ) + @"\" ;
101- return new LibaryFile ( directoryPath , entry . Value , true ) ;
102+ return new LibraryFile ( directoryPath , entry . Value , true ) ;
102103 }
103104 }
104105 catch { }
105106 }
106107
107- foreach ( var entry in libaryRegistryList )
108+ foreach ( var entry in libraryRegistryList )
109+
108110 {
109111 try
110112 {
@@ -128,23 +130,23 @@ public static LibaryFile EvaluateLibary()
128130 path += @"\" ;
129131 }
130132
131- string exe = LibaryPath . GetExeFromLibary ( entry . libary ) ;
133+ string exe = LibraryPath . GetExeFromLibrary ( entry . library ) ;
132134 string exePath = Path . Combine ( path , exe ) ;
133135
134136 if ( Path . Exists ( exePath ) )
135137 {
136- return new LibaryFile ( path , entry . libary , true ) ;
138+ return new LibraryFile ( path , entry . library , true ) ;
137139 }
138140 }
139141 catch { }
140142 }
141143
142- foreach ( var entry in libaryPathList )
144+ foreach ( var entry in LibraryPathList )
143145 {
144146 if ( entry . validate ( ) )
145147 {
146148 string path = Path . Combine ( entry . path ) + @"\" ;
147- return new LibaryFile ( path , entry . libary , true ) ;
149+ return new LibraryFile ( path , entry . library , true ) ;
148150 }
149151 }
150152
@@ -167,22 +169,22 @@ public static string GetMainModuleFileName(this Process process, int buffer = 10
167169 }
168170 }
169171
170- class LibaryPath
172+ class LibraryPath
171173 {
172174 public string [ ] path ;
173- public LibaryHandler . Libary libary ;
175+ public LibraryHandler . Library library ;
174176
175- public LibaryPath ( string [ ] path , LibaryHandler . Libary libary )
177+ public LibraryPath ( string [ ] path , LibraryHandler . Library library )
176178 {
177179 this . path = path ;
178- this . libary = libary ;
180+ this . library = library ;
179181 }
180182
181183 public bool validate ( )
182184 {
183185 try
184186 {
185- string exe = GetExeFromLibary ( this . libary ) ;
187+ string exe = GetExeFromLibrary ( this . library ) ;
186188 string path = Path . Combine ( [ .. this . path , exe ] ) ;
187189
188190 if ( Path . Exists ( path ) )
@@ -195,30 +197,30 @@ public bool validate()
195197 return false ;
196198 }
197199
198- public static string GetExeFromLibary ( Libary libary )
200+ public static string GetExeFromLibrary ( Library library )
199201 {
200- return libary switch
202+ return library switch
201203 {
202- Libary . SEVENZIP => "7z.exe" ,
203- Libary . WINRAR => "winrar.exe" ,
204+ Library . SEVENZIP => "7z.exe" ,
205+ Library . WINRAR => "winrar.exe" ,
204206 _ => "" ,
205207 } ;
206208 }
207209 }
208210
209- class LibaryRegistryPath
211+ class LibraryRegistryPath
210212 {
211213 public RegistryKey key ;
212214 public string path ;
213215 public string name ;
214- public LibaryHandler . Libary libary ;
216+ public LibraryHandler . Library library ;
215217
216- public LibaryRegistryPath ( RegistryKey key , string path , string name , LibaryHandler . Libary libary )
218+ public LibraryRegistryPath ( RegistryKey key , string path , string name , LibraryHandler . Library library )
217219 {
218220 this . key = key ;
219221 this . path = path ;
220222 this . name = name ;
221- this . libary = libary ;
223+ this . library = library ;
222224 }
223225
224226 public RegistryHive getRegistryHive ( )
@@ -237,43 +239,43 @@ public RegistryHive getRegistryHive()
237239 /// <summary>
238240 /// Libaries that can extract the nvidia driver file
239241 /// </summary>
240- class LibaryFile
242+ class LibraryFile
241243 {
242244 string installationDirectory ;
243- LibaryHandler . Libary libary ;
245+ LibraryHandler . Library library ;
244246 bool isInstalled ;
245247
246- public LibaryFile ( string installationDirectory , LibaryHandler . Libary libary , bool isInstalled )
248+ public LibraryFile ( string installationDirectory , LibraryHandler . Library library , bool isInstalled )
247249 {
248250 this . installationDirectory = installationDirectory ;
249- this . libary = libary ;
251+ this . library = library ;
250252 this . isInstalled = isInstalled ;
251253 }
252254
253- public LibaryFile ( LibaryHandler . Libary libary , bool isInstalled )
255+ public LibraryFile ( LibraryHandler . Library library , bool isInstalled )
254256 {
255- this . libary = libary ;
257+ this . library = library ;
256258 this . isInstalled = isInstalled ;
257259 }
258260
259261 /// <summary>
260- /// Is the libary installed?
262+ /// Is the library installed?
261263 /// </summary>
262264 public bool IsInstalled ( )
263265 {
264266 return isInstalled ;
265267 }
266268
267269 /// <summary>
268- /// Libary name
270+ /// Library name
269271 /// </summary>
270- public LibaryHandler . Libary LibaryName ( )
272+ public LibraryHandler . Library LibraryName ( )
271273 {
272- return libary ;
274+ return library ;
273275 }
274276
275277 /// <summary>
276- /// Get the absolute path to the libary , ending with a backslash
278+ /// Get the absolute path to the library , ending with a backslash
277279 /// </summary>
278280 public string GetInstallationDirectory ( )
279281 {
@@ -282,7 +284,7 @@ public string GetInstallationDirectory()
282284
283285 public override string ToString ( )
284286 {
285- return $ "installationDirectory: { installationDirectory } | libary : { libary } | isInstalled: { isInstalled } ";
287+ return $ "installationDirectory: { installationDirectory } | library : { library } | isInstalled: { isInstalled } ";
286288 }
287289 }
288290}
0 commit comments