mirror of
https://github.com/stuff-by-3-random-dudes/UWUVCI-AIO-WPF
synced 2024-11-25 12:30:18 +00:00
Removed async, removed cnus.exe, added c2w_patcher
This commit is contained in:
parent
7df739c964
commit
686e577667
1 changed files with 19 additions and 15 deletions
|
@ -2,17 +2,16 @@
|
|||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Net.Http;
|
||||
using System.Net;
|
||||
using System.Security.Cryptography;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace UWUVCI_AIO_WPF.Classes
|
||||
{
|
||||
class ToolCheck
|
||||
{
|
||||
static string FolderName = new FileInfo(System.Reflection.Assembly.GetEntryAssembly().Location).DirectoryName + "\\bin\\Tools";
|
||||
public static string backupulr = @"https://github.com/Hotbrawl20/UWUVCI-Tools/raw/master/";
|
||||
public static string backupulr = @"https://github.com/Hotbrawl20/UWUVCI-Tools/raw/master/" + (Environment.Is64BitProcess ? "x64/" : "");
|
||||
public static string[] ToolNames =
|
||||
{
|
||||
"N64Converter.exe",
|
||||
|
@ -55,7 +54,7 @@ namespace UWUVCI_AIO_WPF.Classes
|
|||
"forwarder.dol",
|
||||
"gba1.zip",
|
||||
"gba2.zip",
|
||||
"CNUSPACKER.exe"
|
||||
"c2w_patcher.exe"
|
||||
};
|
||||
|
||||
public static bool DoesToolsFolderExist()
|
||||
|
@ -63,23 +62,28 @@ namespace UWUVCI_AIO_WPF.Classes
|
|||
return Directory.Exists(FolderName);
|
||||
}
|
||||
|
||||
public static async Task<bool> IsToolRightAsync(string name)
|
||||
public static bool IsToolRightAsync(string name)
|
||||
{
|
||||
var result = false;
|
||||
string md5Name = name + ".md5";
|
||||
string md5Path = FolderName + "\\" + md5Name;
|
||||
|
||||
using (var httpClient = new HttpClient())
|
||||
{
|
||||
using var response = await httpClient.GetStreamAsync(backupulr + md5Name);
|
||||
using var fs = new FileStream(md5Path, FileMode.Create);
|
||||
await response.CopyToAsync(fs);
|
||||
}
|
||||
|
||||
string filePath = FolderName + "\\" + name;
|
||||
|
||||
if (!File.Exists(filePath))
|
||||
return result;
|
||||
|
||||
using (var webClient = new WebClient())
|
||||
webClient.DownloadFile(backupulr + md5Name, md5Path);
|
||||
|
||||
var md5 = "";
|
||||
using (var sr = new StreamReader(md5Path))
|
||||
md5 = await sr.ReadToEndAsync();
|
||||
md5 = sr.ReadLine();
|
||||
|
||||
return CalculateMD5(md5Path) == md5;
|
||||
result = CalculateMD5(filePath) == md5.ToLower();
|
||||
|
||||
File.Delete(md5Path);
|
||||
|
||||
return result;
|
||||
}
|
||||
static string CalculateMD5(string filename)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue