0
0
mirror of https://github.com/sp-tarkov/patcher.git synced 2025-02-12 14:50:45 -05:00

move resources to correct projects

This commit is contained in:
IsWaffle 2021-12-29 11:04:02 -05:00
parent a5a26d5550
commit 592daf6c64
12 changed files with 33 additions and 26 deletions

1
.gitattributes vendored
View File

@ -1,2 +1,3 @@
/Patcher/_port/Patcher/PatchGenerator/Resources/PatchClient.exe filter=lfs diff=lfs merge=lfs -text /Patcher/_port/Patcher/PatchGenerator/Resources/PatchClient.exe filter=lfs diff=lfs merge=lfs -text
/Patcher/PatcherUtils/Resources/PatchClient.exe filter=lfs diff=lfs merge=lfs -text /Patcher/PatcherUtils/Resources/PatchClient.exe filter=lfs diff=lfs merge=lfs -text
/Patcher/PatchGenerator/Resources/PatchClient.exe filter=lfs diff=lfs merge=lfs -text

View File

@ -9,10 +9,6 @@
<AvaloniaResource Include="Assets\**" /> <AvaloniaResource Include="Assets\**" />
<AvaloniaResource Remove="Assets\Styles.axaml" /> <AvaloniaResource Remove="Assets\Styles.axaml" />
<None Remove=".gitignore" /> <None Remove=".gitignore" />
<None Remove="Resources\xdelta3.exe" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Resources\xdelta3.exe" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@ -5,8 +5,10 @@ using PatcherUtils;
using ReactiveUI; using ReactiveUI;
using System; using System;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.IO;
using System.Linq; using System.Linq;
using System.Reactive.Disposables; using System.Reactive.Disposables;
using System.Reflection;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace PatchClient.ViewModels namespace PatchClient.ViewModels
@ -85,12 +87,18 @@ namespace PatchClient.ViewModels
{ {
Task.Run(async() => Task.Run(async() =>
{ {
LazyOperations.ExtractResourcesToTempDir(Assembly.GetExecutingAssembly());
PatchHelper patcher = new PatchHelper(Environment.CurrentDirectory, null, LazyOperations.PatchFolder); PatchHelper patcher = new PatchHelper(Environment.CurrentDirectory, null, LazyOperations.PatchFolder);
patcher.ProgressChanged += patcher_ProgressChanged; patcher.ProgressChanged += patcher_ProgressChanged;
string message = patcher.ApplyPatches(); string message = patcher.ApplyPatches();
LazyOperations.CleanupTempDir();
Directory.Delete(LazyOperations.PatchFolder, true);
await NavigateToWithDelay(new MessageViewModel(HostScreen, message), 400); await NavigateToWithDelay(new MessageViewModel(HostScreen, message), 400);
}); });
} }

View File

@ -20,6 +20,13 @@
<AvaloniaResource Include="Assets\**" /> <AvaloniaResource Include="Assets\**" />
<AvaloniaResource Remove="Assets\Styles.axaml" /> <AvaloniaResource Remove="Assets\Styles.axaml" />
<None Remove=".gitignore" /> <None Remove=".gitignore" />
<None Remove="Resources\7za.exe" />
<None Remove="Resources\PatchClient.exe" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Resources\7za.exe" />
<EmbeddedResource Include="Resources\PatchClient.exe" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Avalonia" Version="0.10.11" /> <PackageReference Include="Avalonia" Version="0.10.11" />

