mirror of
https://github.com/ZuneDev/ZuneModdingHelper.git
synced 2026-07-27 13:12:21 -07:00
Prevented overwriting of backups when reapplying mod
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
using OwlCore.AbstractUI.Models;
|
using OwlCore.AbstractUI.Models;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Security.AccessControl;
|
using System.Security.AccessControl;
|
||||||
using System.Security.Principal;
|
using System.Security.Principal;
|
||||||
@@ -27,8 +28,10 @@ namespace ZuneModCore.Mods
|
|||||||
#pragma warning disable CA1416 // Validate platform compatibility
|
#pragma warning disable CA1416 // Validate platform compatibility
|
||||||
public override Task<string?> Apply()
|
public override Task<string?> Apply()
|
||||||
{
|
{
|
||||||
// Make a backup of the file
|
// Make a backup of the original file
|
||||||
File.Copy(WMVCORE_PATH, Path.Combine(StorageDirectory, "WMVCORE.original.dll"), true);
|
FileVersionInfo wmvDllVersionInfo = FileVersionInfo.GetVersionInfo(WMVCORE_PATH);
|
||||||
|
if (Version.Parse(wmvDllVersionInfo.ProductVersion!) <= new Version(12, 0, 10586, 0))
|
||||||
|
File.Copy(WMVCORE_PATH, Path.Combine(StorageDirectory, "WMVCORE.original.dll"), true);
|
||||||
|
|
||||||
// Get the working WMVCORE.dll
|
// Get the working WMVCORE.dll
|
||||||
string sourcePath = Path.Combine(
|
string sourcePath = Path.Combine(
|
||||||
|
|||||||
@@ -34,8 +34,12 @@ namespace ZuneModCore.Mods
|
|||||||
return Task.FromResult<string?>($"The file '{zsDllInfo.FullName}' does not exist.");
|
return Task.FromResult<string?>($"The file '{zsDllInfo.FullName}' does not exist.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make a backup of the file
|
// Make a backup if it doesn't already exist
|
||||||
File.Copy(zsDllInfo.FullName, Path.Combine(StorageDirectory, "ZuneService.original.dll"), true);
|
FileInfo zsDllBackupInfo = new(Path.Combine(StorageDirectory, "ZuneService.original.dll"));
|
||||||
|
if (zsDllBackupInfo.Exists)
|
||||||
|
{
|
||||||
|
File.Copy(zsDllInfo.FullName, zsDllBackupInfo.FullName, true);
|
||||||
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.Win32.Registry" Version="5.0.0" />
|
<PackageReference Include="Microsoft.Win32.Registry" Version="5.0.0" />
|
||||||
<PackageReference Include="OwlCore" Version="0.0.2" />
|
<PackageReference Include="OwlCore" Version="0.0.6" />
|
||||||
<PackageReference Include="System.IO.FileSystem.AccessControl" Version="5.0.0" />
|
<PackageReference Include="System.IO.FileSystem.AccessControl" Version="5.0.0" />
|
||||||
<PackageReference Include="TagLibSharp" Version="2.2.0" />
|
<PackageReference Include="TagLibSharp" Version="2.2.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
<PackageReference Include="Microsoft.AppCenter.Analytics" Version="4.2.0" />
|
<PackageReference Include="Microsoft.AppCenter.Analytics" Version="4.2.0" />
|
||||||
<PackageReference Include="Microsoft.AppCenter.Crashes" Version="4.2.0" />
|
<PackageReference Include="Microsoft.AppCenter.Crashes" Version="4.2.0" />
|
||||||
<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.31" />
|
<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.31" />
|
||||||
<PackageReference Include="OwlCore" Version="0.0.2" />
|
<PackageReference Include="OwlCore" Version="0.0.6" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
Reference in New Issue
Block a user