name conflict fix

This commit is contained in:
pointfeev 2023-01-29 20:22:28 -05:00
parent d2dfc7b95a
commit 3d63457a45
9 changed files with 43 additions and 28 deletions

View file

@ -122,13 +122,13 @@ internal static class ParadoxLauncher
directory.GetSmokeApiComponents(out string api32, out _, out string api64, out _, out _, out _, out _, out _, out _);
if (steamOriginalSdk32 is not null && api32.IsResourceFile(ResourceIdentifier.Steamworks32))
{
steamOriginalSdk32.Write(api32);
steamOriginalSdk32.WriteResource(api32);
installForm?.UpdateUser("Corrected Steamworks: " + api32, LogTextBox.Action);
neededRepair = true;
}
if (steamOriginalSdk64 is not null && api64.IsResourceFile(ResourceIdentifier.Steamworks64))
{
steamOriginalSdk64.Write(api64);
steamOriginalSdk64.WriteResource(api64);
installForm?.UpdateUser("Corrected Steamworks: " + api64, LogTextBox.Action);
neededRepair = true;
}
@ -137,13 +137,13 @@ internal static class ParadoxLauncher
directory.GetScreamApiComponents(out api32, out _, out api64, out _, out _, out _);
if (epicOriginalSdk32 is not null && api32.IsResourceFile(ResourceIdentifier.EpicOnlineServices32))
{
epicOriginalSdk32.Write(api32);
epicOriginalSdk32.WriteResource(api32);
installForm?.UpdateUser("Corrected Epic Online Services: " + api32, LogTextBox.Action);
neededRepair = true;
}
if (epicOriginalSdk64 is not null && api64.IsResourceFile(ResourceIdentifier.EpicOnlineServices64))
{
epicOriginalSdk64.Write(api64);
epicOriginalSdk64.WriteResource(api64);
installForm?.UpdateUser("Corrected Epic Online Services: " + api64, LogTextBox.Action);
neededRepair = true;
}

View file

@ -126,7 +126,7 @@ internal static class SteamCMD
if (httpClient is null)
return;
byte[] file = await httpClient.GetByteArrayAsync(new Uri("https://steamcdn-a.akamaihd.net/client/installer/steamcmd.zip"));
file.Write(ArchivePath);
file.WriteResource(ArchivePath);
ZipFile.ExtractToDirectory(ArchivePath, DirectoryPath);
ArchivePath.Delete();
}

View file

