diff options
Diffstat (limited to 'src/SMAPI.Installer')
-rw-r--r-- | src/SMAPI.Installer/InteractiveInstaller.cs | 40 | ||||
-rw-r--r-- | src/SMAPI.Installer/SMAPI.Installer.csproj | 8 |
2 files changed, 3 insertions, 45 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) { diff --git a/src/SMAPI.Installer/SMAPI.Installer.csproj b/src/SMAPI.Installer/SMAPI.Installer.csproj index 79e19d89..44ed3bd1 100644 --- a/src/SMAPI.Installer/SMAPI.Installer.csproj +++ b/src/SMAPI.Installer/SMAPI.Installer.csproj @@ -1,11 +1,8 @@ <Project Sdk="Microsoft.NET.Sdk"> - <PropertyGroup> - <AssemblyName>SMAPI.Installer</AssemblyName> <RootNamespace>StardewModdingAPI.Installer</RootNamespace> <Description>The SMAPI installer for players.</Description> <TargetFramework>net45</TargetFramework> - <LangVersion>latest</LangVersion> <OutputType>Exe</OutputType> <PlatformTarget>x86</PlatformTarget> <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath> @@ -16,13 +13,10 @@ </ItemGroup> <ItemGroup> - <None Update="assets\*"> - <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> - </None> + <None Update="assets\*" CopyToOutputDirectory="PreserveNewest" /> </ItemGroup> <Import Project="..\SMAPI.Internal\SMAPI.Internal.projitems" Label="Shared" /> <Import Project="..\..\build\common.targets" /> <Import Project="..\..\build\prepare-install-package.targets" /> - </Project> |