more potential io exception fixes
This commit is contained in:
parent
720a28ead5
commit
2d773481cc
24 changed files with 460 additions and 336 deletions
|
@ -1,7 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.IO;
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using CreamInstaller.Platforms.Paradox;
|
using CreamInstaller.Platforms.Paradox;
|
||||||
|
@ -51,8 +50,8 @@ internal sealed class ContextMenuItem : ToolStripMenuItem
|
||||||
switch (imageIdentifier)
|
switch (imageIdentifier)
|
||||||
{
|
{
|
||||||
case "Paradox Launcher":
|
case "Paradox Launcher":
|
||||||
if (Directory.Exists(ParadoxLauncher.InstallPath))
|
if (ParadoxLauncher.InstallPath.DirectoryExists())
|
||||||
foreach (string file in Directory.EnumerateFiles(ParadoxLauncher.InstallPath, "*.exe"))
|
foreach (string file in ParadoxLauncher.InstallPath.EnumerateDirectory("*.exe"))
|
||||||
{
|
{
|
||||||
image = file.GetFileIconImage();
|
image = file.GetFileIconImage();
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -209,7 +209,7 @@ internal sealed class CustomTreeView : TreeView
|
||||||
foreach ((string directory, BinaryType _) in pair.Key.ExecutableDirectories)
|
foreach ((string directory, BinaryType _) in pair.Key.ExecutableDirectories)
|
||||||
{
|
{
|
||||||
string path = directory + @"\" + proxy + ".dll";
|
string path = directory + @"\" + proxy + ".dll";
|
||||||
if (!path.Exists(form: form) || path.IsResourceFile(ResourceIdentifier.Koaloader))
|
if (!path.FileExists(form: form) || path.IsResourceFile(ResourceIdentifier.Koaloader))
|
||||||
continue;
|
continue;
|
||||||
canUse = false;
|
canUse = false;
|
||||||
break;
|
break;
|
||||||
|
|
1
CreamInstaller/Forms/DialogForm.Designer.cs
generated
1
CreamInstaller/Forms/DialogForm.Designer.cs
generated
|
@ -91,7 +91,6 @@ namespace CreamInstaller.Forms
|
||||||
this.descriptionPanel.Controls.Add(this.icon);
|
this.descriptionPanel.Controls.Add(this.icon);
|
||||||
this.descriptionPanel.Controls.Add(this.descriptionLabel);
|
this.descriptionPanel.Controls.Add(this.descriptionLabel);
|
||||||
this.descriptionPanel.Dock = System.Windows.Forms.DockStyle.Fill;
|
this.descriptionPanel.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
this.descriptionPanel.FlowDirection = System.Windows.Forms.FlowDirection.TopDown;
|
|
||||||
this.descriptionPanel.Location = new System.Drawing.Point(0, 0);
|
this.descriptionPanel.Location = new System.Drawing.Point(0, 0);
|
||||||
this.descriptionPanel.Margin = new System.Windows.Forms.Padding(0);
|
this.descriptionPanel.Margin = new System.Windows.Forms.Padding(0);
|
||||||
this.descriptionPanel.Name = "descriptionPanel";
|
this.descriptionPanel.Name = "descriptionPanel";
|
||||||
|
|
|
@ -80,9 +80,9 @@ internal sealed partial class InstallForm : CustomForm
|
||||||
if (Program.Canceled)
|
if (Program.Canceled)
|
||||||
throw new CustomMessageException("The operation was canceled.");
|
throw new CustomMessageException("The operation was canceled.");
|
||||||
directory.GetKoaloaderComponents(out string old_config, out string config);
|
directory.GetKoaloaderComponents(out string old_config, out string config);
|
||||||
if (directory.GetKoaloaderProxies().Any(proxy => proxy.Exists(form: this) && proxy.IsResourceFile(ResourceIdentifier.Koaloader))
|
if (directory.GetKoaloaderProxies().Any(proxy => proxy.FileExists(form: this) && proxy.IsResourceFile(ResourceIdentifier.Koaloader))
|
||||||
|| directory != selection.RootDirectory && Koaloader.AutoLoadDLLs.Any(pair => (directory + @"\" + pair.dll).Exists(form: this))
|
|| directory != selection.RootDirectory && Koaloader.AutoLoadDLLs.Any(pair => (directory + @"\" + pair.dll).FileExists(form: this))
|
||||||
|| old_config.Exists(form: this) || config.Exists(form: this))
|
|| old_config.FileExists(form: this) || config.FileExists(form: this))
|
||||||
{
|
{
|
||||||
UpdateUser("Uninstalling Koaloader from " + selection.Name + $" in incorrect directory \"{directory}\" . . . ", LogTextBox.Operation);
|
UpdateUser("Uninstalling Koaloader from " + selection.Name + $" in incorrect directory \"{directory}\" . . . ", LogTextBox.Operation);
|
||||||
await Koaloader.Uninstall(directory, selection.RootDirectory, this);
|
await Koaloader.Uninstall(directory, selection.RootDirectory, this);
|
||||||
|
@ -95,9 +95,9 @@ internal sealed partial class InstallForm : CustomForm
|
||||||
if (Program.Canceled)
|
if (Program.Canceled)
|
||||||
throw new CustomMessageException("The operation was canceled.");
|
throw new CustomMessageException("The operation was canceled.");
|
||||||
directory.GetKoaloaderComponents(out string old_config, out string config);
|
directory.GetKoaloaderComponents(out string old_config, out string config);
|
||||||
if (directory.GetKoaloaderProxies().Any(proxy => proxy.Exists(form: this) && proxy.IsResourceFile(ResourceIdentifier.Koaloader))
|
if (directory.GetKoaloaderProxies().Any(proxy => proxy.FileExists(form: this) && proxy.IsResourceFile(ResourceIdentifier.Koaloader))
|
||||||
|| Koaloader.AutoLoadDLLs.Any(pair => (directory + @"\" + pair.dll).Exists(form: this)) || old_config.Exists(form: this)
|
|| Koaloader.AutoLoadDLLs.Any(pair => (directory + @"\" + pair.dll).FileExists(form: this)) || old_config.FileExists(form: this)
|
||||||
|| config.Exists(form: this))
|
|| config.FileExists(form: this))
|
||||||
{
|
{
|
||||||
UpdateUser("Uninstalling Koaloader from " + selection.Name + $" in directory \"{directory}\" . . . ", LogTextBox.Operation);
|
UpdateUser("Uninstalling Koaloader from " + selection.Name + $" in directory \"{directory}\" . . . ", LogTextBox.Operation);
|
||||||
await Koaloader.Uninstall(directory, selection.RootDirectory, this);
|
await Koaloader.Uninstall(directory, selection.RootDirectory, this);
|
||||||
|
@ -115,9 +115,9 @@ internal sealed partial class InstallForm : CustomForm
|
||||||
directory.GetSmokeApiComponents(out string api32, out string api32_o, out string api64, out string api64_o, out string old_config,
|
directory.GetSmokeApiComponents(out string api32, out string api32_o, out string api64, out string api64_o, out string old_config,
|
||||||
out string config, out string old_log, out string log, out string cache);
|
out string config, out string old_log, out string log, out string cache);
|
||||||
if (uninstallProxy
|
if (uninstallProxy
|
||||||
? api32_o.Exists(form: this) || api64_o.Exists(form: this) || old_config.Exists(form: this) || config.Exists(form: this)
|
? api32_o.FileExists(form: this) || api64_o.FileExists(form: this) || old_config.FileExists(form: this) || config.FileExists(form: this)
|
||||||
|| old_log.Exists(form: this) || log.Exists(form: this) || cache.Exists(form: this)
|
|| old_log.FileExists(form: this) || log.FileExists(form: this) || cache.FileExists(form: this)
|
||||||
: api32.Exists(form: this) || api64.Exists(form: this))
|
: api32.FileExists(form: this) || api64.FileExists(form: this))
|
||||||
{
|
{
|
||||||
UpdateUser(
|
UpdateUser(
|
||||||
$"{(uninstallProxy ? "Uninstalling" : "Installing")} SmokeAPI" + $" {(uninstallProxy ? "from" : "for")} " + selection.Name
|
$"{(uninstallProxy ? "Uninstalling" : "Installing")} SmokeAPI" + $" {(uninstallProxy ? "from" : "for")} " + selection.Name
|
||||||
|
@ -132,8 +132,8 @@ internal sealed partial class InstallForm : CustomForm
|
||||||
{
|
{
|
||||||
directory.GetScreamApiComponents(out string api32, out string api32_o, out string api64, out string api64_o, out string config, out string log);
|
directory.GetScreamApiComponents(out string api32, out string api32_o, out string api64, out string api64_o, out string config, out string log);
|
||||||
if (uninstallProxy
|
if (uninstallProxy
|
||||||
? api32_o.Exists(form: this) || api64_o.Exists(form: this) || config.Exists(form: this) || log.Exists(form: this)
|
? api32_o.FileExists(form: this) || api64_o.FileExists(form: this) || config.FileExists(form: this) || log.FileExists(form: this)
|
||||||
: api32.Exists(form: this) || api64.Exists(form: this))
|
: api32.FileExists(form: this) || api64.FileExists(form: this))
|
||||||
{
|
{
|
||||||
UpdateUser(
|
UpdateUser(
|
||||||
$"{(uninstallProxy ? "Uninstalling" : "Installing")} ScreamAPI" + $" {(uninstallProxy ? "from" : "for")} " + selection.Name
|
$"{(uninstallProxy ? "Uninstalling" : "Installing")} ScreamAPI" + $" {(uninstallProxy ? "from" : "for")} " + selection.Name
|
||||||
|
@ -148,8 +148,8 @@ internal sealed partial class InstallForm : CustomForm
|
||||||
{
|
{
|
||||||
directory.GetUplayR1Components(out string api32, out string api32_o, out string api64, out string api64_o, out string config, out string log);
|
directory.GetUplayR1Components(out string api32, out string api32_o, out string api64, out string api64_o, out string config, out string log);
|
||||||
if (uninstallProxy
|
if (uninstallProxy
|
||||||
? api32_o.Exists(form: this) || api64_o.Exists(form: this) || config.Exists(form: this) || log.Exists(form: this)
|
? api32_o.FileExists(form: this) || api64_o.FileExists(form: this) || config.FileExists(form: this) || log.FileExists(form: this)
|
||||||
: api32.Exists(form: this) || api64.Exists(form: this))
|
: api32.FileExists(form: this) || api64.FileExists(form: this))
|
||||||
{
|
{
|
||||||
UpdateUser(
|
UpdateUser(
|
||||||
$"{(uninstallProxy ? "Uninstalling" : "Installing")} Uplay R1 Unlocker" + $" {(uninstallProxy ? "from" : "for")} " + selection.Name
|
$"{(uninstallProxy ? "Uninstalling" : "Installing")} Uplay R1 Unlocker" + $" {(uninstallProxy ? "from" : "for")} " + selection.Name
|
||||||
|
@ -161,8 +161,8 @@ internal sealed partial class InstallForm : CustomForm
|
||||||
}
|
}
|
||||||
directory.GetUplayR2Components(out string old_api32, out string old_api64, out api32, out api32_o, out api64, out api64_o, out config, out log);
|
directory.GetUplayR2Components(out string old_api32, out string old_api64, out api32, out api32_o, out api64, out api64_o, out config, out log);
|
||||||
if (uninstallProxy
|
if (uninstallProxy
|
||||||
? api32_o.Exists(form: this) || api64_o.Exists(form: this) || config.Exists(form: this) || log.Exists(form: this)
|
? api32_o.FileExists(form: this) || api64_o.FileExists(form: this) || config.FileExists(form: this) || log.FileExists(form: this)
|
||||||
: old_api32.Exists(form: this) || old_api64.Exists(form: this) || api32.Exists(form: this) || api64.Exists(form: this))
|
: old_api32.FileExists(form: this) || old_api64.FileExists(form: this) || api32.FileExists(form: this) || api64.FileExists(form: this))
|
||||||
{
|
{
|
||||||
UpdateUser(
|
UpdateUser(
|
||||||
$"{(uninstallProxy ? "Uninstalling" : "Installing")} Uplay R2 Unlocker" + $" {(uninstallProxy ? "from" : "for")} " + selection.Name
|
$"{(uninstallProxy ? "Uninstalling" : "Installing")} Uplay R2 Unlocker" + $" {(uninstallProxy ? "from" : "for")} " + selection.Name
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
@ -520,15 +519,15 @@ internal sealed partial class SelectForm : CustomForm
|
||||||
if (!scan && (programsToScan is null || !programsToScan.Any() || forceProvideChoices))
|
if (!scan && (programsToScan is null || !programsToScan.Any() || forceProvideChoices))
|
||||||
{
|
{
|
||||||
List<(Platform platform, string id, string name, bool alreadySelected)> gameChoices = new();
|
List<(Platform platform, string id, string name, bool alreadySelected)> gameChoices = new();
|
||||||
if (Directory.Exists(ParadoxLauncher.InstallPath))
|
if (ParadoxLauncher.InstallPath.DirectoryExists())
|
||||||
gameChoices.Add((Platform.Paradox, "PL", "Paradox Launcher",
|
gameChoices.Add((Platform.Paradox, "PL", "Paradox Launcher",
|
||||||
programsToScan is not null && programsToScan.Any(p => p.platform is Platform.Paradox && p.id == "PL")));
|
programsToScan is not null && programsToScan.Any(p => p.platform is Platform.Paradox && p.id == "PL")));
|
||||||
if (Directory.Exists(SteamLibrary.InstallPath))
|
if (SteamLibrary.InstallPath.DirectoryExists())
|
||||||
foreach ((string appId, string name, string _, int _, string _) in (await SteamLibrary.GetGames()).Where(g
|
foreach ((string appId, string name, string _, int _, string _) in (await SteamLibrary.GetGames()).Where(g
|
||||||
=> !Program.IsGameBlocked(g.name, g.gameDirectory)))
|
=> !Program.IsGameBlocked(g.name, g.gameDirectory)))
|
||||||
gameChoices.Add((Platform.Steam, appId, name,
|
gameChoices.Add((Platform.Steam, appId, name,
|
||||||
programsToScan is not null && programsToScan.Any(p => p.platform is Platform.Steam && p.id == appId)));
|
programsToScan is not null && programsToScan.Any(p => p.platform is Platform.Steam && p.id == appId)));
|
||||||
if (Directory.Exists(EpicLibrary.EpicManifestsPath))
|
if (EpicLibrary.EpicManifestsPath.DirectoryExists())
|
||||||
foreach (Manifest manifest in (await EpicLibrary.GetGames()).Where(m => !Program.IsGameBlocked(m.DisplayName, m.InstallLocation)))
|
foreach (Manifest manifest in (await EpicLibrary.GetGames()).Where(m => !Program.IsGameBlocked(m.DisplayName, m.InstallLocation)))
|
||||||
gameChoices.Add((Platform.Epic, manifest.CatalogNamespace, manifest.DisplayName,
|
gameChoices.Add((Platform.Epic, manifest.CatalogNamespace, manifest.DisplayName,
|
||||||
programsToScan is not null && programsToScan.Any(p => p.platform is Platform.Epic && p.id == manifest.CatalogNamespace)));
|
programsToScan is not null && programsToScan.Any(p => p.platform is Platform.Epic && p.id == manifest.CatalogNamespace)));
|
||||||
|
@ -571,10 +570,14 @@ internal sealed partial class SelectForm : CustomForm
|
||||||
progressLabel.Text = setup ? $"Setting up SteamCMD . . . {p}%" : $"Gathering and caching your applicable games and their DLCs . . . {p}%";
|
progressLabel.Text = setup ? $"Setting up SteamCMD . . . {p}%" : $"Gathering and caching your applicable games and their DLCs . . . {p}%";
|
||||||
progressBar.Value = p;
|
progressBar.Value = p;
|
||||||
};
|
};
|
||||||
if (Directory.Exists(SteamLibrary.InstallPath) && programsToScan is not null && programsToScan.Any(c => c.platform is Platform.Steam))
|
if (SteamLibrary.InstallPath.DirectoryExists() && programsToScan is not null && programsToScan.Any(c => c.platform is Platform.Steam))
|
||||||
{
|
{
|
||||||
progressLabel.Text = "Setting up SteamCMD . . . ";
|
progressLabel.Text = "Setting up SteamCMD . . . ";
|
||||||
await SteamCMD.Setup(iProgress);
|
if (!await SteamCMD.Setup(iProgress))
|
||||||
|
{
|
||||||
|
OnLoad(forceScan, true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
setup = false;
|
setup = false;
|
||||||
progressLabel.Text = "Gathering and caching your applicable games and their DLCs . . . ";
|
progressLabel.Text = "Gathering and caching your applicable games and their DLCs . . . ";
|
||||||
|
@ -748,10 +751,10 @@ internal sealed partial class SelectForm : CustomForm
|
||||||
string appInfoVDF = $@"{SteamCMD.AppInfoPath}\{id}.vdf";
|
string appInfoVDF = $@"{SteamCMD.AppInfoPath}\{id}.vdf";
|
||||||
string appInfoJSON = $@"{SteamCMD.AppInfoPath}\{id}.json";
|
string appInfoJSON = $@"{SteamCMD.AppInfoPath}\{id}.json";
|
||||||
string cooldown = $@"{ProgramData.CooldownPath}\{id}.txt";
|
string cooldown = $@"{ProgramData.CooldownPath}\{id}.txt";
|
||||||
if (appInfoVDF.Exists(form: this) || appInfoJSON.Exists(form: this))
|
if (appInfoVDF.FileExists(form: this) || appInfoJSON.FileExists(form: this))
|
||||||
{
|
{
|
||||||
List<ContextMenuItem> queries = new();
|
List<ContextMenuItem> queries = new();
|
||||||
if (appInfoJSON.Exists(form: this))
|
if (appInfoJSON.FileExists(form: this))
|
||||||
{
|
{
|
||||||
string platformString = selection is null || selection.Platform is Platform.Steam
|
string platformString = selection is null || selection.Platform is Platform.Steam
|
||||||
? "Steam Store "
|
? "Steam Store "
|
||||||
|
@ -760,7 +763,7 @@ internal sealed partial class SelectForm : CustomForm
|
||||||
: "";
|
: "";
|
||||||
queries.Add(new($"Open {platformString}Query", "Notepad", (_, _) => Diagnostics.OpenFileInNotepad(appInfoJSON)));
|
queries.Add(new($"Open {platformString}Query", "Notepad", (_, _) => Diagnostics.OpenFileInNotepad(appInfoJSON)));
|
||||||
}
|
}
|
||||||
if (appInfoVDF.Exists(form: this))
|
if (appInfoVDF.FileExists(form: this))
|
||||||
queries.Add(new("Open SteamCMD Query", "Notepad", (_, _) => Diagnostics.OpenFileInNotepad(appInfoVDF)));
|
queries.Add(new("Open SteamCMD Query", "Notepad", (_, _) => Diagnostics.OpenFileInNotepad(appInfoVDF)));
|
||||||
if (queries.Any())
|
if (queries.Any())
|
||||||
{
|
{
|
||||||
|
@ -769,9 +772,9 @@ internal sealed partial class SelectForm : CustomForm
|
||||||
items.Add(query);
|
items.Add(query);
|
||||||
items.Add(new ContextMenuItem("Refresh Queries", "Command Prompt", (_, _) =>
|
items.Add(new ContextMenuItem("Refresh Queries", "Command Prompt", (_, _) =>
|
||||||
{
|
{
|
||||||
appInfoVDF.Delete();
|
appInfoVDF.DeleteFile();
|
||||||
appInfoJSON.Delete();
|
appInfoJSON.DeleteFile();
|
||||||
cooldown.Delete();
|
cooldown.DeleteFile();
|
||||||
OnLoad(true);
|
OnLoad(true);
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
@ -798,9 +801,9 @@ internal sealed partial class SelectForm : CustomForm
|
||||||
{
|
{
|
||||||
directory.GetSmokeApiComponents(out string api32, out string api32_o, out string api64, out string api64_o, out string old_config,
|
directory.GetSmokeApiComponents(out string api32, out string api32_o, out string api64, out string api64_o, out string old_config,
|
||||||
out string config, out string old_log, out string log, out string cache);
|
out string config, out string old_log, out string log, out string cache);
|
||||||
if (api32.Exists(form: this) || api32_o.Exists(form: this) || api64.Exists(form: this) || api64_o.Exists(form: this)
|
if (api32.FileExists(form: this) || api32_o.FileExists(form: this) || api64.FileExists(form: this) || api64_o.FileExists(form: this)
|
||||||
|| old_config.Exists(form: this) || config.Exists(form: this) || old_log.Exists(form: this) || log.Exists(form: this)
|
|| old_config.FileExists(form: this) || config.FileExists(form: this) || old_log.FileExists(form: this) || log.FileExists(form: this)
|
||||||
|| cache.Exists(form: this))
|
|| cache.FileExists(form: this))
|
||||||
items.Add(new ContextMenuItem($"Open Steamworks Directory #{++steam}", "File Explorer",
|
items.Add(new ContextMenuItem($"Open Steamworks Directory #{++steam}", "File Explorer",
|
||||||
(_, _) => Diagnostics.OpenDirectoryInFileExplorer(directory)));
|
(_, _) => Diagnostics.OpenDirectoryInFileExplorer(directory)));
|
||||||
}
|
}
|
||||||
|
@ -809,8 +812,8 @@ internal sealed partial class SelectForm : CustomForm
|
||||||
{
|
{
|
||||||
directory.GetScreamApiComponents(out string api32, out string api32_o, out string api64, out string api64_o, out string config,
|
directory.GetScreamApiComponents(out string api32, out string api32_o, out string api64, out string api64_o, out string config,
|
||||||
out string log);
|
out string log);
|
||||||
if (api32.Exists(form: this) || api32_o.Exists(form: this) || api64.Exists(form: this) || api64_o.Exists(form: this)
|
if (api32.FileExists(form: this) || api32_o.FileExists(form: this) || api64.FileExists(form: this) || api64_o.FileExists(form: this)
|
||||||
|| config.Exists(form: this) || log.Exists(form: this))
|
|| config.FileExists(form: this) || log.FileExists(form: this))
|
||||||
items.Add(new ContextMenuItem($"Open EOS Directory #{++epic}", "File Explorer",
|
items.Add(new ContextMenuItem($"Open EOS Directory #{++epic}", "File Explorer",
|
||||||
(_, _) => Diagnostics.OpenDirectoryInFileExplorer(directory)));
|
(_, _) => Diagnostics.OpenDirectoryInFileExplorer(directory)));
|
||||||
}
|
}
|
||||||
|
@ -819,14 +822,15 @@ internal sealed partial class SelectForm : CustomForm
|
||||||
{
|
{
|
||||||
directory.GetUplayR1Components(out string api32, out string api32_o, out string api64, out string api64_o, out string config,
|
directory.GetUplayR1Components(out string api32, out string api32_o, out string api64, out string api64_o, out string config,
|
||||||
out string log);
|
out string log);
|
||||||
if (api32.Exists(form: this) || api32_o.Exists(form: this) || api64.Exists(form: this) || api64_o.Exists(form: this)
|
if (api32.FileExists(form: this) || api32_o.FileExists(form: this) || api64.FileExists(form: this) || api64_o.FileExists(form: this)
|
||||||
|| config.Exists(form: this) || log.Exists(form: this))
|
|| config.FileExists(form: this) || log.FileExists(form: this))
|
||||||
items.Add(new ContextMenuItem($"Open Uplay R1 Directory #{++r1}", "File Explorer",
|
items.Add(new ContextMenuItem($"Open Uplay R1 Directory #{++r1}", "File Explorer",
|
||||||
(_, _) => Diagnostics.OpenDirectoryInFileExplorer(directory)));
|
(_, _) => Diagnostics.OpenDirectoryInFileExplorer(directory)));
|
||||||
directory.GetUplayR2Components(out string old_api32, out string old_api64, out api32, out api32_o, out api64, out api64_o, out config,
|
directory.GetUplayR2Components(out string old_api32, out string old_api64, out api32, out api32_o, out api64, out api64_o, out config,
|
||||||
out log);
|
out log);
|
||||||
if (old_api32.Exists(form: this) || old_api64.Exists(form: this) || api32.Exists(form: this) || api32_o.Exists(form: this)
|
if (old_api32.FileExists(form: this) || old_api64.FileExists(form: this) || api32.FileExists(form: this)
|
||||||
|| api64.Exists(form: this) || api64_o.Exists(form: this) || config.Exists(form: this) || log.Exists(form: this))
|
|| api32_o.FileExists(form: this) || api64.FileExists(form: this) || api64_o.FileExists(form: this) || config.FileExists(form: this)
|
||||||
|
|| log.FileExists(form: this))
|
||||||
items.Add(new ContextMenuItem($"Open Uplay R2 Directory #{++r2}", "File Explorer",
|
items.Add(new ContextMenuItem($"Open Uplay R2 Directory #{++r2}", "File Explorer",
|
||||||
(_, _) => Diagnostics.OpenDirectoryInFileExplorer(directory)));
|
(_, _) => Diagnostics.OpenDirectoryInFileExplorer(directory)));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
@ -36,13 +35,13 @@ internal static class EpicLibrary
|
||||||
{
|
{
|
||||||
List<Manifest> games = new();
|
List<Manifest> games = new();
|
||||||
string manifests = EpicManifestsPath;
|
string manifests = EpicManifestsPath;
|
||||||
if (!Directory.Exists(manifests))
|
if (!manifests.DirectoryExists())
|
||||||
return games;
|
return games;
|
||||||
foreach (string file in Directory.EnumerateFiles(manifests, "*.item"))
|
foreach (string file in manifests.EnumerateDirectory("*.item"))
|
||||||
{
|
{
|
||||||
if (Program.Canceled)
|
if (Program.Canceled)
|
||||||
return games;
|
return games;
|
||||||
string json = file.Read();
|
string json = file.ReadFile();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Manifest manifest = JsonSerializer.Deserialize<Manifest>(json);
|
Manifest manifest = JsonSerializer.Deserialize<Manifest>(json);
|
||||||
|
|
|
@ -25,14 +25,14 @@ internal static class EpicStore
|
||||||
{
|
{
|
||||||
List<(string id, string name, string product, string icon, string developer)> dlcIds = new();
|
List<(string id, string name, string product, string icon, string developer)> dlcIds = new();
|
||||||
string cacheFile = ProgramData.AppInfoPath + @$"\{categoryNamespace}.json";
|
string cacheFile = ProgramData.AppInfoPath + @$"\{categoryNamespace}.json";
|
||||||
bool cachedExists = cacheFile.Exists();
|
bool cachedExists = cacheFile.FileExists();
|
||||||
Response response = null;
|
Response response = null;
|
||||||
if (!cachedExists || ProgramData.CheckCooldown(categoryNamespace, CooldownEntitlement))
|
if (!cachedExists || ProgramData.CheckCooldown(categoryNamespace, CooldownEntitlement))
|
||||||
{
|
{
|
||||||
response = await QueryGraphQL(categoryNamespace);
|
response = await QueryGraphQL(categoryNamespace);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
cacheFile.Write(JsonConvert.SerializeObject(response, Formatting.Indented));
|
cacheFile.WriteFile(JsonConvert.SerializeObject(response, Formatting.Indented));
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
|
@ -42,11 +42,11 @@ internal static class EpicStore
|
||||||
else
|
else
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
response = JsonConvert.DeserializeObject<Response>(cacheFile.Read());
|
response = JsonConvert.DeserializeObject<Response>(cacheFile.ReadFile());
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
cacheFile.Delete();
|
cacheFile.DeleteFile();
|
||||||
}
|
}
|
||||||
if (response is null)
|
if (response is null)
|
||||||
return dlcIds;
|
return dlcIds;
|
||||||
|
|
|
@ -90,28 +90,28 @@ internal static class ParadoxLauncher
|
||||||
foreach (string directory in selection.DllDirectories)
|
foreach (string directory in selection.DllDirectories)
|
||||||
{
|
{
|
||||||
bool koaloaderInstalled = Koaloader.AutoLoadDLLs.Select(pair => (pair.unlocker, path: directory + @"\" + pair.dll))
|
bool koaloaderInstalled = Koaloader.AutoLoadDLLs.Select(pair => (pair.unlocker, path: directory + @"\" + pair.dll))
|
||||||
.Any(pair => pair.path.Exists(form: form) && pair.path.IsResourceFile());
|
.Any(pair => pair.path.FileExists(form: form) && pair.path.IsResourceFile());
|
||||||
directory.GetSmokeApiComponents(out string api32, out string api32_o, out string api64, out string api64_o, out string old_config,
|
directory.GetSmokeApiComponents(out string api32, out string api32_o, out string api64, out string api64_o, out string old_config,
|
||||||
out string config, out _, out _, out _);
|
out string config, out _, out _, out _);
|
||||||
smokeInstalled = smokeInstalled || api32_o.Exists(form: form) || api64_o.Exists(form: form)
|
smokeInstalled = smokeInstalled || api32_o.FileExists(form: form) || api64_o.FileExists(form: form)
|
||||||
|| (old_config.Exists(form: form) || config.Exists(form: form)) && !koaloaderInstalled
|
|| (old_config.FileExists(form: form) || config.FileExists(form: form)) && !koaloaderInstalled
|
||||||
|| api32.Exists(form: form) && api32.IsResourceFile(ResourceIdentifier.Steamworks32)
|
|| api32.FileExists(form: form) && api32.IsResourceFile(ResourceIdentifier.Steamworks32)
|
||||||
|| api64.Exists(form: form) && api64.IsResourceFile(ResourceIdentifier.Steamworks64);
|
|| api64.FileExists(form: form) && api64.IsResourceFile(ResourceIdentifier.Steamworks64);
|
||||||
await SmokeAPI.Uninstall(directory, deleteOthers: false);
|
await SmokeAPI.Uninstall(directory, deleteOthers: false);
|
||||||
if (steamOriginalSdk32 is null && api32.Exists(form: form) && !api32.IsResourceFile(ResourceIdentifier.Steamworks32))
|
if (steamOriginalSdk32 is null && api32.FileExists(form: form) && !api32.IsResourceFile(ResourceIdentifier.Steamworks32))
|
||||||
steamOriginalSdk32 = api32.ReadBytes(true);
|
steamOriginalSdk32 = api32.ReadFileBytes(true);
|
||||||
if (steamOriginalSdk64 is null && api64.Exists(form: form) && !api64.IsResourceFile(ResourceIdentifier.Steamworks64))
|
if (steamOriginalSdk64 is null && api64.FileExists(form: form) && !api64.IsResourceFile(ResourceIdentifier.Steamworks64))
|
||||||
steamOriginalSdk64 = api64.ReadBytes(true);
|
steamOriginalSdk64 = api64.ReadFileBytes(true);
|
||||||
directory.GetScreamApiComponents(out api32, out api32_o, out api64, out api64_o, out config, out string log);
|
directory.GetScreamApiComponents(out api32, out api32_o, out api64, out api64_o, out config, out string log);
|
||||||
screamInstalled = screamInstalled || api32_o.Exists(form: form) || api64_o.Exists(form: form)
|
screamInstalled = screamInstalled || api32_o.FileExists(form: form) || api64_o.FileExists(form: form)
|
||||||
|| (config.Exists(form: form) || log.Exists(form: form)) && !koaloaderInstalled
|
|| (config.FileExists(form: form) || log.FileExists(form: form)) && !koaloaderInstalled
|
||||||
|| api32.Exists(form: form) && api32.IsResourceFile(ResourceIdentifier.EpicOnlineServices32)
|
|| api32.FileExists(form: form) && api32.IsResourceFile(ResourceIdentifier.EpicOnlineServices32)
|
||||||
|| api64.Exists(form: form) && api64.IsResourceFile(ResourceIdentifier.EpicOnlineServices64);
|
|| api64.FileExists(form: form) && api64.IsResourceFile(ResourceIdentifier.EpicOnlineServices64);
|
||||||
await ScreamAPI.Uninstall(directory, deleteOthers: false);
|
await ScreamAPI.Uninstall(directory, deleteOthers: false);
|
||||||
if (epicOriginalSdk32 is null && api32.Exists(form: form) && !api32.IsResourceFile(ResourceIdentifier.EpicOnlineServices32))
|
if (epicOriginalSdk32 is null && api32.FileExists(form: form) && !api32.IsResourceFile(ResourceIdentifier.EpicOnlineServices32))
|
||||||
epicOriginalSdk32 = api32.ReadBytes(true);
|
epicOriginalSdk32 = api32.ReadFileBytes(true);
|
||||||
if (epicOriginalSdk64 is null && api64.Exists(form: form) && !api64.IsResourceFile(ResourceIdentifier.EpicOnlineServices64))
|
if (epicOriginalSdk64 is null && api64.FileExists(form: form) && !api64.IsResourceFile(ResourceIdentifier.EpicOnlineServices64))
|
||||||
epicOriginalSdk64 = api64.ReadBytes(true);
|
epicOriginalSdk64 = api64.ReadFileBytes(true);
|
||||||
}
|
}
|
||||||
using DialogForm dialogForm = new(form);
|
using DialogForm dialogForm = new(form);
|
||||||
if (steamOriginalSdk32 is not null || steamOriginalSdk64 is not null || epicOriginalSdk32 is not null || epicOriginalSdk64 is not null)
|
if (steamOriginalSdk32 is not null || steamOriginalSdk64 is not null || epicOriginalSdk32 is not null || epicOriginalSdk64 is not null)
|
||||||
|
|
|
@ -2,13 +2,15 @@
|
||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using System.Drawing;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.IO.Compression;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
using CreamInstaller.Forms;
|
||||||
using CreamInstaller.Resources;
|
using CreamInstaller.Resources;
|
||||||
using CreamInstaller.Utility;
|
using CreamInstaller.Utility;
|
||||||
using Gameloop.Vdf.Linq;
|
using Gameloop.Vdf.Linq;
|
||||||
|
@ -117,61 +119,68 @@ internal static class SteamCMD
|
||||||
goto wait_for_lock;
|
goto wait_for_lock;
|
||||||
});
|
});
|
||||||
|
|
||||||
internal static async Task Setup(IProgress<int> progress)
|
internal static async Task<bool> Setup(IProgress<int> progress)
|
||||||
{
|
{
|
||||||
await Cleanup();
|
await Cleanup();
|
||||||
if (!FilePath.Exists())
|
if (!FilePath.FileExists())
|
||||||
{
|
{
|
||||||
HttpClient httpClient = HttpClientManager.HttpClient;
|
HttpClient httpClient = HttpClientManager.HttpClient;
|
||||||
if (httpClient is null)
|
if (httpClient is null)
|
||||||
return;
|
return false;
|
||||||
byte[] file = await httpClient.GetByteArrayAsync(new Uri("https://steamcdn-a.akamaihd.net/client/installer/steamcmd.zip"));
|
while (!Program.Canceled)
|
||||||
file.WriteResource(ArchivePath);
|
try
|
||||||
ZipFile.ExtractToDirectory(ArchivePath, DirectoryPath);
|
{
|
||||||
ArchivePath.Delete();
|
byte[] file = await httpClient.GetByteArrayAsync(new Uri("https://steamcdn-a.akamaihd.net/client/installer/steamcmd.zip"));
|
||||||
}
|
file.WriteResource(ArchivePath);
|
||||||
if (!DllPath.Exists())
|
ArchivePath.ExtractZip(DirectoryPath);
|
||||||
{
|
ArchivePath.DeleteFile();
|
||||||
FileSystemWatcher watcher = new(DirectoryPath) { Filter = "*", IncludeSubdirectories = true, EnableRaisingEvents = true };
|
break;
|
||||||
if (DllPath.Exists())
|
}
|
||||||
progress.Report(-15); // update (not used at the moment)
|
catch (Exception e)
|
||||||
else
|
{
|
||||||
progress.Report(-1660); // install
|
using DialogForm dialogForm = new(Form.ActiveForm);
|
||||||
int cur = 0;
|
if (dialogForm.Show(SystemIcons.Warning, "Failed to download SteamCMD:\n " + e.Message, "Retry", "OK") is not DialogResult.OK)
|
||||||
progress.Report(cur);
|
return false;
|
||||||
watcher.Changed += (_, _) => progress.Report(++cur);
|
}
|
||||||
_ = await Run(null);
|
|
||||||
watcher.Dispose();
|
|
||||||
}
|
}
|
||||||
|
if (DllPath.FileExists())
|
||||||
|
return true;
|
||||||
|
FileSystemWatcher watcher = new(DirectoryPath) { Filter = "*", IncludeSubdirectories = true, EnableRaisingEvents = true };
|
||||||
|
if (DllPath.FileExists())
|
||||||
|
progress.Report(-15); // update (not used at the moment)
|
||||||
|
else
|
||||||
|
progress.Report(-1660); // install
|
||||||
|
int cur = 0;
|
||||||
|
progress.Report(cur);
|
||||||
|
watcher.Changed += (_, _) => progress.Report(++cur);
|
||||||
|
_ = await Run(null);
|
||||||
|
watcher.Dispose();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static async Task Cleanup()
|
internal static async Task Cleanup()
|
||||||
=> await Task.Run(async () =>
|
=> await Task.Run(async () =>
|
||||||
{
|
{
|
||||||
if (!Directory.Exists(DirectoryPath))
|
if (!DirectoryPath.DirectoryExists())
|
||||||
return;
|
return;
|
||||||
await Kill();
|
await Kill();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (Directory.Exists(ConfigPath))
|
if (ConfigPath.DirectoryExists())
|
||||||
foreach (string file in Directory.EnumerateFiles(ConfigPath, "*.tmp"))
|
foreach (string file in ConfigPath.EnumerateDirectory("*.tmp"))
|
||||||
file.Delete();
|
file.DeleteFile();
|
||||||
foreach (string file in Directory.EnumerateFiles(DirectoryPath, "*.old"))
|
foreach (string file in DirectoryPath.EnumerateDirectory("*.old"))
|
||||||
file.Delete();
|
file.DeleteFile();
|
||||||
foreach (string file in Directory.EnumerateFiles(DirectoryPath, "*.delete"))
|
foreach (string file in DirectoryPath.EnumerateDirectory("*.delete"))
|
||||||
file.Delete();
|
file.DeleteFile();
|
||||||
foreach (string file in Directory.EnumerateFiles(DirectoryPath, "*.crash"))
|
foreach (string file in DirectoryPath.EnumerateDirectory("*.crash"))
|
||||||
file.Delete();
|
file.DeleteFile();
|
||||||
foreach (string file in Directory.EnumerateFiles(DirectoryPath, "*.ntfs_transaction_failed"))
|
foreach (string file in DirectoryPath.EnumerateDirectory("*.ntfs_transaction_failed"))
|
||||||
file.Delete();
|
file.DeleteFile();
|
||||||
if (Directory.Exists(AppCachePath))
|
AppCachePath.DeleteDirectory(); // this is definitely needed, so SteamCMD gets the latest information for us
|
||||||
Directory.Delete(AppCachePath, true); // this is definitely needed, so SteamCMD gets the latest information for us
|
DumpsPath.DeleteDirectory();
|
||||||
if (Directory.Exists(DumpsPath))
|
LogsPath.DeleteDirectory();
|
||||||
Directory.Delete(DumpsPath, true);
|
SteamAppsPath.DeleteDirectory(); // this is just a useless folder created from +app_update 4
|
||||||
if (Directory.Exists(LogsPath))
|
|
||||||
Directory.Delete(LogsPath, true);
|
|
||||||
if (Directory.Exists(SteamAppsPath))
|
|
||||||
Directory.Delete(SteamAppsPath, true); // this is just a useless folder created from +app_update 4
|
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
|
@ -187,7 +196,7 @@ internal static class SteamCMD
|
||||||
restart:
|
restart:
|
||||||
if (Program.Canceled)
|
if (Program.Canceled)
|
||||||
return null;
|
return null;
|
||||||
string output = appUpdateFile.Read();
|
string output = appUpdateFile.ReadFile();
|
||||||
if (output is null)
|
if (output is null)
|
||||||
{
|
{
|
||||||
output = await Run(appId) ?? "";
|
output = await Run(appId) ?? "";
|
||||||
|
@ -197,7 +206,7 @@ internal static class SteamCMD
|
||||||
{
|
{
|
||||||
output = $"\"{appId}\"\n" + output[openBracket..(1 + closeBracket)];
|
output = $"\"{appId}\"\n" + output[openBracket..(1 + closeBracket)];
|
||||||
output = output.Replace("ERROR! Failed to install app '4' (Invalid platform)", "");
|
output = output.Replace("ERROR! Failed to install app '4' (Invalid platform)", "");
|
||||||
appUpdateFile.Write(output);
|
appUpdateFile.WriteFile(output);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
goto restart;
|
goto restart;
|
||||||
|
@ -206,7 +215,7 @@ internal static class SteamCMD
|
||||||
return null;
|
return null;
|
||||||
if (!ValveDataFile.TryDeserialize(output, out VProperty appInfo) || appInfo.Value is VValue)
|
if (!ValveDataFile.TryDeserialize(output, out VProperty appInfo) || appInfo.Value is VValue)
|
||||||
{
|
{
|
||||||
appUpdateFile.Delete();
|
appUpdateFile.DeleteFile();
|
||||||
goto restart;
|
goto restart;
|
||||||
}
|
}
|
||||||
if (appInfo.Value.Children().ToList().Count == 0)
|
if (appInfo.Value.Children().ToList().Count == 0)
|
||||||
|
@ -221,8 +230,8 @@ internal static class SteamCMD
|
||||||
return appInfo;
|
return appInfo;
|
||||||
List<string> dlcAppIds = await ParseDlcAppIds(appInfo);
|
List<string> dlcAppIds = await ParseDlcAppIds(appInfo);
|
||||||
foreach (string dlcAppUpdateFile in dlcAppIds.Select(id => $@"{AppInfoPath}\{id}.vdf"))
|
foreach (string dlcAppUpdateFile in dlcAppIds.Select(id => $@"{AppInfoPath}\{id}.vdf"))
|
||||||
dlcAppUpdateFile.Delete();
|
dlcAppUpdateFile.DeleteFile();
|
||||||
appUpdateFile.Delete();
|
appUpdateFile.DeleteFile();
|
||||||
goto restart;
|
goto restart;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -275,7 +284,6 @@ internal static class SteamCMD
|
||||||
internal static void Dispose()
|
internal static void Dispose()
|
||||||
{
|
{
|
||||||
Kill().Wait();
|
Kill().Wait();
|
||||||
if (Directory.Exists(DirectoryPath))
|
DirectoryPath.DeleteDirectory();
|
||||||
Directory.Delete(DirectoryPath, true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,5 +1,4 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using CreamInstaller.Utility;
|
using CreamInstaller.Utility;
|
||||||
|
@ -48,13 +47,13 @@ internal static class SteamLibrary
|
||||||
=> await Task.Run(() =>
|
=> await Task.Run(() =>
|
||||||
{
|
{
|
||||||
List<(string appId, string name, string branch, int buildId, string gameDirectory)> games = new();
|
List<(string appId, string name, string branch, int buildId, string gameDirectory)> games = new();
|
||||||
if (Program.Canceled || !Directory.Exists(libraryDirectory))
|
if (Program.Canceled || !libraryDirectory.DirectoryExists())
|
||||||
return games;
|
return games;
|
||||||
foreach (string file in Directory.EnumerateFiles(libraryDirectory, "*.acf"))
|
foreach (string file in libraryDirectory.EnumerateDirectory("*.acf"))
|
||||||
{
|
{
|
||||||
if (Program.Canceled)
|
if (Program.Canceled)
|
||||||
return games;
|
return games;
|
||||||
if (!ValveDataFile.TryDeserialize(file.Read(), out VProperty result))
|
if (!ValveDataFile.TryDeserialize(file.ReadFile(), out VProperty result))
|
||||||
continue;
|
continue;
|
||||||
string appId = result.Value.GetChild("appid")?.ToString();
|
string appId = result.Value.GetChild("appid")?.ToString();
|
||||||
string installdir = result.Value.GetChild("installdir")?.ToString();
|
string installdir = result.Value.GetChild("installdir")?.ToString();
|
||||||
|
@ -85,14 +84,14 @@ internal static class SteamLibrary
|
||||||
if (Program.Canceled)
|
if (Program.Canceled)
|
||||||
return gameDirectories;
|
return gameDirectories;
|
||||||
string steamInstallPath = InstallPath;
|
string steamInstallPath = InstallPath;
|
||||||
if (steamInstallPath == null || !Directory.Exists(steamInstallPath))
|
if (steamInstallPath == null || !steamInstallPath.DirectoryExists())
|
||||||
return gameDirectories;
|
return gameDirectories;
|
||||||
string libraryFolder = steamInstallPath + @"\steamapps";
|
string libraryFolder = steamInstallPath + @"\steamapps";
|
||||||
if (!Directory.Exists(libraryFolder))
|
if (!libraryFolder.DirectoryExists())
|
||||||
return gameDirectories;
|
return gameDirectories;
|
||||||
gameDirectories.Add(libraryFolder);
|
gameDirectories.Add(libraryFolder);
|
||||||
string libraryFolders = libraryFolder + @"\libraryfolders.vdf";
|
string libraryFolders = libraryFolder + @"\libraryfolders.vdf";
|
||||||
if (!libraryFolders.Exists() || !ValveDataFile.TryDeserialize(libraryFolders.Read(), out VProperty result))
|
if (!libraryFolders.FileExists() || !ValveDataFile.TryDeserialize(libraryFolders.ReadFile(), out VProperty result))
|
||||||
return gameDirectories;
|
return gameDirectories;
|
||||||
foreach (VToken vToken in result.Value.Where(p => p is VProperty property && int.TryParse(property.Key, out int _)))
|
foreach (VToken vToken in result.Value.Where(p => p is VProperty property && int.TryParse(property.Key, out int _)))
|
||||||
{
|
{
|
||||||
|
@ -101,7 +100,7 @@ internal static class SteamLibrary
|
||||||
if (string.IsNullOrWhiteSpace(path))
|
if (string.IsNullOrWhiteSpace(path))
|
||||||
continue;
|
continue;
|
||||||
path += @"\steamapps";
|
path += @"\steamapps";
|
||||||
if (Directory.Exists(path) && !gameDirectories.Contains(path))
|
if (path.DirectoryExists() && !gameDirectories.Contains(path))
|
||||||
gameDirectories.Add(path);
|
gameDirectories.Add(path);
|
||||||
}
|
}
|
||||||
return gameDirectories;
|
return gameDirectories;
|
||||||
|
|
|
@ -35,7 +35,7 @@ internal static class SteamStore
|
||||||
if (Program.Canceled)
|
if (Program.Canceled)
|
||||||
return null;
|
return null;
|
||||||
string cacheFile = ProgramData.AppInfoPath + @$"\{appId}.json";
|
string cacheFile = ProgramData.AppInfoPath + @$"\{appId}.json";
|
||||||
bool cachedExists = cacheFile.Exists();
|
bool cachedExists = cacheFile.FileExists();
|
||||||
if (!cachedExists || ProgramData.CheckCooldown(appId, isDlc ? CooldownDlc : CooldownGame))
|
if (!cachedExists || ProgramData.CheckCooldown(appId, isDlc ? CooldownDlc : CooldownGame))
|
||||||
{
|
{
|
||||||
string response = await HttpClientManager.EnsureGet($"https://store.steampowered.com/api/appdetails?appids={appId}");
|
string response = await HttpClientManager.EnsureGet($"https://store.steampowered.com/api/appdetails?appids={appId}");
|
||||||
|
@ -64,7 +64,7 @@ internal static class SteamStore
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
cacheFile.Write(JsonConvert.SerializeObject(data, Formatting.Indented));
|
cacheFile.WriteFile(JsonConvert.SerializeObject(data, Formatting.Indented));
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
|
@ -118,11 +118,11 @@ internal static class SteamStore
|
||||||
if (cachedExists)
|
if (cachedExists)
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return JsonConvert.DeserializeObject<AppData>(cacheFile.Read());
|
return JsonConvert.DeserializeObject<AppData>(cacheFile.ReadFile());
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
cacheFile.Delete();
|
cacheFile.DeleteFile();
|
||||||
}
|
}
|
||||||
if (isDlc || attempts >= 10)
|
if (isDlc || attempts >= 10)
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
@ -48,7 +47,7 @@ internal static class Program
|
||||||
return true;
|
return true;
|
||||||
if (directory is null || ProtectedGameDirectoryExceptions.Contains(name))
|
if (directory is null || ProtectedGameDirectoryExceptions.Contains(name))
|
||||||
return false;
|
return false;
|
||||||
return ProtectedGameDirectories.Any(path => Directory.Exists(directory + path));
|
return ProtectedGameDirectories.Any(path => (directory + path).DirectoryExists());
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static bool IsProgramRunningDialog(Form form, ProgramSelection selection)
|
internal static bool IsProgramRunningDialog(Form form, ProgramSelection selection)
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using CreamInstaller.Components;
|
using CreamInstaller.Components;
|
||||||
using CreamInstaller.Resources;
|
using CreamInstaller.Resources;
|
||||||
|
using CreamInstaller.Utility;
|
||||||
using static CreamInstaller.Resources.Resources;
|
using static CreamInstaller.Resources.Resources;
|
||||||
|
|
||||||
namespace CreamInstaller;
|
namespace CreamInstaller;
|
||||||
|
@ -133,12 +133,12 @@ internal sealed class ProgramSelection
|
||||||
_ = All.Remove(this);
|
_ = All.Remove(this);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!Directory.Exists(RootDirectory))
|
if (!RootDirectory.DirectoryExists())
|
||||||
{
|
{
|
||||||
_ = All.Remove(this);
|
_ = All.Remove(this);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_ = DllDirectories.RemoveAll(directory => !Directory.Exists(directory));
|
_ = DllDirectories.RemoveAll(directory => !directory.DirectoryExists());
|
||||||
if (!DllDirectories.Any())
|
if (!DllDirectories.Any())
|
||||||
_ = All.Remove(this);
|
_ = All.Remove(this);
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,16 +60,16 @@ internal static class Koaloader
|
||||||
private static void CheckConfig(string directory, InstallForm installForm = null)
|
private static void CheckConfig(string directory, InstallForm installForm = null)
|
||||||
{
|
{
|
||||||
directory.GetKoaloaderComponents(out string old_config, out string config);
|
directory.GetKoaloaderComponents(out string old_config, out string config);
|
||||||
if (old_config.Exists(form: installForm))
|
if (old_config.FileExists(form: installForm))
|
||||||
{
|
{
|
||||||
if (!config.Exists(form: installForm))
|
if (!config.FileExists(form: installForm))
|
||||||
{
|
{
|
||||||
old_config.Move(config!);
|
old_config.MoveFile(config!);
|
||||||
installForm?.UpdateUser($"Converted old configuration: {Path.GetFileName(old_config)} -> {Path.GetFileName(config)}", LogTextBox.Action, false);
|
installForm?.UpdateUser($"Converted old configuration: {Path.GetFileName(old_config)} -> {Path.GetFileName(config)}", LogTextBox.Action, false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
old_config.Delete();
|
old_config.DeleteFile();
|
||||||
installForm?.UpdateUser($"Deleted old configuration: {Path.GetFileName(old_config)}", LogTextBox.Action, false);
|
installForm?.UpdateUser($"Deleted old configuration: {Path.GetFileName(old_config)}", LogTextBox.Action, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -79,15 +79,15 @@ internal static class Koaloader
|
||||||
{
|
{
|
||||||
/*if (installForm is not null)
|
/*if (installForm is not null)
|
||||||
installForm.UpdateUser("Generating Koaloader configuration for " + selection.Name + $" in directory \"{directory}\" . . . ", LogTextBox.Operation);*/
|
installForm.UpdateUser("Generating Koaloader configuration for " + selection.Name + $" in directory \"{directory}\" . . . ", LogTextBox.Operation);*/
|
||||||
config.Create(true, installForm);
|
config.CreateFile(true, installForm);
|
||||||
StreamWriter writer = new(config, true, Encoding.UTF8);
|
StreamWriter writer = new(config, true, Encoding.UTF8);
|
||||||
WriteConfig(writer, targets, modules, installForm);
|
WriteConfig(writer, targets, modules, installForm);
|
||||||
writer.Flush();
|
writer.Flush();
|
||||||
writer.Close();
|
writer.Close();
|
||||||
}
|
}
|
||||||
else if (config.Exists(form: installForm))
|
else if (config.FileExists(form: installForm))
|
||||||
{
|
{
|
||||||
config.Delete();
|
config.DeleteFile();
|
||||||
installForm?.UpdateUser($"Deleted unnecessary configuration: {Path.GetFileName(config)}", LogTextBox.Action, false);
|
installForm?.UpdateUser($"Deleted unnecessary configuration: {Path.GetFileName(config)}", LogTextBox.Action, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -136,26 +136,26 @@ internal static class Koaloader
|
||||||
=> await Task.Run(async () =>
|
=> await Task.Run(async () =>
|
||||||
{
|
{
|
||||||
directory.GetKoaloaderComponents(out string old_config, out string config);
|
directory.GetKoaloaderComponents(out string old_config, out string config);
|
||||||
foreach (string proxyPath in directory.GetKoaloaderProxies()
|
foreach (string proxyPath in directory.GetKoaloaderProxies().Where(proxyPath
|
||||||
.Where(proxyPath => proxyPath.Exists(form: installForm) && proxyPath.IsResourceFile(ResourceIdentifier.Koaloader)))
|
=> proxyPath.FileExists(form: installForm) && proxyPath.IsResourceFile(ResourceIdentifier.Koaloader)))
|
||||||
{
|
{
|
||||||
proxyPath.Delete();
|
proxyPath.DeleteFile();
|
||||||
installForm?.UpdateUser($"Deleted Koaloader: {Path.GetFileName(proxyPath)}", LogTextBox.Action, false);
|
installForm?.UpdateUser($"Deleted Koaloader: {Path.GetFileName(proxyPath)}", LogTextBox.Action, false);
|
||||||
}
|
}
|
||||||
foreach ((string unlocker, string path) in AutoLoadDLLs.Select(pair => (pair.unlocker, path: directory + @"\" + pair.dll))
|
foreach ((string unlocker, string path) in AutoLoadDLLs.Select(pair => (pair.unlocker, path: directory + @"\" + pair.dll))
|
||||||
.Where(pair => pair.path.Exists(form: installForm) && pair.path.IsResourceFile()))
|
.Where(pair => pair.path.FileExists(form: installForm) && pair.path.IsResourceFile()))
|
||||||
{
|
{
|
||||||
path.Delete();
|
path.DeleteFile();
|
||||||
installForm?.UpdateUser($"Deleted {unlocker}: {Path.GetFileName(path)}", LogTextBox.Action, false);
|
installForm?.UpdateUser($"Deleted {unlocker}: {Path.GetFileName(path)}", LogTextBox.Action, false);
|
||||||
}
|
}
|
||||||
if (deleteConfig && old_config.Exists(form: installForm))
|
if (deleteConfig && old_config.FileExists(form: installForm))
|
||||||
{
|
{
|
||||||
old_config.Delete();
|
old_config.DeleteFile();
|
||||||
installForm?.UpdateUser($"Deleted configuration: {Path.GetFileName(old_config)}", LogTextBox.Action, false);
|
installForm?.UpdateUser($"Deleted configuration: {Path.GetFileName(old_config)}", LogTextBox.Action, false);
|
||||||
}
|
}
|
||||||
if (deleteConfig && config.Exists(form: installForm))
|
if (deleteConfig && config.FileExists(form: installForm))
|
||||||
{
|
{
|
||||||
config.Delete();
|
config.DeleteFile();
|
||||||
installForm?.UpdateUser($"Deleted configuration: {Path.GetFileName(config)}", LogTextBox.Action, false);
|
installForm?.UpdateUser($"Deleted configuration: {Path.GetFileName(config)}", LogTextBox.Action, false);
|
||||||
}
|
}
|
||||||
await SmokeAPI.Uninstall(directory, installForm, deleteConfig);
|
await SmokeAPI.Uninstall(directory, installForm, deleteConfig);
|
||||||
|
@ -173,18 +173,18 @@ internal static class Koaloader
|
||||||
string proxy = selection.KoaloaderProxy ?? ProgramSelection.DefaultKoaloaderProxy;
|
string proxy = selection.KoaloaderProxy ?? ProgramSelection.DefaultKoaloaderProxy;
|
||||||
string path = directory + @"\" + proxy + ".dll";
|
string path = directory + @"\" + proxy + ".dll";
|
||||||
foreach (string _path in directory.GetKoaloaderProxies()
|
foreach (string _path in directory.GetKoaloaderProxies()
|
||||||
.Where(p => p != path && p.Exists(form: installForm) && p.IsResourceFile(ResourceIdentifier.Koaloader)))
|
.Where(p => p != path && p.FileExists(form: installForm) && p.IsResourceFile(ResourceIdentifier.Koaloader)))
|
||||||
{
|
{
|
||||||
_path.Delete();
|
_path.DeleteFile();
|
||||||
installForm?.UpdateUser($"Deleted Koaloader: {Path.GetFileName(_path)}", LogTextBox.Action, false);
|
installForm?.UpdateUser($"Deleted Koaloader: {Path.GetFileName(_path)}", LogTextBox.Action, false);
|
||||||
}
|
}
|
||||||
if (path.Exists(form: installForm) && !path.IsResourceFile(ResourceIdentifier.Koaloader))
|
if (path.FileExists(form: installForm) && !path.IsResourceFile(ResourceIdentifier.Koaloader))
|
||||||
throw new CustomMessageException("A non-Koaloader DLL named " + proxy + ".dll already exists in this directory!");
|
throw new CustomMessageException("A non-Koaloader DLL named " + proxy + ".dll already exists in this directory!");
|
||||||
path.WriteProxy(proxy, binaryType);
|
path.WriteProxy(proxy, binaryType);
|
||||||
installForm?.UpdateUser($"Wrote {(binaryType == BinaryType.BIT32 ? "32-bit" : "64-bit")} Koaloader: {Path.GetFileName(path)}", LogTextBox.Action,
|
installForm?.UpdateUser($"Wrote {(binaryType == BinaryType.BIT32 ? "32-bit" : "64-bit")} Koaloader: {Path.GetFileName(path)}", LogTextBox.Action,
|
||||||
false);
|
false);
|
||||||
bool bit32 = false, bit64 = false;
|
bool bit32 = false, bit64 = false;
|
||||||
foreach (string executable in Directory.EnumerateFiles(directory, "*.exe"))
|
foreach (string executable in directory.EnumerateDirectory("*.exe"))
|
||||||
if (executable.TryGetFileBinaryType(out BinaryType binaryType))
|
if (executable.TryGetFileBinaryType(out BinaryType binaryType))
|
||||||
{
|
{
|
||||||
switch (binaryType)
|
switch (binaryType)
|
||||||
|
@ -206,9 +206,9 @@ internal static class Koaloader
|
||||||
path = directory + @"\SmokeAPI32.dll";
|
path = directory + @"\SmokeAPI32.dll";
|
||||||
if (rootDirectory is not null && directory != rootDirectory)
|
if (rootDirectory is not null && directory != rootDirectory)
|
||||||
{
|
{
|
||||||
if (path.Exists(form: installForm))
|
if (path.FileExists(form: installForm))
|
||||||
{
|
{
|
||||||
path.Delete();
|
path.DeleteFile();
|
||||||
installForm?.UpdateUser($"Deleted SmokeAPI from non-root directory: {Path.GetFileName(path)}", LogTextBox.Action, false);
|
installForm?.UpdateUser($"Deleted SmokeAPI from non-root directory: {Path.GetFileName(path)}", LogTextBox.Action, false);
|
||||||
}
|
}
|
||||||
path = rootDirectory + @"\SmokeAPI32.dll";
|
path = rootDirectory + @"\SmokeAPI32.dll";
|
||||||
|
@ -223,9 +223,9 @@ internal static class Koaloader
|
||||||
path = directory + @"\SmokeAPI64.dll";
|
path = directory + @"\SmokeAPI64.dll";
|
||||||
if (rootDirectory is not null && directory != rootDirectory)
|
if (rootDirectory is not null && directory != rootDirectory)
|
||||||
{
|
{
|
||||||
if (path.Exists(form: installForm))
|
if (path.FileExists(form: installForm))
|
||||||
{
|
{
|
||||||
path.Delete();
|
path.DeleteFile();
|
||||||
installForm?.UpdateUser($"Deleted SmokeAPI from non-root directory: {Path.GetFileName(path)}", LogTextBox.Action, false);
|
installForm?.UpdateUser($"Deleted SmokeAPI from non-root directory: {Path.GetFileName(path)}", LogTextBox.Action, false);
|
||||||
}
|
}
|
||||||
path = rootDirectory + @"\SmokeAPI64.dll";
|
path = rootDirectory + @"\SmokeAPI64.dll";
|
||||||
|
@ -246,9 +246,9 @@ internal static class Koaloader
|
||||||
path = directory + @"\ScreamAPI32.dll";
|
path = directory + @"\ScreamAPI32.dll";
|
||||||
if (rootDirectory is not null && directory != rootDirectory)
|
if (rootDirectory is not null && directory != rootDirectory)
|
||||||
{
|
{
|
||||||
if (path.Exists(form: installForm))
|
if (path.FileExists(form: installForm))
|
||||||
{
|
{
|
||||||
path.Delete();
|
path.DeleteFile();
|
||||||
installForm?.UpdateUser($"Deleted ScreamAPI from non-root directory: {Path.GetFileName(path)}", LogTextBox.Action, false);
|
installForm?.UpdateUser($"Deleted ScreamAPI from non-root directory: {Path.GetFileName(path)}", LogTextBox.Action, false);
|
||||||
}
|
}
|
||||||
path = rootDirectory + @"\ScreamAPI32.dll";
|
path = rootDirectory + @"\ScreamAPI32.dll";
|
||||||
|
@ -263,9 +263,9 @@ internal static class Koaloader
|
||||||
path = directory + @"\ScreamAPI64.dll";
|
path = directory + @"\ScreamAPI64.dll";
|
||||||
if (rootDirectory is not null && directory != rootDirectory)
|
if (rootDirectory is not null && directory != rootDirectory)
|
||||||
{
|
{
|
||||||
if (path.Exists(form: installForm))
|
if (path.FileExists(form: installForm))
|
||||||
{
|
{
|
||||||
path.Delete();
|
path.DeleteFile();
|
||||||
installForm?.UpdateUser($"Deleted ScreamAPI from non-root directory: {Path.GetFileName(path)}", LogTextBox.Action, false);
|
installForm?.UpdateUser($"Deleted ScreamAPI from non-root directory: {Path.GetFileName(path)}", LogTextBox.Action, false);
|
||||||
}
|
}
|
||||||
path = rootDirectory + @"\ScreamAPI64.dll";
|
path = rootDirectory + @"\ScreamAPI64.dll";
|
||||||
|
@ -285,9 +285,9 @@ internal static class Koaloader
|
||||||
path = directory + @"\UplayR1Unlocker32.dll";
|
path = directory + @"\UplayR1Unlocker32.dll";
|
||||||
if (rootDirectory is not null && directory != rootDirectory)
|
if (rootDirectory is not null && directory != rootDirectory)
|
||||||
{
|
{
|
||||||
if (path.Exists(form: installForm))
|
if (path.FileExists(form: installForm))
|
||||||
{
|
{
|
||||||
path.Delete();
|
path.DeleteFile();
|
||||||
installForm?.UpdateUser($"Deleted Uplay R1 Unlocker from non-root directory: {Path.GetFileName(path)}", LogTextBox.Action,
|
installForm?.UpdateUser($"Deleted Uplay R1 Unlocker from non-root directory: {Path.GetFileName(path)}", LogTextBox.Action,
|
||||||
false);
|
false);
|
||||||
}
|
}
|
||||||
|
@ -303,9 +303,9 @@ internal static class Koaloader
|
||||||
path = directory + @"\UplayR1Unlocker64.dll";
|
path = directory + @"\UplayR1Unlocker64.dll";
|
||||||
if (rootDirectory is not null && directory != rootDirectory)
|
if (rootDirectory is not null && directory != rootDirectory)
|
||||||
{
|
{
|
||||||
if (path.Exists(form: installForm))
|
if (path.FileExists(form: installForm))
|
||||||
{
|
{
|
||||||
path.Delete();
|
path.DeleteFile();
|
||||||
installForm?.UpdateUser($"Deleted Uplay R1 Unlocker from non-root directory: {Path.GetFileName(path)}", LogTextBox.Action,
|
installForm?.UpdateUser($"Deleted Uplay R1 Unlocker from non-root directory: {Path.GetFileName(path)}", LogTextBox.Action,
|
||||||
false);
|
false);
|
||||||
}
|
}
|
||||||
|
@ -322,9 +322,9 @@ internal static class Koaloader
|
||||||
path = directory + @"\UplayR2Unlocker32.dll";
|
path = directory + @"\UplayR2Unlocker32.dll";
|
||||||
if (rootDirectory is not null && directory != rootDirectory)
|
if (rootDirectory is not null && directory != rootDirectory)
|
||||||
{
|
{
|
||||||
if (path.Exists(form: installForm))
|
if (path.FileExists(form: installForm))
|
||||||
{
|
{
|
||||||
path.Delete();
|
path.DeleteFile();
|
||||||
installForm?.UpdateUser($"Deleted Uplay R2 Unlocker from non-root directory: {Path.GetFileName(path)}", LogTextBox.Action,
|
installForm?.UpdateUser($"Deleted Uplay R2 Unlocker from non-root directory: {Path.GetFileName(path)}", LogTextBox.Action,
|
||||||
false);
|
false);
|
||||||
}
|
}
|
||||||
|
@ -340,9 +340,9 @@ internal static class Koaloader
|
||||||
path = directory + @"\UplayR2Unlocker64.dll";
|
path = directory + @"\UplayR2Unlocker64.dll";
|
||||||
if (rootDirectory is not null && directory != rootDirectory)
|
if (rootDirectory is not null && directory != rootDirectory)
|
||||||
{
|
{
|
||||||
if (path.Exists(form: installForm))
|
if (path.FileExists(form: installForm))
|
||||||
{
|
{
|
||||||
path.Delete();
|
path.DeleteFile();
|
||||||
installForm?.UpdateUser($"Deleted Uplay R2 Unlocker from non-root directory: {Path.GetFileName(path)}", LogTextBox.Action,
|
installForm?.UpdateUser($"Deleted Uplay R2 Unlocker from non-root directory: {Path.GetFileName(path)}", LogTextBox.Action,
|
||||||
false);
|
false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -507,9 +507,9 @@ internal static class Resources
|
||||||
=> await Task.Run(() =>
|
=> await Task.Run(() =>
|
||||||
{
|
{
|
||||||
List<(string path, BinaryType binaryType)> executables = new();
|
List<(string path, BinaryType binaryType)> executables = new();
|
||||||
if (Program.Canceled || !Directory.Exists(rootDirectory))
|
if (Program.Canceled || !rootDirectory.DirectoryExists())
|
||||||
return null;
|
return null;
|
||||||
foreach (string path in Directory.EnumerateFiles(rootDirectory, "*.exe", new EnumerationOptions { RecurseSubdirectories = true }))
|
foreach (string path in rootDirectory.EnumerateDirectory("*.exe", true))
|
||||||
{
|
{
|
||||||
if (Program.Canceled)
|
if (Program.Canceled)
|
||||||
return null;
|
return null;
|
||||||
|
@ -519,7 +519,7 @@ internal static class Resources
|
||||||
executables.Add((path, binaryType));
|
executables.Add((path, binaryType));
|
||||||
Thread.Sleep(1);
|
Thread.Sleep(1);
|
||||||
}
|
}
|
||||||
foreach (string path in Directory.EnumerateFiles(rootDirectory, "*.exe", new EnumerationOptions { RecurseSubdirectories = true }))
|
foreach (string path in rootDirectory.EnumerateDirectory("*.exe", true))
|
||||||
{
|
{
|
||||||
if (Program.Canceled)
|
if (Program.Canceled)
|
||||||
return null;
|
return null;
|
||||||
|
@ -546,10 +546,9 @@ internal static class Resources
|
||||||
=> await Task.Run(() =>
|
=> await Task.Run(() =>
|
||||||
{
|
{
|
||||||
List<string> dllDirectories = new();
|
List<string> dllDirectories = new();
|
||||||
if (Program.Canceled || !Directory.Exists(gameDirectory))
|
if (Program.Canceled || !gameDirectory.DirectoryExists())
|
||||||
return null;
|
return null;
|
||||||
foreach (string directory in Directory.EnumerateDirectories(gameDirectory, "*", new EnumerationOptions { RecurseSubdirectories = true })
|
foreach (string directory in gameDirectory.EnumerateSubdirectories("*", true).Append(gameDirectory))
|
||||||
.Append(gameDirectory))
|
|
||||||
{
|
{
|
||||||
if (Program.Canceled)
|
if (Program.Canceled)
|
||||||
return null;
|
return null;
|
||||||
|
@ -557,35 +556,36 @@ internal static class Resources
|
||||||
if (dllDirectories.Contains(subDirectory))
|
if (dllDirectories.Contains(subDirectory))
|
||||||
continue;
|
continue;
|
||||||
bool koaloaderInstalled = Koaloader.AutoLoadDLLs.Select(pair => (pair.unlocker, path: directory + @"\" + pair.dll))
|
bool koaloaderInstalled = Koaloader.AutoLoadDLLs.Select(pair => (pair.unlocker, path: directory + @"\" + pair.dll))
|
||||||
.Any(pair => pair.path.Exists(form: form) && pair.path.IsResourceFile());
|
.Any(pair => pair.path.FileExists(form: form) && pair.path.IsResourceFile());
|
||||||
if (platform is Platform.Steam or Platform.Paradox)
|
if (platform is Platform.Steam or Platform.Paradox)
|
||||||
{
|
{
|
||||||
subDirectory.GetSmokeApiComponents(out string api, out string api_o, out string api64, out string api64_o, out string old_config,
|
subDirectory.GetSmokeApiComponents(out string api, out string api_o, out string api64, out string api64_o, out string old_config,
|
||||||
out string config, out string old_log, out string log, out string cache);
|
out string config, out string old_log, out string log, out string cache);
|
||||||
if (api.Exists(form: form) || api_o.Exists(form: form) || api64.Exists(form: form) || api64_o.Exists(form: form)
|
if (api.FileExists(form: form) || api_o.FileExists(form: form) || api64.FileExists(form: form) || api64_o.FileExists(form: form)
|
||||||
|| (old_config.Exists(form: form) || config.Exists(form: form) || old_log.Exists(form: form) || log.Exists(form: form)
|
|| (old_config.FileExists(form: form) || config.FileExists(form: form) || old_log.FileExists(form: form) || log.FileExists(form: form)
|
||||||
|| cache.Exists(form: form)) && !koaloaderInstalled)
|
|| cache.FileExists(form: form)) && !koaloaderInstalled)
|
||||||
dllDirectories.Add(subDirectory);
|
dllDirectories.Add(subDirectory);
|
||||||
}
|
}
|
||||||
if (platform is Platform.Epic or Platform.Paradox)
|
if (platform is Platform.Epic or Platform.Paradox)
|
||||||
{
|
{
|
||||||
subDirectory.GetScreamApiComponents(out string api32, out string api32_o, out string api64, out string api64_o, out string config,
|
subDirectory.GetScreamApiComponents(out string api32, out string api32_o, out string api64, out string api64_o, out string config,
|
||||||
out string log);
|
out string log);
|
||||||
if (api32.Exists(form: form) || api32_o.Exists(form: form) || api64.Exists(form: form) || api64_o.Exists(form: form)
|
if (api32.FileExists(form: form) || api32_o.FileExists(form: form) || api64.FileExists(form: form) || api64_o.FileExists(form: form)
|
||||||
|| (config.Exists(form: form) || log.Exists(form: form)) && !koaloaderInstalled)
|
|| (config.FileExists(form: form) || log.FileExists(form: form)) && !koaloaderInstalled)
|
||||||
dllDirectories.Add(subDirectory);
|
dllDirectories.Add(subDirectory);
|
||||||
}
|
}
|
||||||
if (platform is Platform.Ubisoft)
|
if (platform is Platform.Ubisoft)
|
||||||
{
|
{
|
||||||
subDirectory.GetUplayR1Components(out string api32, out string api32_o, out string api64, out string api64_o, out string config,
|
subDirectory.GetUplayR1Components(out string api32, out string api32_o, out string api64, out string api64_o, out string config,
|
||||||
out string log);
|
out string log);
|
||||||
if (api32.Exists(form: form) || api32_o.Exists(form: form) || api64.Exists(form: form) || api64_o.Exists(form: form)
|
if (api32.FileExists(form: form) || api32_o.FileExists(form: form) || api64.FileExists(form: form) || api64_o.FileExists(form: form)
|
||||||
|| (config.Exists(form: form) || log.Exists(form: form)) && !koaloaderInstalled)
|
|| (config.FileExists(form: form) || log.FileExists(form: form)) && !koaloaderInstalled)
|
||||||
dllDirectories.Add(subDirectory);
|
dllDirectories.Add(subDirectory);
|
||||||
subDirectory.GetUplayR2Components(out string old_api32, out string old_api64, out api32, out api32_o, out api64, out api64_o, out config,
|
subDirectory.GetUplayR2Components(out string old_api32, out string old_api64, out api32, out api32_o, out api64, out api64_o, out config,
|
||||||
out log);
|
out log);
|
||||||
if (old_api32.Exists(form: form) || old_api64.Exists(form: form) || api32.Exists(form: form) || api32_o.Exists(form: form)
|
if (old_api32.FileExists(form: form) || old_api64.FileExists(form: form) || api32.FileExists(form: form) || api32_o.FileExists(form: form)
|
||||||
|| api64.Exists(form: form) || api64_o.Exists(form: form) || (config.Exists(form: form) || log.Exists(form: form)) && !koaloaderInstalled)
|
|| api64.FileExists(form: form) || api64_o.FileExists(form: form)
|
||||||
|
|| (config.FileExists(form: form) || log.FileExists(form: form)) && !koaloaderInstalled)
|
||||||
dllDirectories.Add(subDirectory);
|
dllDirectories.Add(subDirectory);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -604,7 +604,7 @@ internal static class Resources
|
||||||
|
|
||||||
private static string ComputeMD5(this string filePath)
|
private static string ComputeMD5(this string filePath)
|
||||||
{
|
{
|
||||||
if (!filePath.Exists())
|
if (!filePath.FileExists())
|
||||||
return null;
|
return null;
|
||||||
#pragma warning disable CA5351
|
#pragma warning disable CA5351
|
||||||
using MD5 md5 = MD5.Create();
|
using MD5 md5 = MD5.Create();
|
||||||
|
|
|
@ -39,16 +39,16 @@ internal static class ScreamAPI
|
||||||
{
|
{
|
||||||
/*if (installForm is not null)
|
/*if (installForm is not null)
|
||||||
installForm.UpdateUser("Generating ScreamAPI configuration for " + selection.Name + $" in directory \"{directory}\" . . . ", LogTextBox.Operation);*/
|
installForm.UpdateUser("Generating ScreamAPI configuration for " + selection.Name + $" in directory \"{directory}\" . . . ", LogTextBox.Operation);*/
|
||||||
config.Create(true, installForm);
|
config.CreateFile(true, installForm);
|
||||||
StreamWriter writer = new(config, true, Encoding.UTF8);
|
StreamWriter writer = new(config, true, Encoding.UTF8);
|
||||||
WriteConfig(writer, new(overrideCatalogItems.ToDictionary(pair => pair.Key, pair => pair.Value), PlatformIdComparer.String),
|
WriteConfig(writer, new(overrideCatalogItems.ToDictionary(pair => pair.Key, pair => pair.Value), PlatformIdComparer.String),
|
||||||
new(entitlements.ToDictionary(pair => pair.Key, pair => pair.Value), PlatformIdComparer.String), installForm);
|
new(entitlements.ToDictionary(pair => pair.Key, pair => pair.Value), PlatformIdComparer.String), installForm);
|
||||||
writer.Flush();
|
writer.Flush();
|
||||||
writer.Close();
|
writer.Close();
|
||||||
}
|
}
|
||||||
else if (config.Exists(form: installForm))
|
else if (config.FileExists(form: installForm))
|
||||||
{
|
{
|
||||||
config.Delete();
|
config.DeleteFile();
|
||||||
installForm?.UpdateUser($"Deleted unnecessary configuration: {Path.GetFileName(config)}", LogTextBox.Action, false);
|
installForm?.UpdateUser($"Deleted unnecessary configuration: {Path.GetFileName(config)}", LogTextBox.Action, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -105,36 +105,36 @@ internal static class ScreamAPI
|
||||||
=> await Task.Run(() =>
|
=> await Task.Run(() =>
|
||||||
{
|
{
|
||||||
directory.GetScreamApiComponents(out string api32, out string api32_o, out string api64, out string api64_o, out string config, out string log);
|
directory.GetScreamApiComponents(out string api32, out string api32_o, out string api64, out string api64_o, out string config, out string log);
|
||||||
if (api32_o.Exists(form: installForm))
|
if (api32_o.FileExists(form: installForm))
|
||||||
{
|
{
|
||||||
if (api32.Exists(form: installForm))
|
if (api32.FileExists(form: installForm))
|
||||||
{
|
{
|
||||||
api32.Delete();
|
api32.DeleteFile();
|
||||||
installForm?.UpdateUser($"Deleted ScreamAPI: {Path.GetFileName(api32)}", LogTextBox.Action, false);
|
installForm?.UpdateUser($"Deleted ScreamAPI: {Path.GetFileName(api32)}", LogTextBox.Action, false);
|
||||||
}
|
}
|
||||||
api32_o.Move(api32!);
|
api32_o.MoveFile(api32!);
|
||||||
installForm?.UpdateUser($"Restored EOS: {Path.GetFileName(api32_o)} -> {Path.GetFileName(api32)}", LogTextBox.Action, false);
|
installForm?.UpdateUser($"Restored EOS: {Path.GetFileName(api32_o)} -> {Path.GetFileName(api32)}", LogTextBox.Action, false);
|
||||||
}
|
}
|
||||||
if (api64_o.Exists(form: installForm))
|
if (api64_o.FileExists(form: installForm))
|
||||||
{
|
{
|
||||||
if (api64.Exists(form: installForm))
|
if (api64.FileExists(form: installForm))
|
||||||
{
|
{
|
||||||
api64.Delete();
|
api64.DeleteFile();
|
||||||
installForm?.UpdateUser($"Deleted ScreamAPI: {Path.GetFileName(api64)}", LogTextBox.Action, false);
|
installForm?.UpdateUser($"Deleted ScreamAPI: {Path.GetFileName(api64)}", LogTextBox.Action, false);
|
||||||
}
|
}
|
||||||
api64_o.Move(api64!);
|
api64_o.MoveFile(api64!);
|
||||||
installForm?.UpdateUser($"Restored EOS: {Path.GetFileName(api64_o)} -> {Path.GetFileName(api64)}", LogTextBox.Action, false);
|
installForm?.UpdateUser($"Restored EOS: {Path.GetFileName(api64_o)} -> {Path.GetFileName(api64)}", LogTextBox.Action, false);
|
||||||
}
|
}
|
||||||
if (!deleteOthers)
|
if (!deleteOthers)
|
||||||
return;
|
return;
|
||||||
if (config.Exists(form: installForm))
|
if (config.FileExists(form: installForm))
|
||||||
{
|
{
|
||||||
config.Delete();
|
config.DeleteFile();
|
||||||
installForm?.UpdateUser($"Deleted configuration: {Path.GetFileName(config)}", LogTextBox.Action, false);
|
installForm?.UpdateUser($"Deleted configuration: {Path.GetFileName(config)}", LogTextBox.Action, false);
|
||||||
}
|
}
|
||||||
if (log.Exists(form: installForm))
|
if (log.FileExists(form: installForm))
|
||||||
{
|
{
|
||||||
log.Delete();
|
log.DeleteFile();
|
||||||
installForm?.UpdateUser($"Deleted log: {Path.GetFileName(log)}", LogTextBox.Action, false);
|
installForm?.UpdateUser($"Deleted log: {Path.GetFileName(log)}", LogTextBox.Action, false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -143,22 +143,22 @@ internal static class ScreamAPI
|
||||||
=> await Task.Run(() =>
|
=> await Task.Run(() =>
|
||||||
{
|
{
|
||||||
directory.GetScreamApiComponents(out string api32, out string api32_o, out string api64, out string api64_o, out _, out _);
|
directory.GetScreamApiComponents(out string api32, out string api32_o, out string api64, out string api64_o, out _, out _);
|
||||||
if (api32.Exists(form: installForm) && !api32_o.Exists(form: installForm))
|
if (api32.FileExists(form: installForm) && !api32_o.FileExists(form: installForm))
|
||||||
{
|
{
|
||||||
api32.Move(api32_o!);
|
api32.MoveFile(api32_o!);
|
||||||
installForm?.UpdateUser($"Renamed EOS: {Path.GetFileName(api32)} -> {Path.GetFileName(api32_o)}", LogTextBox.Action, false);
|
installForm?.UpdateUser($"Renamed EOS: {Path.GetFileName(api32)} -> {Path.GetFileName(api32_o)}", LogTextBox.Action, false);
|
||||||
}
|
}
|
||||||
if (api32_o.Exists(form: installForm))
|
if (api32_o.FileExists(form: installForm))
|
||||||
{
|
{
|
||||||
"ScreamAPI.EOSSDK-Win32-Shipping.dll".WriteManifestResource(api32);
|
"ScreamAPI.EOSSDK-Win32-Shipping.dll".WriteManifestResource(api32);
|
||||||
installForm?.UpdateUser($"Wrote ScreamAPI: {Path.GetFileName(api32)}", LogTextBox.Action, false);
|
installForm?.UpdateUser($"Wrote ScreamAPI: {Path.GetFileName(api32)}", LogTextBox.Action, false);
|
||||||
}
|
}
|
||||||
if (api64.Exists(form: installForm) && !api64_o.Exists(form: installForm))
|
if (api64.FileExists(form: installForm) && !api64_o.FileExists(form: installForm))
|
||||||
{
|
{
|
||||||
api64.Move(api64_o!);
|
api64.MoveFile(api64_o!);
|
||||||
installForm?.UpdateUser($"Renamed EOS: {Path.GetFileName(api64)} -> {Path.GetFileName(api64_o)}", LogTextBox.Action, false);
|
installForm?.UpdateUser($"Renamed EOS: {Path.GetFileName(api64)} -> {Path.GetFileName(api64_o)}", LogTextBox.Action, false);
|
||||||
}
|
}
|
||||||
if (api64_o.Exists(form: installForm))
|
if (api64_o.FileExists(form: installForm))
|
||||||
{
|
{
|
||||||
"ScreamAPI.EOSSDK-Win64-Shipping.dll".WriteManifestResource(api64);
|
"ScreamAPI.EOSSDK-Win64-Shipping.dll".WriteManifestResource(api64);
|
||||||
installForm?.UpdateUser($"Wrote ScreamAPI: {Path.GetFileName(api64)}", LogTextBox.Action, false);
|
installForm?.UpdateUser($"Wrote ScreamAPI: {Path.GetFileName(api64)}", LogTextBox.Action, false);
|
||||||
|
|
|
@ -51,16 +51,16 @@ internal static class SmokeAPI
|
||||||
extraApps.Add(newExtraPair);
|
extraApps.Add(newExtraPair);
|
||||||
}
|
}
|
||||||
injectDlc = injectDlc.ToList();
|
injectDlc = injectDlc.ToList();
|
||||||
if (old_config.Exists(form: installForm))
|
if (old_config.FileExists(form: installForm))
|
||||||
{
|
{
|
||||||
old_config.Delete();
|
old_config.DeleteFile();
|
||||||
installForm?.UpdateUser($"Deleted old configuration: {Path.GetFileName(old_config)}", LogTextBox.Action, false);
|
installForm?.UpdateUser($"Deleted old configuration: {Path.GetFileName(old_config)}", LogTextBox.Action, false);
|
||||||
}
|
}
|
||||||
if (selection.ExtraSelectedDlc.Any(p => p.Value.dlc.Any()) || overrideDlc.Any() || injectDlc.Any())
|
if (selection.ExtraSelectedDlc.Any(p => p.Value.dlc.Any()) || overrideDlc.Any() || injectDlc.Any())
|
||||||
{
|
{
|
||||||
/*if (installForm is not null)
|
/*if (installForm is not null)
|
||||||
installForm.UpdateUser("Generating SmokeAPI configuration for " + selection.Name + $" in directory \"{directory}\" . . . ", LogTextBox.Operation);*/
|
installForm.UpdateUser("Generating SmokeAPI configuration for " + selection.Name + $" in directory \"{directory}\" . . . ", LogTextBox.Operation);*/
|
||||||
config.Create(true, installForm);
|
config.CreateFile(true, installForm);
|
||||||
StreamWriter writer = new(config, true, Encoding.UTF8);
|
StreamWriter writer = new(config, true, Encoding.UTF8);
|
||||||
WriteConfig(writer, selection.Id, new(extraApps.ToDictionary(pair => pair.Key, pair => pair.Value), PlatformIdComparer.String),
|
WriteConfig(writer, selection.Id, new(extraApps.ToDictionary(pair => pair.Key, pair => pair.Value), PlatformIdComparer.String),
|
||||||
new(overrideDlc.ToDictionary(pair => pair.Key, pair => pair.Value), PlatformIdComparer.String),
|
new(overrideDlc.ToDictionary(pair => pair.Key, pair => pair.Value), PlatformIdComparer.String),
|
||||||
|
@ -68,9 +68,9 @@ internal static class SmokeAPI
|
||||||
writer.Flush();
|
writer.Flush();
|
||||||
writer.Close();
|
writer.Close();
|
||||||
}
|
}
|
||||||
else if (config.Exists(form: installForm))
|
else if (config.FileExists(form: installForm))
|
||||||
{
|
{
|
||||||
config.Delete();
|
config.DeleteFile();
|
||||||
installForm?.UpdateUser($"Deleted unnecessary configuration: {Path.GetFileName(config)}", LogTextBox.Action, false);
|
installForm?.UpdateUser($"Deleted unnecessary configuration: {Path.GetFileName(config)}", LogTextBox.Action, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -155,58 +155,58 @@ internal static class SmokeAPI
|
||||||
=> await Task.Run(() =>
|
=> await Task.Run(() =>
|
||||||
{
|
{
|
||||||
directory.GetCreamApiComponents(out _, out _, out _, out _, out string oldConfig);
|
directory.GetCreamApiComponents(out _, out _, out _, out _, out string oldConfig);
|
||||||
if (oldConfig.Exists(form: installForm))
|
if (oldConfig.FileExists(form: installForm))
|
||||||
{
|
{
|
||||||
oldConfig.Delete();
|
oldConfig.DeleteFile();
|
||||||
installForm?.UpdateUser($"Deleted old CreamAPI configuration: {Path.GetFileName(oldConfig)}", LogTextBox.Action, false);
|
installForm?.UpdateUser($"Deleted old CreamAPI configuration: {Path.GetFileName(oldConfig)}", LogTextBox.Action, false);
|
||||||
}
|
}
|
||||||
directory.GetSmokeApiComponents(out string api32, out string api32_o, out string api64, out string api64_o, out string old_config,
|
directory.GetSmokeApiComponents(out string api32, out string api32_o, out string api64, out string api64_o, out string old_config,
|
||||||
out string config, out string old_log, out string log, out string cache);
|
out string config, out string old_log, out string log, out string cache);
|
||||||
if (api32_o.Exists(form: installForm))
|
if (api32_o.FileExists(form: installForm))
|
||||||
{
|
{
|
||||||
if (api32.Exists(form: installForm))
|
if (api32.FileExists(form: installForm))
|
||||||
{
|
{
|
||||||
api32.Delete();
|
api32.DeleteFile();
|
||||||
installForm?.UpdateUser($"Deleted SmokeAPI: {Path.GetFileName(api32)}", LogTextBox.Action, false);
|
installForm?.UpdateUser($"Deleted SmokeAPI: {Path.GetFileName(api32)}", LogTextBox.Action, false);
|
||||||
}
|
}
|
||||||
api32_o.Move(api32!);
|
api32_o.MoveFile(api32!);
|
||||||
installForm?.UpdateUser($"Restored Steamworks: {Path.GetFileName(api32_o)} -> {Path.GetFileName(api32)}", LogTextBox.Action, false);
|
installForm?.UpdateUser($"Restored Steamworks: {Path.GetFileName(api32_o)} -> {Path.GetFileName(api32)}", LogTextBox.Action, false);
|
||||||
}
|
}
|
||||||
if (api64_o.Exists(form: installForm))
|
if (api64_o.FileExists(form: installForm))
|
||||||
{
|
{
|
||||||
if (api64.Exists(form: installForm))
|
if (api64.FileExists(form: installForm))
|
||||||
{
|
{
|
||||||
api64.Delete();
|
api64.DeleteFile();
|
||||||
installForm?.UpdateUser($"Deleted SmokeAPI: {Path.GetFileName(api64)}", LogTextBox.Action, false);
|
installForm?.UpdateUser($"Deleted SmokeAPI: {Path.GetFileName(api64)}", LogTextBox.Action, false);
|
||||||
}
|
}
|
||||||
api64_o.Move(api64!);
|
api64_o.MoveFile(api64!);
|
||||||
installForm?.UpdateUser($"Restored Steamworks: {Path.GetFileName(api64_o)} -> {Path.GetFileName(api64)}", LogTextBox.Action, false);
|
installForm?.UpdateUser($"Restored Steamworks: {Path.GetFileName(api64_o)} -> {Path.GetFileName(api64)}", LogTextBox.Action, false);
|
||||||
}
|
}
|
||||||
if (!deleteOthers)
|
if (!deleteOthers)
|
||||||
return;
|
return;
|
||||||
if (old_config.Exists(form: installForm))
|
if (old_config.FileExists(form: installForm))
|
||||||
{
|
{
|
||||||
old_config.Delete();
|
old_config.DeleteFile();
|
||||||
installForm?.UpdateUser($"Deleted configuration: {Path.GetFileName(old_config)}", LogTextBox.Action, false);
|
installForm?.UpdateUser($"Deleted configuration: {Path.GetFileName(old_config)}", LogTextBox.Action, false);
|
||||||
}
|
}
|
||||||
if (config.Exists(form: installForm))
|
if (config.FileExists(form: installForm))
|
||||||
{
|
{
|
||||||
config.Delete();
|
config.DeleteFile();
|
||||||
installForm?.UpdateUser($"Deleted configuration: {Path.GetFileName(config)}", LogTextBox.Action, false);
|
installForm?.UpdateUser($"Deleted configuration: {Path.GetFileName(config)}", LogTextBox.Action, false);
|
||||||
}
|
}
|
||||||
if (cache.Exists(form: installForm))
|
if (cache.FileExists(form: installForm))
|
||||||
{
|
{
|
||||||
cache.Delete();
|
cache.DeleteFile();
|
||||||
installForm?.UpdateUser($"Deleted cache: {Path.GetFileName(cache)}", LogTextBox.Action, false);
|
installForm?.UpdateUser($"Deleted cache: {Path.GetFileName(cache)}", LogTextBox.Action, false);
|
||||||
}
|
}
|
||||||
if (old_log.Exists(form: installForm))
|
if (old_log.FileExists(form: installForm))
|
||||||
{
|
{
|
||||||
old_log.Delete();
|
old_log.DeleteFile();
|
||||||
installForm?.UpdateUser($"Deleted log: {Path.GetFileName(old_log)}", LogTextBox.Action, false);
|
installForm?.UpdateUser($"Deleted log: {Path.GetFileName(old_log)}", LogTextBox.Action, false);
|
||||||
}
|
}
|
||||||
if (log.Exists(form: installForm))
|
if (log.FileExists(form: installForm))
|
||||||
{
|
{
|
||||||
log.Delete();
|
log.DeleteFile();
|
||||||
installForm?.UpdateUser($"Deleted log: {Path.GetFileName(log)}", LogTextBox.Action, false);
|
installForm?.UpdateUser($"Deleted log: {Path.GetFileName(log)}", LogTextBox.Action, false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -215,28 +215,28 @@ internal static class SmokeAPI
|
||||||
=> await Task.Run(() =>
|
=> await Task.Run(() =>
|
||||||
{
|
{
|
||||||
directory.GetCreamApiComponents(out _, out _, out _, out _, out string oldConfig);
|
directory.GetCreamApiComponents(out _, out _, out _, out _, out string oldConfig);
|
||||||
if (oldConfig.Exists(form: installForm))
|
if (oldConfig.FileExists(form: installForm))
|
||||||
{
|
{
|
||||||
oldConfig.Delete();
|
oldConfig.DeleteFile();
|
||||||
installForm?.UpdateUser($"Deleted old CreamAPI configuration: {Path.GetFileName(oldConfig)}", LogTextBox.Action, false);
|
installForm?.UpdateUser($"Deleted old CreamAPI configuration: {Path.GetFileName(oldConfig)}", LogTextBox.Action, false);
|
||||||
}
|
}
|
||||||
directory.GetSmokeApiComponents(out string api32, out string api32_o, out string api64, out string api64_o, out _, out _, out _, out _, out _);
|
directory.GetSmokeApiComponents(out string api32, out string api32_o, out string api64, out string api64_o, out _, out _, out _, out _, out _);
|
||||||
if (api32.Exists(form: installForm) && !api32_o.Exists(form: installForm))
|
if (api32.FileExists(form: installForm) && !api32_o.FileExists(form: installForm))
|
||||||
{
|
{
|
||||||
api32.Move(api32_o!);
|
api32.MoveFile(api32_o!);
|
||||||
installForm?.UpdateUser($"Renamed Steamworks: {Path.GetFileName(api32)} -> {Path.GetFileName(api32_o)}", LogTextBox.Action, false);
|
installForm?.UpdateUser($"Renamed Steamworks: {Path.GetFileName(api32)} -> {Path.GetFileName(api32_o)}", LogTextBox.Action, false);
|
||||||
}
|
}
|
||||||
if (api32_o.Exists(form: installForm))
|
if (api32_o.FileExists(form: installForm))
|
||||||
{
|
{
|
||||||
"SmokeAPI.steam_api.dll".WriteManifestResource(api32);
|
"SmokeAPI.steam_api.dll".WriteManifestResource(api32);
|
||||||
installForm?.UpdateUser($"Wrote SmokeAPI: {Path.GetFileName(api32)}", LogTextBox.Action, false);
|
installForm?.UpdateUser($"Wrote SmokeAPI: {Path.GetFileName(api32)}", LogTextBox.Action, false);
|
||||||
}
|
}
|
||||||
if (api64.Exists(form: installForm) && !api64_o.Exists(form: installForm))
|
if (api64.FileExists(form: installForm) && !api64_o.FileExists(form: installForm))
|
||||||
{
|
{
|
||||||
api64.Move(api64_o!);
|
api64.MoveFile(api64_o!);
|
||||||
installForm?.UpdateUser($"Renamed Steamworks: {Path.GetFileName(api64)} -> {Path.GetFileName(api64_o)}", LogTextBox.Action, false);
|
installForm?.UpdateUser($"Renamed Steamworks: {Path.GetFileName(api64)} -> {Path.GetFileName(api64_o)}", LogTextBox.Action, false);
|
||||||
}
|
}
|
||||||
if (api64_o.Exists(form: installForm))
|
if (api64_o.FileExists(form: installForm))
|
||||||
{
|
{
|
||||||
"SmokeAPI.steam_api64.dll".WriteManifestResource(api64);
|
"SmokeAPI.steam_api64.dll".WriteManifestResource(api64);
|
||||||
installForm?.UpdateUser($"Wrote SmokeAPI: {Path.GetFileName(api64)}", LogTextBox.Action, false);
|
installForm?.UpdateUser($"Wrote SmokeAPI: {Path.GetFileName(api64)}", LogTextBox.Action, false);
|
||||||
|
|
|
@ -33,15 +33,15 @@ internal static class UplayR1
|
||||||
{
|
{
|
||||||
/*if (installForm is not null)
|
/*if (installForm is not null)
|
||||||
installForm.UpdateUser("Generating Uplay R1 Unlocker configuration for " + selection.Name + $" in directory \"{directory}\" . . . ", LogTextBox.Operation);*/
|
installForm.UpdateUser("Generating Uplay R1 Unlocker configuration for " + selection.Name + $" in directory \"{directory}\" . . . ", LogTextBox.Operation);*/
|
||||||
config.Create(true, installForm);
|
config.CreateFile(true, installForm);
|
||||||
StreamWriter writer = new(config, true, Encoding.UTF8);
|
StreamWriter writer = new(config, true, Encoding.UTF8);
|
||||||
WriteConfig(writer, new(blacklistDlc.ToDictionary(pair => pair.Key, pair => pair.Value), PlatformIdComparer.String), installForm);
|
WriteConfig(writer, new(blacklistDlc.ToDictionary(pair => pair.Key, pair => pair.Value), PlatformIdComparer.String), installForm);
|
||||||
writer.Flush();
|
writer.Flush();
|
||||||
writer.Close();
|
writer.Close();
|
||||||
}
|
}
|
||||||
else if (config.Exists(form: installForm))
|
else if (config.FileExists(form: installForm))
|
||||||
{
|
{
|
||||||
config.Delete();
|
config.DeleteFile();
|
||||||
installForm?.UpdateUser($"Deleted unnecessary configuration: {Path.GetFileName(config)}", LogTextBox.Action, false);
|
installForm?.UpdateUser($"Deleted unnecessary configuration: {Path.GetFileName(config)}", LogTextBox.Action, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -75,36 +75,36 @@ internal static class UplayR1
|
||||||
=> await Task.Run(() =>
|
=> await Task.Run(() =>
|
||||||
{
|
{
|
||||||
directory.GetUplayR1Components(out string api32, out string api32_o, out string api64, out string api64_o, out string config, out string log);
|
directory.GetUplayR1Components(out string api32, out string api32_o, out string api64, out string api64_o, out string config, out string log);
|
||||||
if (api32_o.Exists(form: installForm))
|
if (api32_o.FileExists(form: installForm))
|
||||||
{
|
{
|
||||||
if (api32.Exists(form: installForm))
|
if (api32.FileExists(form: installForm))
|
||||||
{
|
{
|
||||||
api32.Delete();
|
api32.DeleteFile();
|
||||||
installForm?.UpdateUser($"Deleted Uplay R1 Unlocker: {Path.GetFileName(api32)}", LogTextBox.Action, false);
|
installForm?.UpdateUser($"Deleted Uplay R1 Unlocker: {Path.GetFileName(api32)}", LogTextBox.Action, false);
|
||||||
}
|
}
|
||||||
api32_o.Move(api32!);
|
api32_o.MoveFile(api32!);
|
||||||
installForm?.UpdateUser($"Restored Uplay R1: {Path.GetFileName(api32_o)} -> {Path.GetFileName(api32)}", LogTextBox.Action, false);
|
installForm?.UpdateUser($"Restored Uplay R1: {Path.GetFileName(api32_o)} -> {Path.GetFileName(api32)}", LogTextBox.Action, false);
|
||||||
}
|
}
|
||||||
if (api64_o.Exists(form: installForm))
|
if (api64_o.FileExists(form: installForm))
|
||||||
{
|
{
|
||||||
if (api64.Exists(form: installForm))
|
if (api64.FileExists(form: installForm))
|
||||||
{
|
{
|
||||||
api64.Delete();
|
api64.DeleteFile();
|
||||||
installForm?.UpdateUser($"Deleted Uplay R1 Unlocker: {Path.GetFileName(api64)}", LogTextBox.Action, false);
|
installForm?.UpdateUser($"Deleted Uplay R1 Unlocker: {Path.GetFileName(api64)}", LogTextBox.Action, false);
|
||||||
}
|
}
|
||||||
api64_o.Move(api64!);
|
api64_o.MoveFile(api64!);
|
||||||
installForm?.UpdateUser($"Restored Uplay R1: {Path.GetFileName(api64_o)} -> {Path.GetFileName(api64)}", LogTextBox.Action, false);
|
installForm?.UpdateUser($"Restored Uplay R1: {Path.GetFileName(api64_o)} -> {Path.GetFileName(api64)}", LogTextBox.Action, false);
|
||||||
}
|
}
|
||||||
if (!deleteOthers)
|
if (!deleteOthers)
|
||||||
return;
|
return;
|
||||||
if (config.Exists(form: installForm))
|
if (config.FileExists(form: installForm))
|
||||||
{
|
{
|
||||||
config.Delete();
|
config.DeleteFile();
|
||||||
installForm?.UpdateUser($"Deleted configuration: {Path.GetFileName(config)}", LogTextBox.Action, false);
|
installForm?.UpdateUser($"Deleted configuration: {Path.GetFileName(config)}", LogTextBox.Action, false);
|
||||||
}
|
}
|
||||||
if (log.Exists(form: installForm))
|
if (log.FileExists(form: installForm))
|
||||||
{
|
{
|
||||||
log.Delete();
|
log.DeleteFile();
|
||||||
installForm?.UpdateUser($"Deleted log: {Path.GetFileName(log)}", LogTextBox.Action, false);
|
installForm?.UpdateUser($"Deleted log: {Path.GetFileName(log)}", LogTextBox.Action, false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -113,22 +113,22 @@ internal static class UplayR1
|
||||||
=> await Task.Run(() =>
|
=> await Task.Run(() =>
|
||||||
{
|
{
|
||||||
directory.GetUplayR1Components(out string api32, out string api32_o, out string api64, out string api64_o, out _, out _);
|
directory.GetUplayR1Components(out string api32, out string api32_o, out string api64, out string api64_o, out _, out _);
|
||||||
if (api32.Exists(form: installForm) && !api32_o.Exists(form: installForm))
|
if (api32.FileExists(form: installForm) && !api32_o.FileExists(form: installForm))
|
||||||
{
|
{
|
||||||
api32.Move(api32_o!);
|
api32.MoveFile(api32_o!);
|
||||||
installForm?.UpdateUser($"Renamed Uplay R1: {Path.GetFileName(api32)} -> {Path.GetFileName(api32_o)}", LogTextBox.Action, false);
|
installForm?.UpdateUser($"Renamed Uplay R1: {Path.GetFileName(api32)} -> {Path.GetFileName(api32_o)}", LogTextBox.Action, false);
|
||||||
}
|
}
|
||||||
if (api32_o.Exists(form: installForm))
|
if (api32_o.FileExists(form: installForm))
|
||||||
{
|
{
|
||||||
"UplayR1.uplay_r1_loader.dll".WriteManifestResource(api32);
|
"UplayR1.uplay_r1_loader.dll".WriteManifestResource(api32);
|
||||||
installForm?.UpdateUser($"Wrote Uplay R1 Unlocker: {Path.GetFileName(api32)}", LogTextBox.Action, false);
|
installForm?.UpdateUser($"Wrote Uplay R1 Unlocker: {Path.GetFileName(api32)}", LogTextBox.Action, false);
|
||||||
}
|
}
|
||||||
if (api64.Exists(form: installForm) && !api64_o.Exists(form: installForm))
|
if (api64.FileExists(form: installForm) && !api64_o.FileExists(form: installForm))
|
||||||
{
|
{
|
||||||
api64.Move(api64_o!);
|
api64.MoveFile(api64_o!);
|
||||||
installForm?.UpdateUser($"Renamed Uplay R1: {Path.GetFileName(api64)} -> {Path.GetFileName(api64_o)}", LogTextBox.Action, false);
|
installForm?.UpdateUser($"Renamed Uplay R1: {Path.GetFileName(api64)} -> {Path.GetFileName(api64_o)}", LogTextBox.Action, false);
|
||||||
}
|
}
|
||||||
if (api64_o.Exists(form: installForm))
|
if (api64_o.FileExists(form: installForm))
|
||||||
{
|
{
|
||||||
"UplayR1.uplay_r1_loader64.dll".WriteManifestResource(api64);
|
"UplayR1.uplay_r1_loader64.dll".WriteManifestResource(api64);
|
||||||
installForm?.UpdateUser($"Wrote Uplay R1 Unlocker: {Path.GetFileName(api64)}", LogTextBox.Action, false);
|
installForm?.UpdateUser($"Wrote Uplay R1 Unlocker: {Path.GetFileName(api64)}", LogTextBox.Action, false);
|
||||||
|
|
|
@ -35,15 +35,15 @@ internal static class UplayR2
|
||||||
{
|
{
|
||||||
/*if (installForm is not null)
|
/*if (installForm is not null)
|
||||||
installForm.UpdateUser("Generating Uplay R2 Unlocker configuration for " + selection.Name + $" in directory \"{directory}\" . . . ", LogTextBox.Operation);*/
|
installForm.UpdateUser("Generating Uplay R2 Unlocker configuration for " + selection.Name + $" in directory \"{directory}\" . . . ", LogTextBox.Operation);*/
|
||||||
config.Create(true, installForm);
|
config.CreateFile(true, installForm);
|
||||||
StreamWriter writer = new(config, true, Encoding.UTF8);
|
StreamWriter writer = new(config, true, Encoding.UTF8);
|
||||||
WriteConfig(writer, new(blacklistDlc.ToDictionary(pair => pair.Key, pair => pair.Value), PlatformIdComparer.String), installForm);
|
WriteConfig(writer, new(blacklistDlc.ToDictionary(pair => pair.Key, pair => pair.Value), PlatformIdComparer.String), installForm);
|
||||||
writer.Flush();
|
writer.Flush();
|
||||||
writer.Close();
|
writer.Close();
|
||||||
}
|
}
|
||||||
else if (config.Exists(form: installForm))
|
else if (config.FileExists(form: installForm))
|
||||||
{
|
{
|
||||||
config.Delete();
|
config.DeleteFile();
|
||||||
installForm?.UpdateUser($"Deleted unnecessary configuration: {Path.GetFileName(config)}", LogTextBox.Action, false);
|
installForm?.UpdateUser($"Deleted unnecessary configuration: {Path.GetFileName(config)}", LogTextBox.Action, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -80,38 +80,38 @@ internal static class UplayR2
|
||||||
{
|
{
|
||||||
directory.GetUplayR2Components(out string old_api32, out string old_api64, out string api32, out string api32_o, out string api64,
|
directory.GetUplayR2Components(out string old_api32, out string old_api64, out string api32, out string api32_o, out string api64,
|
||||||
out string api64_o, out string config, out string log);
|
out string api64_o, out string config, out string log);
|
||||||
if (api32_o.Exists(form: installForm))
|
if (api32_o.FileExists(form: installForm))
|
||||||
{
|
{
|
||||||
string api = old_api32.Exists(form: installForm) ? old_api32 : api32;
|
string api = old_api32.FileExists(form: installForm) ? old_api32 : api32;
|
||||||
if (api.Exists(form: installForm))
|
if (api.FileExists(form: installForm))
|
||||||
{
|
{
|
||||||
api.Delete();
|
api.DeleteFile();
|
||||||
installForm?.UpdateUser($"Deleted Uplay R2 Unlocker: {Path.GetFileName(api)}", LogTextBox.Action, false);
|
installForm?.UpdateUser($"Deleted Uplay R2 Unlocker: {Path.GetFileName(api)}", LogTextBox.Action, false);
|
||||||
}
|
}
|
||||||
api32_o.Move(api!);
|
api32_o.MoveFile(api!);
|
||||||
installForm?.UpdateUser($"Restored Uplay R2: {Path.GetFileName(api32_o)} -> {Path.GetFileName(api)}", LogTextBox.Action, false);
|
installForm?.UpdateUser($"Restored Uplay R2: {Path.GetFileName(api32_o)} -> {Path.GetFileName(api)}", LogTextBox.Action, false);
|
||||||
}
|
}
|
||||||
if (api64_o.Exists(form: installForm))
|
if (api64_o.FileExists(form: installForm))
|
||||||
{
|
{
|
||||||
string api = old_api64.Exists(form: installForm) ? old_api64 : api64;
|
string api = old_api64.FileExists(form: installForm) ? old_api64 : api64;
|
||||||
if (api.Exists(form: installForm))
|
if (api.FileExists(form: installForm))
|
||||||
{
|
{
|
||||||
api.Delete();
|
api.DeleteFile();
|
||||||
installForm?.UpdateUser($"Deleted Uplay R2 Unlocker: {Path.GetFileName(api)}", LogTextBox.Action, false);
|
installForm?.UpdateUser($"Deleted Uplay R2 Unlocker: {Path.GetFileName(api)}", LogTextBox.Action, false);
|
||||||
}
|
}
|
||||||
api64_o.Move(api!);
|
api64_o.MoveFile(api!);
|
||||||
installForm?.UpdateUser($"Restored Uplay R2: {Path.GetFileName(api64_o)} -> {Path.GetFileName(api)}", LogTextBox.Action, false);
|
installForm?.UpdateUser($"Restored Uplay R2: {Path.GetFileName(api64_o)} -> {Path.GetFileName(api)}", LogTextBox.Action, false);
|
||||||
}
|
}
|
||||||
if (!deleteOthers)
|
if (!deleteOthers)
|
||||||
return;
|
return;
|
||||||
if (config.Exists(form: installForm))
|
if (config.FileExists(form: installForm))
|
||||||
{
|
{
|
||||||
config.Delete();
|
config.DeleteFile();
|
||||||
installForm?.UpdateUser($"Deleted configuration: {Path.GetFileName(config)}", LogTextBox.Action, false);
|
installForm?.UpdateUser($"Deleted configuration: {Path.GetFileName(config)}", LogTextBox.Action, false);
|
||||||
}
|
}
|
||||||
if (log.Exists(form: installForm))
|
if (log.FileExists(form: installForm))
|
||||||
{
|
{
|
||||||
log.Delete();
|
log.DeleteFile();
|
||||||
installForm?.UpdateUser($"Deleted log: {Path.GetFileName(log)}", LogTextBox.Action, false);
|
installForm?.UpdateUser($"Deleted log: {Path.GetFileName(log)}", LogTextBox.Action, false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -121,24 +121,24 @@ internal static class UplayR2
|
||||||
{
|
{
|
||||||
directory.GetUplayR2Components(out string old_api32, out string old_api64, out string api32, out string api32_o, out string api64,
|
directory.GetUplayR2Components(out string old_api32, out string old_api64, out string api32, out string api32_o, out string api64,
|
||||||
out string api64_o, out _, out _);
|
out string api64_o, out _, out _);
|
||||||
string api = old_api32.Exists(form: installForm) ? old_api32 : api32;
|
string api = old_api32.FileExists(form: installForm) ? old_api32 : api32;
|
||||||
if (api.Exists(form: installForm) && !api32_o.Exists(form: installForm))
|
if (api.FileExists(form: installForm) && !api32_o.FileExists(form: installForm))
|
||||||
{
|
{
|
||||||
api.Move(api32_o!);
|
api.MoveFile(api32_o!);
|
||||||
installForm?.UpdateUser($"Renamed Uplay R2: {Path.GetFileName(api)} -> {Path.GetFileName(api32_o)}", LogTextBox.Action, false);
|
installForm?.UpdateUser($"Renamed Uplay R2: {Path.GetFileName(api)} -> {Path.GetFileName(api32_o)}", LogTextBox.Action, false);
|
||||||
}
|
}
|
||||||
if (api32_o.Exists(form: installForm))
|
if (api32_o.FileExists(form: installForm))
|
||||||
{
|
{
|
||||||
"UplayR2.upc_r2_loader.dll".WriteManifestResource(api);
|
"UplayR2.upc_r2_loader.dll".WriteManifestResource(api);
|
||||||
installForm?.UpdateUser($"Wrote Uplay R2 Unlocker: {Path.GetFileName(api)}", LogTextBox.Action, false);
|
installForm?.UpdateUser($"Wrote Uplay R2 Unlocker: {Path.GetFileName(api)}", LogTextBox.Action, false);
|
||||||
}
|
}
|
||||||
api = old_api64.Exists(form: installForm) ? old_api64 : api64;
|
api = old_api64.FileExists(form: installForm) ? old_api64 : api64;
|
||||||
if (api.Exists(form: installForm) && !api64_o.Exists(form: installForm))
|
if (api.FileExists(form: installForm) && !api64_o.FileExists(form: installForm))
|
||||||
{
|
{
|
||||||
api.Move(api64_o!);
|
api.MoveFile(api64_o!);
|
||||||
installForm?.UpdateUser($"Renamed Uplay R2: {Path.GetFileName(api)} -> {Path.GetFileName(api64_o)}", LogTextBox.Action, false);
|
installForm?.UpdateUser($"Renamed Uplay R2: {Path.GetFileName(api)} -> {Path.GetFileName(api64_o)}", LogTextBox.Action, false);
|
||||||
}
|
}
|
||||||
if (api64_o.Exists(form: installForm))
|
if (api64_o.FileExists(form: installForm))
|
||||||
{
|
{
|
||||||
"UplayR2.upc_r2_loader64.dll".WriteManifestResource(api);
|
"UplayR2.upc_r2_loader64.dll".WriteManifestResource(api);
|
||||||
installForm?.UpdateUser($"Wrote Uplay R2 Unlocker: {Path.GetFileName(api)}", LogTextBox.Action, false);
|
installForm?.UpdateUser($"Wrote Uplay R2 Unlocker: {Path.GetFileName(api)}", LogTextBox.Action, false);
|
||||||
|
|
|
@ -22,13 +22,13 @@ internal static class Diagnostics
|
||||||
internal static string GetNotepadPath()
|
internal static string GetNotepadPath()
|
||||||
{
|
{
|
||||||
string npp = NppPath + @"\notepad++.exe";
|
string npp = NppPath + @"\notepad++.exe";
|
||||||
return npp.Exists() ? npp : Environment.GetFolderPath(Environment.SpecialFolder.Windows) + @"\notepad.exe";
|
return npp.FileExists() ? npp : Environment.GetFolderPath(Environment.SpecialFolder.Windows) + @"\notepad.exe";
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static void OpenFileInNotepad(string path)
|
internal static void OpenFileInNotepad(string path)
|
||||||
{
|
{
|
||||||
string npp = NppPath + @"\notepad++.exe";
|
string npp = NppPath + @"\notepad++.exe";
|
||||||
if (npp.Exists())
|
if (npp.FileExists())
|
||||||
OpenFileInNotepadPlusPlus(npp, path);
|
OpenFileInNotepadPlusPlus(npp, path);
|
||||||
else
|
else
|
||||||
OpenFileInWindowsNotepad(path);
|
OpenFileInWindowsNotepad(path);
|
||||||
|
|
|
@ -3,6 +3,9 @@ using System.Drawing;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using HtmlAgilityPack;
|
using HtmlAgilityPack;
|
||||||
|
#if DEBUG
|
||||||
|
using CreamInstaller.Forms;
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace CreamInstaller.Utility;
|
namespace CreamInstaller.Utility;
|
||||||
|
|
||||||
|
@ -25,13 +28,21 @@ internal static class HttpClientManager
|
||||||
_ = response.EnsureSuccessStatusCode();
|
_ = response.EnsureSuccessStatusCode();
|
||||||
return await response.Content.ReadAsStringAsync();
|
return await response.Content.ReadAsStringAsync();
|
||||||
}
|
}
|
||||||
|
#if DEBUG
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
DebugForm.Current.Log("Get request failed to " + url + ": " + e, LogTextBox.Warning);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
#else
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static HtmlDocument ToHtmlDocument(this string html)
|
private static HtmlDocument ToHtmlDocument(this string html)
|
||||||
{
|
{
|
||||||
HtmlDocument document = new();
|
HtmlDocument document = new();
|
||||||
document.LoadHtml(html);
|
document.LoadHtml(html);
|
||||||
|
@ -39,9 +50,9 @@ internal static class HttpClientManager
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static async Task<HtmlNodeCollection> GetDocumentNodes(string url, string xpath)
|
internal static async Task<HtmlNodeCollection> GetDocumentNodes(string url, string xpath)
|
||||||
=> (await EnsureGet(url))?.ToHtmlDocument()?.DocumentNode?.SelectNodes(xpath);
|
=> (await EnsureGet(url))?.ToHtmlDocument()?.GetDocumentNodes(xpath);
|
||||||
|
|
||||||
internal static HtmlNodeCollection GetDocumentNodes(this HtmlDocument htmlDocument, string xpath) => htmlDocument.DocumentNode?.SelectNodes(xpath);
|
private static HtmlNodeCollection GetDocumentNodes(this HtmlDocument htmlDocument, string xpath) => htmlDocument.DocumentNode?.SelectNodes(xpath);
|
||||||
|
|
||||||
internal static async Task<Image> GetImageFromUrl(string url)
|
internal static async Task<Image> GetImageFromUrl(string url)
|
||||||
{
|
{
|
||||||
|
|
|
@ -17,7 +17,7 @@ internal static class IconGrabber
|
||||||
|
|
||||||
internal static string GetDomainFaviconUrl(string domain, int size = 16) => GoogleFaviconsApiUrl + $"?domain={domain}&sz={size}";
|
internal static string GetDomainFaviconUrl(string domain, int size = 16) => GoogleFaviconsApiUrl + $"?domain={domain}&sz={size}";
|
||||||
|
|
||||||
internal static Image GetFileIconImage(this string path) => path.Exists() ? Icon.ExtractAssociatedIcon(path)?.ToBitmap() : null;
|
internal static Image GetFileIconImage(this string path) => path.FileExists() ? Icon.ExtractAssociatedIcon(path)?.ToBitmap() : null;
|
||||||
|
|
||||||
internal static Image GetNotepadImage() => GetFileIconImage(Diagnostics.GetNotepadPath());
|
internal static Image GetNotepadImage() => GetFileIconImage(Diagnostics.GetNotepadPath());
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
@ -30,25 +29,22 @@ internal static class ProgramData
|
||||||
internal static async Task Setup(Form form = null)
|
internal static async Task Setup(Form form = null)
|
||||||
=> await Task.Run(() =>
|
=> await Task.Run(() =>
|
||||||
{
|
{
|
||||||
if (Directory.Exists(DirectoryPathOld))
|
if (DirectoryPathOld.DirectoryExists())
|
||||||
{
|
{
|
||||||
if (Directory.Exists(DirectoryPath))
|
DirectoryPath.DeleteDirectory();
|
||||||
Directory.Delete(DirectoryPath, true);
|
DirectoryPathOld.MoveDirectory(DirectoryPath, true, form);
|
||||||
Directory.Move(DirectoryPathOld, DirectoryPath);
|
|
||||||
}
|
}
|
||||||
if (!Directory.Exists(DirectoryPath))
|
DirectoryPath.CreateDirectory();
|
||||||
_ = Directory.CreateDirectory(DirectoryPath);
|
if (!AppInfoVersionPath.FileExists(form: form) || !Version.TryParse(AppInfoVersionPath.ReadFile(), out Version version)
|
||||||
if (!AppInfoVersionPath.Exists(form: form) || !Version.TryParse(AppInfoVersionPath.Read(), out Version version) || version < MinimumAppInfoVersion)
|
|| version < MinimumAppInfoVersion)
|
||||||
{
|
{
|
||||||
if (Directory.Exists(AppInfoPath))
|
AppInfoPath.DeleteDirectory();
|
||||||
Directory.Delete(AppInfoPath, true);
|
AppInfoPath.CreateDirectory();
|
||||||
_ = Directory.CreateDirectory(AppInfoPath);
|
AppInfoVersionPath.WriteFile(Program.Version);
|
||||||
AppInfoVersionPath.Write(Program.Version);
|
|
||||||
}
|
}
|
||||||
if (!Directory.Exists(CooldownPath))
|
CooldownPath.CreateDirectory();
|
||||||
_ = Directory.CreateDirectory(CooldownPath);
|
if (OldProgramChoicesPath.FileExists(form: form))
|
||||||
if (OldProgramChoicesPath.Exists(form: form))
|
OldProgramChoicesPath.DeleteFile();
|
||||||
OldProgramChoicesPath.Delete();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
internal static bool CheckCooldown(string identifier, int cooldown)
|
internal static bool CheckCooldown(string identifier, int cooldown)
|
||||||
|
@ -63,14 +59,14 @@ internal static class ProgramData
|
||||||
|
|
||||||
private static DateTime? GetCooldown(string identifier)
|
private static DateTime? GetCooldown(string identifier)
|
||||||
{
|
{
|
||||||
if (!Directory.Exists(CooldownPath))
|
if (!CooldownPath.DirectoryExists())
|
||||||
return null;
|
return null;
|
||||||
string cooldownFile = CooldownPath + @$"\{identifier}.txt";
|
string cooldownFile = CooldownPath + @$"\{identifier}.txt";
|
||||||
if (!cooldownFile.Exists())
|
if (!cooldownFile.FileExists())
|
||||||
return null;
|
return null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (DateTime.TryParse(cooldownFile.Read(), out DateTime cooldown))
|
if (DateTime.TryParse(cooldownFile.ReadFile(), out DateTime cooldown))
|
||||||
return cooldown;
|
return cooldown;
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
|
@ -82,12 +78,11 @@ internal static class ProgramData
|
||||||
|
|
||||||
private static void SetCooldown(string identifier, DateTime time)
|
private static void SetCooldown(string identifier, DateTime time)
|
||||||
{
|
{
|
||||||
if (!Directory.Exists(CooldownPath))
|
CooldownPath.CreateDirectory();
|
||||||
_ = Directory.CreateDirectory(CooldownPath);
|
|
||||||
string cooldownFile = CooldownPath + @$"\{identifier}.txt";
|
string cooldownFile = CooldownPath + @$"\{identifier}.txt";
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
cooldownFile.Write(time.ToString(CultureInfo.InvariantCulture));
|
cooldownFile.WriteFile(time.ToString(CultureInfo.InvariantCulture));
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
|
@ -97,10 +92,10 @@ internal static class ProgramData
|
||||||
|
|
||||||
internal static IEnumerable<(Platform platform, string id)> ReadProgramChoices()
|
internal static IEnumerable<(Platform platform, string id)> ReadProgramChoices()
|
||||||
{
|
{
|
||||||
if (ProgramChoicesPath.Exists())
|
if (ProgramChoicesPath.FileExists())
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (JsonConvert.DeserializeObject(ProgramChoicesPath.Read(), typeof(List<(Platform platform, string id)>)) is
|
if (JsonConvert.DeserializeObject(ProgramChoicesPath.ReadFile(), typeof(List<(Platform platform, string id)>)) is
|
||||||
List<(Platform platform, string id)> choices)
|
List<(Platform platform, string id)> choices)
|
||||||
return choices;
|
return choices;
|
||||||
}
|
}
|
||||||
|
@ -116,9 +111,9 @@ internal static class ProgramData
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (choices is null || !choices.Any())
|
if (choices is null || !choices.Any())
|
||||||
ProgramChoicesPath.Delete();
|
ProgramChoicesPath.DeleteFile();
|
||||||
else
|
else
|
||||||
ProgramChoicesPath.Write(JsonConvert.SerializeObject(choices));
|
ProgramChoicesPath.WriteFile(JsonConvert.SerializeObject(choices));
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
|
@ -128,10 +123,10 @@ internal static class ProgramData
|
||||||
|
|
||||||
internal static IEnumerable<(Platform platform, string gameId, string dlcId)> ReadDlcChoices()
|
internal static IEnumerable<(Platform platform, string gameId, string dlcId)> ReadDlcChoices()
|
||||||
{
|
{
|
||||||
if (DlcChoicesPath.Exists())
|
if (DlcChoicesPath.FileExists())
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (JsonConvert.DeserializeObject(DlcChoicesPath.Read(), typeof(IEnumerable<(Platform platform, string gameId, string dlcId)>)) is
|
if (JsonConvert.DeserializeObject(DlcChoicesPath.ReadFile(), typeof(IEnumerable<(Platform platform, string gameId, string dlcId)>)) is
|
||||||
IEnumerable<(Platform platform, string gameId, string dlcId)> choices)
|
IEnumerable<(Platform platform, string gameId, string dlcId)> choices)
|
||||||
return choices;
|
return choices;
|
||||||
}
|
}
|
||||||
|
@ -147,9 +142,9 @@ internal static class ProgramData
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (choices is null || !choices.Any())
|
if (choices is null || !choices.Any())
|
||||||
DlcChoicesPath.Delete();
|
DlcChoicesPath.DeleteFile();
|
||||||
else
|
else
|
||||||
DlcChoicesPath.Write(JsonConvert.SerializeObject(choices));
|
DlcChoicesPath.WriteFile(JsonConvert.SerializeObject(choices));
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
|
@ -159,10 +154,10 @@ internal static class ProgramData
|
||||||
|
|
||||||
internal static IEnumerable<(Platform platform, string id, string proxy, bool enabled)> ReadKoaloaderChoices()
|
internal static IEnumerable<(Platform platform, string id, string proxy, bool enabled)> ReadKoaloaderChoices()
|
||||||
{
|
{
|
||||||
if (KoaloaderProxyChoicesPath.Exists())
|
if (KoaloaderProxyChoicesPath.FileExists())
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (JsonConvert.DeserializeObject(KoaloaderProxyChoicesPath.Read(),
|
if (JsonConvert.DeserializeObject(KoaloaderProxyChoicesPath.ReadFile(),
|
||||||
typeof(IEnumerable<(Platform platform, string id, string proxy, bool enabled)>)) is
|
typeof(IEnumerable<(Platform platform, string id, string proxy, bool enabled)>)) is
|
||||||
IEnumerable<(Platform platform, string id, string proxy, bool enabled)> choices)
|
IEnumerable<(Platform platform, string id, string proxy, bool enabled)> choices)
|
||||||
return choices;
|
return choices;
|
||||||
|
@ -179,9 +174,9 @@ internal static class ProgramData
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (choices is null || !choices.Any())
|
if (choices is null || !choices.Any())
|
||||||
KoaloaderProxyChoicesPath.Delete();
|
KoaloaderProxyChoicesPath.DeleteFile();
|
||||||
else
|
else
|
||||||
KoaloaderProxyChoicesPath.Write(JsonConvert.SerializeObject(choices));
|
KoaloaderProxyChoicesPath.WriteFile(JsonConvert.SerializeObject(choices));
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
using System.Drawing;
|
using System.Collections.Generic;
|
||||||
|
using System.Drawing;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.IO.Compression;
|
||||||
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using CreamInstaller.Forms;
|
using CreamInstaller.Forms;
|
||||||
|
@ -8,7 +11,100 @@ namespace CreamInstaller.Utility;
|
||||||
|
|
||||||
internal static class SafeIO
|
internal static class SafeIO
|
||||||
{
|
{
|
||||||
internal static bool Exists(this string filePath, bool crucial = false, Form form = null)
|
internal static bool DirectoryExists(this string directoryPath, bool crucial = false, Form form = null)
|
||||||
|
{
|
||||||
|
while (!Program.Canceled)
|
||||||
|
{
|
||||||
|
bool exists = Directory.Exists(directoryPath);
|
||||||
|
if (exists || !crucial || directoryPath.IOWarn("Failed to find a crucial directory", form) is not DialogResult.OK)
|
||||||
|
return exists;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static void CreateDirectory(this string directoryPath, bool crucial = false, Form form = null)
|
||||||
|
{
|
||||||
|
if (directoryPath.DirectoryExists())
|
||||||
|
return;
|
||||||
|
while (!Program.Canceled)
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(directoryPath);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
if (!crucial || directoryPath.IOWarn("Failed to create a crucial directory", form) is not DialogResult.OK)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static void MoveDirectory(this string directoryPath, string newDirectoryPath, bool crucial = false, Form form = null)
|
||||||
|
{
|
||||||
|
while (!Program.Canceled)
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Directory.Move(directoryPath, newDirectoryPath);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
if (!crucial || directoryPath.IOWarn("Failed to move a crucial directory", form) is not DialogResult.OK)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static void DeleteDirectory(this string directoryPath, bool crucial = false, Form form = null)
|
||||||
|
{
|
||||||
|
if (!directoryPath.DirectoryExists())
|
||||||
|
return;
|
||||||
|
while (!Program.Canceled)
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Directory.Delete(directoryPath, true);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
if (!crucial || directoryPath.IOWarn("Failed to delete a crucial directory", form) is not DialogResult.OK)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static IEnumerable<string> EnumerateDirectory(this string directoryPath, string filePattern, bool subdirectories = false, bool crucial = false,
|
||||||
|
Form form = null)
|
||||||
|
{
|
||||||
|
while (!Program.Canceled)
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return subdirectories
|
||||||
|
? Directory.EnumerateFiles(directoryPath, filePattern, new EnumerationOptions { RecurseSubdirectories = true })
|
||||||
|
: Directory.EnumerateFiles(directoryPath, filePattern);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
if (!crucial || directoryPath.IOWarn("Failed to enumerate a crucial directory's files", form) is not DialogResult.OK)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return Enumerable.Empty<string>();
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static IEnumerable<string> EnumerateSubdirectories(this string directoryPath, string directoryPattern, bool crucial = false, Form form = null)
|
||||||
|
{
|
||||||
|
while (!Program.Canceled)
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return Directory.EnumerateDirectories(directoryPath, directoryPattern);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
if (!crucial || directoryPath.IOWarn("Failed to enumerate a crucial directory's subdirectories", form) is not DialogResult.OK)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return Enumerable.Empty<string>();
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static bool FileExists(this string filePath, bool crucial = false, Form form = null)
|
||||||
{
|
{
|
||||||
while (!Program.Canceled)
|
while (!Program.Canceled)
|
||||||
{
|
{
|
||||||
|
@ -19,7 +115,7 @@ internal static class SafeIO
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static void Create(this string filePath, bool crucial = false, Form form = null)
|
internal static void CreateFile(this string filePath, bool crucial = false, Form form = null)
|
||||||
{
|
{
|
||||||
while (!Program.Canceled)
|
while (!Program.Canceled)
|
||||||
try
|
try
|
||||||
|
@ -34,7 +130,7 @@ internal static class SafeIO
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static void Move(this string filePath, string newFilePath, bool crucial = false, Form form = null)
|
internal static void MoveFile(this string filePath, string newFilePath, bool crucial = false, Form form = null)
|
||||||
{
|
{
|
||||||
while (!Program.Canceled)
|
while (!Program.Canceled)
|
||||||
try
|
try
|
||||||
|
@ -44,14 +140,14 @@ internal static class SafeIO
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
if (!crucial || !filePath.Exists(true) || filePath.IOWarn("Failed to move a crucial file", form) is not DialogResult.OK)
|
if (!crucial || !filePath.FileExists(true) || filePath.IOWarn("Failed to move a crucial file", form) is not DialogResult.OK)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static void Delete(this string filePath, bool crucial = false, Form form = null)
|
internal static void DeleteFile(this string filePath, bool crucial = false, Form form = null)
|
||||||
{
|
{
|
||||||
if (!filePath.Exists(form: form))
|
if (!filePath.FileExists(form: form))
|
||||||
return;
|
return;
|
||||||
while (!Program.Canceled)
|
while (!Program.Canceled)
|
||||||
try
|
try
|
||||||
|
@ -66,7 +162,7 @@ internal static class SafeIO
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static string Read(this string filePath, bool crucial = false, Form form = null)
|
internal static string ReadFile(this string filePath, bool crucial = false, Form form = null)
|
||||||
{
|
{
|
||||||
while (!Program.Canceled)
|
while (!Program.Canceled)
|
||||||
try
|
try
|
||||||
|
@ -75,13 +171,13 @@ internal static class SafeIO
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
if (!crucial || !filePath.Exists(true) || filePath.IOWarn("Failed to read a crucial file", form) is not DialogResult.OK)
|
if (!crucial || !filePath.FileExists(true) || filePath.IOWarn("Failed to read a crucial file", form) is not DialogResult.OK)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static byte[] ReadBytes(this string filePath, bool crucial = false, Form form = null)
|
internal static byte[] ReadFileBytes(this string filePath, bool crucial = false, Form form = null)
|
||||||
{
|
{
|
||||||
while (!Program.Canceled)
|
while (!Program.Canceled)
|
||||||
try
|
try
|
||||||
|
@ -90,13 +186,13 @@ internal static class SafeIO
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
if (!crucial || !filePath.Exists(true) || filePath.IOWarn("Failed to read a crucial file", form) is not DialogResult.OK)
|
if (!crucial || !filePath.FileExists(true) || filePath.IOWarn("Failed to read a crucial file", form) is not DialogResult.OK)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static void Write(this string filePath, string text, bool crucial = false, Form form = null)
|
internal static void WriteFile(this string filePath, string text, bool crucial = false, Form form = null)
|
||||||
{
|
{
|
||||||
while (!Program.Canceled)
|
while (!Program.Canceled)
|
||||||
try
|
try
|
||||||
|
@ -111,6 +207,21 @@ internal static class SafeIO
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal static void ExtractZip(this string archivePath, string destinationPath, bool crucial = false, Form form = null)
|
||||||
|
{
|
||||||
|
while (!Program.Canceled)
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ZipFile.ExtractToDirectory(archivePath, destinationPath);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
if (!crucial || archivePath.IOWarn("Failed to extract a crucial zip file", form) is not DialogResult.OK)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
internal static DialogResult IOWarn(this string filePath, string message, Form form = null)
|
internal static DialogResult IOWarn(this string filePath, string message, Form form = null)
|
||||||
{
|
{
|
||||||
using DialogForm dialogForm = new(form ?? Form.ActiveForm);
|
using DialogForm dialogForm = new(form ?? Form.ActiveForm);
|
||||||
|
|
Loading…
Reference in a new issue