@ -43,7 +43,7 @@ internal static class Koaloader
resourceIdentifier.GetProxyInfoFromIdentifier(out string _proxyName, out BinaryType _binaryType);
if (_proxyName != proxyName || _binaryType != binaryType)
continue;
resourceIdentifier.Write(path);
resourceIdentifier.WriteManifestResource(path);
break;
}
}
@ -213,7 +213,7 @@ internal static class Koaloader
}
path = rootDirectory + @"\SmokeAPI32.dll";
}
"SmokeAPI.steam_api.dll".Write(path);
"SmokeAPI.steam_api.dll".WriteManifestResource(path);
installForm?.UpdateUser(
$"Wrote SmokeAPI{(rootDirectory is not null && directory != rootDirectory ? " to root directory" : "")}: {Path.GetFileName(path)}",
LogTextBox.Action, false);
@ -230,7 +230,7 @@ internal static class Koaloader
}
path = rootDirectory + @"\SmokeAPI64.dll";
}
"SmokeAPI.steam_api64.dll".Write(path);
"SmokeAPI.steam_api64.dll".WriteManifestResource(path);
installForm?.UpdateUser(
$"Wrote SmokeAPI{(rootDirectory is not null && directory != rootDirectory ? " to root directory" : "")}: {Path.GetFileName(path)}",
LogTextBox.Action, false);
@ -253,7 +253,7 @@ internal static class Koaloader
}
path = rootDirectory + @"\ScreamAPI32.dll";
}
"ScreamAPI.EOSSDK-Win32-Shipping.dll".Write(path);
"ScreamAPI.EOSSDK-Win32-Shipping.dll".WriteManifestResource(path);
installForm?.UpdateUser(
$"Wrote ScreamAPI{(rootDirectory is not null && directory != rootDirectory ? " to root directory" : "")}: {Path.GetFileName(path)}",
LogTextBox.Action, false);
@ -270,7 +270,7 @@ internal static class Koaloader
}
path = rootDirectory + @"\ScreamAPI64.dll";
}
"ScreamAPI.EOSSDK-Win64-Shipping.dll".Write(path);
"ScreamAPI.EOSSDK-Win64-Shipping.dll".WriteManifestResource(path);
installForm?.UpdateUser(
$"Wrote ScreamAPI{(rootDirectory is not null && directory != rootDirectory ? " to root directory" : "")}: {Path.GetFileName(path)}",
LogTextBox.Action, false);
@ -293,7 +293,7 @@ internal static class Koaloader
}
path = rootDirectory + @"\UplayR1Unlocker32.dll";
}
"UplayR1.uplay_r1_loader.dll".Write(path);
"UplayR1.uplay_r1_loader.dll".WriteManifestResource(path);
installForm?.UpdateUser(
$"Wrote Uplay R1 Unlocker{(rootDirectory is not null && directory != rootDirectory ? " to root directory" : "")}: {Path.GetFileName(path)}",
LogTextBox.Action, false);
@ -311,7 +311,7 @@ internal static class Koaloader
}
path = rootDirectory + @"\UplayR1Unlocker64.dll";
}
"UplayR1.uplay_r1_loader64.dll".Write(path);
"UplayR1.uplay_r1_loader64.dll".WriteManifestResource(path);
installForm?.UpdateUser(
$"Wrote Uplay R1 Unlocker{(rootDirectory is not null && directory != rootDirectory ? " to root directory" : "")}: {Path.GetFileName(path)}",
LogTextBox.Action, false);
@ -330,7 +330,7 @@ internal static class Koaloader
}
path = rootDirectory + @"\UplayR2Unlocker32.dll";
}
"UplayR2.upc_r2_loader.dll".Write(path);
"UplayR2.upc_r2_loader.dll".WriteManifestResource(path);
installForm?.UpdateUser(
$"Wrote Uplay R2 Unlocker{(rootDirectory is not null && directory != rootDirectory ? " to root directory" : "")}: {Path.GetFileName(path)}",
LogTextBox.Action, false);
@ -348,7 +348,7 @@ internal static class Koaloader
}
path = rootDirectory + @"\UplayR2Unlocker64.dll";
}
"UplayR2.upc_r2_loader64.dll".Write(path);
"UplayR2.upc_r2_loader64.dll".WriteManifestResource(path);
installForm?.UpdateUser(
$"Wrote Uplay R2 Unlocker{(rootDirectory is not null && directory != rootDirectory ? " to root directory" : "")}: {Path.GetFileName(path)}",
LogTextBox.Action, false);

View file

