diff --git a/WelsonJS.Toolkit/WelsonJS.Launcher/ZipExtractor.cs b/WelsonJS.Toolkit/WelsonJS.Launcher/ZipExtractor.cs index 01bab9a..2a838bb 100644 --- a/WelsonJS.Toolkit/WelsonJS.Launcher/ZipExtractor.cs +++ b/WelsonJS.Toolkit/WelsonJS.Launcher/ZipExtractor.cs @@ -42,6 +42,12 @@ namespace WelsonJS.Launcher ExtractCommand = (src, dest) => $"-ext2simple \"{src}\" \"{dest}\"" }, new Extractor + { + Name = "tar (Windows)", + FileName = "tar.exe", + ExtractCommand = (src, dest) => $"-xf \"{src}\" -C \"{dest}\"" + }, + new Extractor { Name = "WinZip", FileName = "wzunzip.exe", @@ -58,18 +64,6 @@ namespace WelsonJS.Launcher Name = "Bandizip", FileName = "Bandizip.exe", ExtractCommand = (src, dest) => $"x -o:\"{dest}\" \"{src}\" -y" - }, - new Extractor - { - Name = "tar (Windows)", // Windows 10 build 17063 or later - FileName = "tar.exe", - ExtractCommand = (src, dest) => $"-xf \"{src}\" -C \"{dest}\"" - }, - new Extractor - { - Name = "unzip", // Info-ZIP, Cygwin - FileName = "unzip.exe", - ExtractCommand = (src, dest) => $"\"{src}\" -d \"{dest}\" -o" } }; @@ -92,16 +86,12 @@ namespace WelsonJS.Launcher foreach (var extractor in AvailableExtractors.Where(e => e.Path != null)) { if (RunProcess(extractor.Path, extractor.ExtractCommand(filePath, workingDirectory))) + { return true; + } } - if (ExtractUsingPowerShell(filePath, workingDirectory)) - return true; - - if (ExtractUsingShell(filePath, workingDirectory)) - return true; - - return false; + return ExtractUsingShell(filePath, workingDirectory); } private bool IsValidFile(string filePath) @@ -167,9 +157,7 @@ namespace WelsonJS.Launcher } } } - catch { - // ignore an exception - } + catch { } } } @@ -193,15 +181,6 @@ namespace WelsonJS.Launcher } } - private bool ExtractUsingPowerShell(string filePath, string workingDirectory) - { - var escapedSrc = filePath.Replace("'", "''"); - var escapedDest = workingDirectory.Replace("'", "''"); - var script = $"Expand-Archive -LiteralPath '{escapedSrc}' -DestinationPath '{escapedDest}' -Force"; - - return RunProcess("powershell.exe", $"-NoProfile -Command \"{script}\""); - } - private bool ExtractUsingShell(string filePath, string workingDirectory) { var shellAppType = Type.GetTypeFromProgID("Shell.Application");