Skip to content

Commit

Permalink
Fix Windows uninstaller
Browse files Browse the repository at this point in the history
  • Loading branch information
maddie480 committed Jan 26, 2025
1 parent 71a739c commit 8c80993
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ and only contains the latest changes.
Its purpose is to be shown in Olympus when updating.

#changelog#
Reintegrate the Windows uninstaller in Olympus.Sharp instead of having a separate uninstall.exe
Fixed the Windows uninstaller by copying the entire "sharp" folder in the temp directory
22 changes: 11 additions & 11 deletions sharp/CmdWin32AppUninstall.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ public override string Run(bool quiet) {
string root = Environment.GetEnvironmentVariable("OLYMPUS_ROOT");
if (string.IsNullOrEmpty(root))
root = Win32RegHelper.OpenOrCreateKey(@"HKCU\Software\Microsoft\Windows\CurrentVersion\Uninstall\Olympus", false)?.GetValue("InstallLocation") as string;
if (string.IsNullOrEmpty(root))
root = Path.GetDirectoryName(Path.GetDirectoryName(selfPath));

string selfDirectory = Path.GetDirectoryName(selfPath);
if (string.IsNullOrEmpty(root)) root = Path.GetDirectoryName(selfDirectory);

if (!File.Exists(Path.Combine(root, "main.exe")) ||
!File.Exists(Path.Combine(root, "love.dll")) ||
Expand All @@ -42,17 +43,16 @@ public override string Run(bool quiet) {

if (selfPath.StartsWith(root)) {
string tmpDir = Path.Combine(Path.GetTempPath(), "Olympus.Uninstall");
string tmp = Path.Combine(tmpDir, "Olympus.Sharp.exe");
try {
if (!Directory.Exists(tmpDir))
Directory.CreateDirectory(tmpDir);
string tmpDep = Path.Combine(tmpDir, "MonoMod.Utils.dll");
if (File.Exists(tmpDep))
File.Delete(tmpDep);
File.Copy(Path.Combine(Path.GetDirectoryName(selfPath), "MonoMod.Utils.dll"), tmpDep);
if (File.Exists(tmp))
File.Delete(tmp);
File.Copy(selfPath, tmp);

foreach (string f in Directory.GetFiles(selfDirectory)) {
string file = Path.GetFileName(f);
string tmpDep = Path.Combine(tmpDir, file);
if (File.Exists(tmpDep)) File.Delete(tmpDep);
File.Copy(Path.Combine(selfDirectory, file), tmpDep);
}
}
catch {
if (!quiet)
Expand All @@ -63,7 +63,7 @@ public override string Run(bool quiet) {
Environment.SetEnvironmentVariable("OLYMPUS_ROOT", root);

Process process = new Process();
process.StartInfo.FileName = tmp;
process.StartInfo.FileName = Path.Combine(tmpDir, "Olympus.Sharp.exe");
process.StartInfo.Arguments = "--uninstall" + (quiet ? " --quiet" : "");
Environment.CurrentDirectory = process.StartInfo.WorkingDirectory = tmpDir;
process.Start();
Expand Down

0 comments on commit 8c80993

Please sign in to comment.