Skip to content

Commit

Permalink
Add validation before file deletion
Browse files Browse the repository at this point in the history
  • Loading branch information
edassis committed Dec 13, 2023
1 parent af6f181 commit 488f496
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions GodotEnv/src/features/godot/domain/GodotRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -456,13 +456,17 @@ [Desktop Entry]

case OSType.Windows: {
var hardLinkPath = $"{GodotSymlinkPath}.exe";
await FileClient.DeleteFile(hardLinkPath);
var commonStartMenuPath = Environment.GetFolderPath(Environment.SpecialFolder.StartMenu);
var applicationsPath = FileClient.Combine(commonStartMenuPath, "Programs", "Godot.lnk");

if (FileClient.FileExists(hardLinkPath)) {
await FileClient.DeleteFile(hardLinkPath);
}

await FileClient.ProcessRunner.RunElevatedOnWindows(
"cmd.exe", $"/c mklink /H \"{hardLinkPath}\" \"{installation.ExecutionPath}\""
);

var commonStartMenuPath = Environment.GetFolderPath(Environment.SpecialFolder.StartMenu);
var applicationsPath = FileClient.Combine(commonStartMenuPath, "Programs", "Godot.lnk");
var command = string.Join(";",
"$ws = New-Object -ComObject (\"WScript.Shell\")",
$"$s = $ws.CreateShortcut(\"{applicationsPath}\")",
Expand Down

0 comments on commit 488f496

Please sign in to comment.