BIN
Patcher/PatchGenerator/Resources/PatchClient.exe (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -9,6 +9,7 @@ using System.Collections.ObjectModel;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
using System.Reactive.Disposables; using System.Reactive.Disposables;
using System.Reflection;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -68,6 +69,8 @@ namespace PatchGenerator.ViewModels
{ {
string patchOutputFolder = Path.Join(generationInfo.PatchName.FromCwd(), LazyOperations.PatchFolder); string patchOutputFolder = Path.Join(generationInfo.PatchName.FromCwd(), LazyOperations.PatchFolder);
LazyOperations.ExtractResourcesToTempDir(Assembly.GetExecutingAssembly());
PatchHelper patcher = new PatchHelper(generationInfo.SourceFolderPath, generationInfo.TargetFolderPath, patchOutputFolder); PatchHelper patcher = new PatchHelper(generationInfo.SourceFolderPath, generationInfo.TargetFolderPath, patchOutputFolder);
patcher.ProgressChanged += Patcher_ProgressChanged; patcher.ProgressChanged += Patcher_ProgressChanged;

View File

@ -43,7 +43,7 @@ namespace PatcherUtils
/// <param name="ResourceName"></param> /// <param name="ResourceName"></param>
/// <param name="OutputFilePath"></param> /// <param name="OutputFilePath"></param>
/// <remarks>The resource will not be streamed out if the <paramref name="OutputFilePath"/> already exists</remarks> /// <remarks>The resource will not be streamed out if the <paramref name="OutputFilePath"/> already exists</remarks>
private static void StreamResourceOut(string ResourceName, string OutputFilePath) private static void StreamResourceOut(Assembly assembly, string ResourceName, string OutputFilePath)
{ {
FileInfo outputFile = new FileInfo(OutputFilePath); FileInfo outputFile = new FileInfo(OutputFilePath);
@ -55,7 +55,7 @@ namespace PatcherUtils
} }
using (FileStream fs = File.Create(OutputFilePath)) using (FileStream fs = File.Create(OutputFilePath))
using (Stream s = Assembly.GetExecutingAssembly().GetManifestResourceStream(ResourceName)) using (Stream s = assembly.GetManifestResourceStream(ResourceName))
{ {
s.CopyTo(fs); s.CopyTo(fs);
} }
@ -64,25 +64,27 @@ namespace PatcherUtils
/// <summary> /// <summary>
/// Checks the resources in the assembly and streams them to the temp directory for later use. /// Checks the resources in the assembly and streams them to the temp directory for later use.
/// </summary> /// </summary>
public static void PrepTempDir() public static void ExtractResourcesToTempDir(Assembly assembly = null)
{ {
foreach (string resource in Assembly.GetExecutingAssembly().GetManifestResourceNames()) if(assembly == null) assembly = Assembly.GetExecutingAssembly();
foreach (string resource in assembly.GetManifestResourceNames())
{ {
switch (resource) switch (resource)
{ {
case string a when a.EndsWith(SevenZExe): case string a when a.EndsWith(SevenZExe):
{ {
StreamResourceOut(resource, SevenZExePath); StreamResourceOut(assembly, resource, SevenZExePath);
break; break;
} }
case string a when a.EndsWith(PatcherClient): case string a when a.EndsWith(PatcherClient):
{ {
StreamResourceOut(resource, PatcherClientPath); StreamResourceOut(assembly, resource, PatcherClientPath);
break; break;
} }
case string a when a.EndsWith(XDelta3EXE): case string a when a.EndsWith(XDelta3EXE):
{ {
StreamResourceOut(resource, XDelta3Path); StreamResourceOut(assembly, resource, XDelta3Path);
break; break;
} }
} }

View File

@ -180,8 +180,7 @@ namespace PatcherUtils
return false; return false;
} }
LazyOperations.CleanupTempDir(); LazyOperations.ExtractResourcesToTempDir();
LazyOperations.PrepTempDir();
List<FileInfo> SourceFiles = sourceDir.GetFiles("*", SearchOption.AllDirectories).ToList(); List<FileInfo> SourceFiles = sourceDir.GetFiles("*", SearchOption.AllDirectories).ToList();
@ -280,8 +279,7 @@ namespace PatcherUtils
return "One of the supplied directories doesn't exist"; return "One of the supplied directories doesn't exist";
} }
LazyOperations.CleanupTempDir(); LazyOperations.ExtractResourcesToTempDir();
LazyOperations.PrepTempDir();
List<FileInfo> SourceFiles = sourceDir.GetFiles("*", SearchOption.AllDirectories).ToList(); List<FileInfo> SourceFiles = sourceDir.GetFiles("*", SearchOption.AllDirectories).ToList();
@ -360,10 +358,6 @@ namespace PatcherUtils
RaiseProgressChanged(filesProcessed, fileCountTotal, deltaFile.Name, AdditionalInfo.ToArray()); RaiseProgressChanged(filesProcessed, fileCountTotal, deltaFile.Name, AdditionalInfo.ToArray());
} }
LazyOperations.CleanupTempDir();
Directory.Delete(LazyOperations.PatchFolder, true);
return $"Patching Complete. You can delete the patcher.exe file."; return $"Patching Complete. You can delete the patcher.exe file.";
} }
} }

View File

@ -5,14 +5,10 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<None Remove="Resources\7za.exe" />
<None Remove="Resources\PatchClient.exe" />
<None Remove="Resources\xdelta3.exe" /> <None Remove="Resources\xdelta3.exe" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<EmbeddedResource Include="Resources\7za.exe" />
<EmbeddedResource Include="Resources\PatchClient.exe" />
<EmbeddedResource Include="Resources\xdelta3.exe" /> <EmbeddedResource Include="Resources\xdelta3.exe" />
</ItemGroup> </ItemGroup>

Binary file not shown.