WIP code for Updater.exe
This commit is contained in:
parent
ccdfbfb2f0
commit
402c3a0154
7 changed files with 140 additions and 21 deletions
107
Ryujinx.Updater/Program.cs
Normal file
107
Ryujinx.Updater/Program.cs
Normal file
|
@ -0,0 +1,107 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Ryujinx.Updater
|
||||
{
|
||||
public class Program
|
||||
{
|
||||
public static string RyuDir = Environment.CurrentDirectory;
|
||||
|
||||
public static string updateSaveLocation;
|
||||
public static string metaFilePath;
|
||||
|
||||
public static string versionNumber;
|
||||
public static string downloadUrl;
|
||||
|
||||
private static void CloneDirectory(string root, string dest)
|
||||
{
|
||||
foreach (var directory in Directory.GetDirectories(root))
|
||||
{
|
||||
string dirName = Path.GetFileName(directory);
|
||||
|
||||
try
|
||||
{
|
||||
if (!Directory.Exists(Path.Combine(dest, dirName)))
|
||||
{
|
||||
Directory.CreateDirectory(Path.Combine(dest, dirName));
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
CloneDirectory(directory, Path.Combine(dest, dirName));
|
||||
}
|
||||
|
||||
foreach (var file in Directory.GetFiles(root))
|
||||
{
|
||||
try
|
||||
{
|
||||
File.Move(file, Path.Combine(dest, Path.GetFileName(file)), true);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[STAThread]
|
||||
public static void Main()
|
||||
{
|
||||
// Create Temp Directory
|
||||
|
||||
if (!Directory.Exists(Path.Combine(RyuDir, "Temp")))
|
||||
{
|
||||
Directory.CreateDirectory(Path.Combine(RyuDir, "Temp"));
|
||||
}
|
||||
|
||||
updateSaveLocation = Path.Combine(RyuDir, "Temp", "RyujinxPackage.zip");
|
||||
metaFilePath = Path.Combine(RyuDir, "Meta.json");
|
||||
|
||||
string[] metaFileData = File.ReadAllLines(metaFilePath);
|
||||
|
||||
versionNumber = metaFileData[0];
|
||||
downloadUrl = metaFileData[1];
|
||||
|
||||
using (WebClient client = new WebClient())
|
||||
{
|
||||
client.DownloadFile(downloadUrl, updateSaveLocation);
|
||||
}
|
||||
|
||||
foreach (string file in Directory.GetFiles(RyuDir, "*", SearchOption.AllDirectories))
|
||||
{
|
||||
if (Path.GetFileName(file) != "Config.json" && Path.GetFileName(file) != "Meta.json" && Path.GetFileName(file) != "RyujinxPackage.zip")
|
||||
{
|
||||
try
|
||||
{
|
||||
File.Delete(file);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ZipFile.ExtractToDirectory(updateSaveLocation, RyuDir, true);
|
||||
|
||||
CloneDirectory(Path.Combine(RyuDir, "publish"), RyuDir);
|
||||
Directory.Delete(Path.Combine(RyuDir, "publish"), true);
|
||||
Directory.Delete(Path.Combine(RyuDir, "Temp"), true);
|
||||
|
||||
Process.Start(Path.Combine(RyuDir, "Ryujinx.exe"));
|
||||
|
||||
Application.Exit();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
12
Ryujinx.Updater/Ryujinx.Updater.csproj
Normal file
12
Ryujinx.Updater/Ryujinx.Updater.csproj
Normal file
|
@ -0,0 +1,12 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>netcoreapp3.0</TargetFramework>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<StartupObject>Ryujinx.Updater.Program</StartupObject>
|
||||
<AssemblyName>Updater</AssemblyName>
|
||||
<ApplicationIcon>Ryujinx.ico</ApplicationIcon>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
BIN
Ryujinx.Updater/Ryujinx.ico
Normal file
BIN
Ryujinx.Updater/Ryujinx.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 106 KiB |
21
Ryujinx.sln
21
Ryujinx.sln
|
@ -4,6 +4,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
|||
VisualStudioVersion = 16.0.29613.14
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Ryujinx", "Ryujinx\Ryujinx.csproj", "{074045D4-3ED2-4711-9169-E385F2BFB5A0}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{529E361C-FEF5-4C07-A2F4-3351C45CADDD} = {529E361C-FEF5-4C07-A2F4-3351C45CADDD}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Ryujinx.Tests", "Ryujinx.Tests\Ryujinx.Tests.csproj", "{EBB55AEA-C7D7-4DEB-BF96-FA1789E225E9}"
|
||||
EndProject
|
||||
|
@ -33,7 +36,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Ryujinx.Graphics.Shader", "
|
|||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Ryujinx.Graphics.Nvdec", "Ryujinx.Graphics.Nvdec\Ryujinx.Graphics.Nvdec.csproj", "{85A0FA56-DC01-4A42-8808-70DAC76BD66D}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ryujinx.Debugger", "Ryujinx.Debugger\Ryujinx.Debugger.csproj", "{79E4EE34-9C5F-4BE6-8529-A49D32B5B0CC}"
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ryujinx.Updater", "Ryujinx.Updater\Ryujinx.Updater.csproj", "{529E361C-FEF5-4C07-A2F4-3351C45CADDD}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
|
@ -163,22 +166,6 @@ Global
|
|||
{85A0FA56-DC01-4A42-8808-70DAC76BD66D}.Profile Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{85A0FA56-DC01-4A42-8808-70DAC76BD66D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{85A0FA56-DC01-4A42-8808-70DAC76BD66D}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{2E02B7F3-245E-43B1-AE5B-44167A0FDA20}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{2E02B7F3-245E-43B1-AE5B-44167A0FDA20}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{2E02B7F3-245E-43B1-AE5B-44167A0FDA20}.Profile Debug|Any CPU.ActiveCfg = Profile Debug|Any CPU
|
||||
{2E02B7F3-245E-43B1-AE5B-44167A0FDA20}.Profile Debug|Any CPU.Build.0 = Profile Debug|Any CPU
|
||||
{2E02B7F3-245E-43B1-AE5B-44167A0FDA20}.Profile Release|Any CPU.ActiveCfg = Profile Release|Any CPU
|
||||
{2E02B7F3-245E-43B1-AE5B-44167A0FDA20}.Profile Release|Any CPU.Build.0 = Profile Release|Any CPU
|
||||
{2E02B7F3-245E-43B1-AE5B-44167A0FDA20}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{2E02B7F3-245E-43B1-AE5B-44167A0FDA20}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{79E4EE34-9C5F-4BE6-8529-A49D32B5B0CC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{79E4EE34-9C5F-4BE6-8529-A49D32B5B0CC}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{79E4EE34-9C5F-4BE6-8529-A49D32B5B0CC}.Profile Debug|Any CPU.ActiveCfg = Profile Debug|Any CPU
|
||||
{79E4EE34-9C5F-4BE6-8529-A49D32B5B0CC}.Profile Debug|Any CPU.Build.0 = Profile Debug|Any CPU
|
||||
{79E4EE34-9C5F-4BE6-8529-A49D32B5B0CC}.Profile Release|Any CPU.ActiveCfg = Profile Release|Any CPU
|
||||
{79E4EE34-9C5F-4BE6-8529-A49D32B5B0CC}.Profile Release|Any CPU.Build.0 = Profile Release|Any CPU
|
||||
{79E4EE34-9C5F-4BE6-8529-A49D32B5B0CC}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{79E4EE34-9C5F-4BE6-8529-A49D32B5B0CC}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
|
|
@ -89,6 +89,7 @@
|
|||
<ProjectReference Include="..\ARMeilleure\ARMeilleure.csproj" />
|
||||
<ProjectReference Include="..\Ryujinx.Graphics.OpenGL\Ryujinx.Graphics.OpenGL.csproj" />
|
||||
<ProjectReference Include="..\Ryujinx.Graphics.Gpu\Ryujinx.Graphics.Gpu.csproj" />
|
||||
<ProjectReference Include="..\Ryujinx.Updater\Ryujinx.Updater.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
@ -3,6 +3,7 @@ using Newtonsoft.Json.Linq;
|
|||
using Ryujinx.Common.Logging;
|
||||
using Ryujinx.Ui;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
|
@ -24,7 +25,7 @@ namespace Ryujinx.Updater.Parser
|
|||
|
||||
public static string _buildArt;
|
||||
|
||||
public static string RyuDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Ryujinx");
|
||||
public static string RyuDir = Environment.CurrentDirectory;
|
||||
public static WebClient Package = new WebClient();
|
||||
public static int PackageProgress;
|
||||
public static double Percentage;
|
||||
|
@ -77,8 +78,19 @@ namespace Ryujinx.Updater.Parser
|
|||
{
|
||||
if (dialog.Run() == (int)ResponseType.Yes)
|
||||
{
|
||||
dialog.Dispose();
|
||||
GrabPackage();
|
||||
try
|
||||
{
|
||||
// Start Updater.exe
|
||||
|
||||
string updaterPath = Path.Combine(RyuDir, "Updater.exe");
|
||||
|
||||
Process.Start(new ProcessStartInfo(updaterPath) { UseShellExecute = true });
|
||||
Application.Quit();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
GtkDialog.CreateErrorDialog(ex.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ namespace Ryujinx.Updater
|
|||
|
||||
try
|
||||
{
|
||||
Process.Start(new ProcessStartInfo(Path.Combine(_parentdir, "Ryujinx.exe"), "/C") { UseShellExecute = true });
|
||||
Process.Start(new ProcessStartInfo(Path.Combine(RyuDir, "Ryujinx.exe")) { UseShellExecute = true });
|
||||
Application.Quit();
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
|
Loading…
Add table
Reference in a new issue