mirror of
https://github.com/open-goal/launcher.git
synced 2024-10-20 04:57:38 -04:00
Implemented game uninstall functionality (#31)
Another one that's pretty self explanatory. Added a function to delete the directories: `data/decompiler_out/game` `data/iso_data/game` `data/out/game` Where `game` is the specified game passed in.
This commit is contained in:
parent
5730ad2630
commit
08fe008133
|
@ -3,7 +3,11 @@
|
|||
import { getInternalName, SupportedGame } from "$lib/constants";
|
||||
import { launchGame, launchGameInDebug } from "$lib/launch";
|
||||
import { openDir } from "$lib/rpc/commands";
|
||||
import { compileGame, decompileGameData } from "$lib/setup/setup";
|
||||
import {
|
||||
compileGame,
|
||||
decompileGameData,
|
||||
uninstallGame,
|
||||
} from "$lib/setup/setup";
|
||||
import { appDir, configDir, join } from "@tauri-apps/api/path";
|
||||
import { createEventDispatcher, onMount } from "svelte";
|
||||
import LogViewer from "./setup/LogViewer.svelte";
|
||||
|
@ -42,6 +46,7 @@
|
|||
const confirmed = await confirm("Are you sure you want to uninstall?");
|
||||
if (confirmed) {
|
||||
await launcherConfig.setInstallStatus(activeGame, false);
|
||||
await uninstallGame(activeGame);
|
||||
dispatch("change");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ import { launcherConfig } from "$lib/config";
|
|||
import { resolveErrorCode } from "./setup_errors";
|
||||
import { installLog, log } from "$lib/utils/log";
|
||||
import { ProcessLogs } from "$lib/stores/AppStore";
|
||||
import { removeDir } from "@tauri-apps/api/fs";
|
||||
|
||||
let sidecarOptions = {};
|
||||
|
||||
|
@ -266,3 +267,18 @@ export async function recompileGame(game: SupportedGame): Promise<boolean> {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export async function uninstallGame(game: SupportedGame) {
|
||||
const dataDir = await join(await appDir(), "data");
|
||||
try {
|
||||
const t0 = await join(dataDir, "decompiler_out", getInternalName(game));
|
||||
const t1 = await join(dataDir, "iso_data", getInternalName(game));
|
||||
const t2 = await join(dataDir, "out", getInternalName(game));
|
||||
const targets = [t0, t1, t2];
|
||||
for (const target of targets) {
|
||||
await removeDir(target, { recursive: true });
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue