summaryrefslogtreecommitdiff
path: root/src/SMAPI.Installer/InteractiveInstaller.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/SMAPI.Installer/InteractiveInstaller.cs')
-rw-r--r--src/SMAPI.Installer/InteractiveInstaller.cs40
1 files changed, 2 insertions, 38 deletions
diff --git a/src/SMAPI.Installer/InteractiveInstaller.cs b/src/SMAPI.Installer/InteractiveInstaller.cs
index 5b0c6e1f..1457848b 100644
--- a/src/SMAPI.Installer/InteractiveInstaller.cs
+++ b/src/SMAPI.Installer/InteractiveInstaller.cs
@@ -3,7 +3,6 @@ using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
-using System.Threading;
using Microsoft.Win32;
using StardewModdingApi.Installer.Enums;
using StardewModdingAPI.Installer.Framework;
@@ -624,7 +623,7 @@ namespace StardewModdingApi.Installer
{
try
{
- this.ForceDelete(Directory.Exists(path) ? new DirectoryInfo(path) : (FileSystemInfo)new FileInfo(path));
+ FileUtilities.ForceDelete(Directory.Exists(path) ? new DirectoryInfo(path) : (FileSystemInfo)new FileInfo(path));
break;
}
catch (Exception ex)
@@ -665,41 +664,6 @@ namespace StardewModdingApi.Installer
}
}
- /// <summary>Delete a file or folder regardless of file permissions, and block until deletion completes.</summary>
- /// <param name="entry">The file or folder to reset.</param>
- /// <remarks>This method is mirrored from <c>FileUtilities.ForceDelete</c> in the toolkit.</remarks>
- private void ForceDelete(FileSystemInfo entry)
- {
- // ignore if already deleted
- entry.Refresh();
- if (!entry.Exists)
- return;
-
- // delete children
- if (entry is DirectoryInfo folder)
- {
- foreach (FileSystemInfo child in folder.GetFileSystemInfos())
- this.ForceDelete(child);
- }
-
- // reset permissions & delete
- entry.Attributes = FileAttributes.Normal;
- entry.Delete();
-
- // wait for deletion to finish
- for (int i = 0; i < 10; i++)
- {
- entry.Refresh();
- if (entry.Exists)
- Thread.Sleep(500);
- }
-
- // throw exception if deletion didn't happen before timeout
- entry.Refresh();
- if (entry.Exists)
- throw new IOException($"Timed out trying to delete {entry.FullName}");
- }
-
/// <summary>Interactively ask the user to choose a value.</summary>
/// <param name="print">A callback which prints a message to the console.</param>
/// <param name="message">The message to print.</param>
@@ -707,7 +671,7 @@ namespace StardewModdingApi.Installer
/// <param name="indent">The indentation to prefix to output.</param>
private string InteractivelyChoose(string message, string[] options, string indent = "", Action<string> print = null)
{
- print = print ?? this.PrintInfo;
+ print ??= this.PrintInfo;
while (true)
{