@ -8,6 +8,7 @@ using System.Security.Cryptography;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using CreamInstaller.Forms;
using CreamInstaller.Utility;
namespace CreamInstaller.Resources;
@ -437,14 +438,28 @@ internal static class Resources
}
}
internal static void Write(this string resourceIdentifier, string filePath)
internal static void WriteManifestResource(this string resourceIdentifier, string filePath)
{
using Stream resource = Assembly.GetExecutingAssembly().GetManifestResourceStream("CreamInstaller.Resources." + resourceIdentifier);
try
{
using FileStream file = new(filePath, FileMode.Create, FileAccess.Write);
resource?.CopyTo(file);
}
#if DEBUG
catch (Exception e)
{
DebugForm.Current.Log("resource write exception for '" + resourceIdentifier + "' to '" + filePath + "': " + e);
}
#else
catch
{
//ignored
}
#endif
}
internal static void Write(this byte[] resource, string filePath)
internal static void WriteResource(this byte[] resource, string filePath)
{
using FileStream fileStream = new(filePath, FileMode.Create, FileAccess.Write);
fileStream.Write(resource);

View file

@ -150,7 +150,7 @@ internal static class ScreamAPI
}
if (api32_o.Exists(form: installForm))
{
"ScreamAPI.EOSSDK-Win32-Shipping.dll".Write(api32);
"ScreamAPI.EOSSDK-Win32-Shipping.dll".WriteManifestResource(api32);
installForm?.UpdateUser($"Wrote ScreamAPI: {Path.GetFileName(api32)}", LogTextBox.Action, false);
}
if (api64.Exists(form: installForm) && !api64_o.Exists(form: installForm))
@ -160,7 +160,7 @@ internal static class ScreamAPI
}
if (api64_o.Exists(form: installForm))
{
"ScreamAPI.EOSSDK-Win64-Shipping.dll".Write(api64);
"ScreamAPI.EOSSDK-Win64-Shipping.dll".WriteManifestResource(api64);
installForm?.UpdateUser($"Wrote ScreamAPI: {Path.GetFileName(api64)}", LogTextBox.Action, false);
}
if (generateConfig)

View file

@ -228,7 +228,7 @@ internal static class SmokeAPI
}
if (api32_o.Exists(form: installForm))
{
"SmokeAPI.steam_api.dll".Write(api32);
"SmokeAPI.steam_api.dll".WriteManifestResource(api32);
installForm?.UpdateUser($"Wrote SmokeAPI: {Path.GetFileName(api32)}", LogTextBox.Action, false);
}
if (api64.Exists(form: installForm) && !api64_o.Exists(form: installForm))
@ -238,7 +238,7 @@ internal static class SmokeAPI
}
if (api64_o.Exists(form: installForm))
{
"SmokeAPI.steam_api64.dll".Write(api64);
"SmokeAPI.steam_api64.dll".WriteManifestResource(api64);
installForm?.UpdateUser($"Wrote SmokeAPI: {Path.GetFileName(api64)}", LogTextBox.Action, false);
}
if (generateConfig)

View file

@ -120,7 +120,7 @@ internal static class UplayR1
}
if (api32_o.Exists(form: installForm))
{
"UplayR1.uplay_r1_loader.dll".Write(api32);
"UplayR1.uplay_r1_loader.dll".WriteManifestResource(api32);
installForm?.UpdateUser($"Wrote Uplay R1 Unlocker: {Path.GetFileName(api32)}", LogTextBox.Action, false);
}
if (api64.Exists(form: installForm) && !api64_o.Exists(form: installForm))
@ -130,7 +130,7 @@ internal static class UplayR1
}
if (api64_o.Exists(form: installForm))
{
"UplayR1.uplay_r1_loader64.dll".Write(api64);
"UplayR1.uplay_r1_loader64.dll".WriteManifestResource(api64);
installForm?.UpdateUser($"Wrote Uplay R1 Unlocker: {Path.GetFileName(api64)}", LogTextBox.Action, false);
}
if (generateConfig)

View file

@ -129,7 +129,7 @@ internal static class UplayR2
}
if (api32_o.Exists(form: installForm))
{
"UplayR2.upc_r2_loader.dll".Write(api);
"UplayR2.upc_r2_loader.dll".WriteManifestResource(api);
installForm?.UpdateUser($"Wrote Uplay R2 Unlocker: {Path.GetFileName(api)}", LogTextBox.Action, false);
}
api = old_api64.Exists(form: installForm) ? old_api64 : api64;
@ -140,7 +140,7 @@ internal static class UplayR2
}
if (api64_o.Exists(form: installForm))
{
"UplayR2.upc_r2_loader64.dll".Write(api);
"UplayR2.upc_r2_loader64.dll".WriteManifestResource(api);
installForm?.UpdateUser($"Wrote Uplay R2 Unlocker: {Path.GetFileName(api)}", LogTextBox.Action, false);
}
if (generateConfig)