using System.IO.Compression; using System; using System.IO; using SharpCompress.Archives; using SharpCompress.Common; using SharpCompress.Readers; using System.Diagnostics; using CmlLib.Core; namespace BlightFlame { static public class Utils { public static void UnzipTarGzFile(string filePath, string destinationPath) { using (Stream stream = File.OpenRead(filePath)) { using (var reader = ReaderFactory.Open(stream)) { while (reader.MoveToNextEntry()) { if (!reader.Entry.IsDirectory) { reader.WriteEntryToDirectory(destinationPath, new ExtractionOptions() { ExtractFullPath = true, Overwrite = true }); } } } } } public static void LinuxExec(string cmd) { var escapedArgs = cmd.Replace("\"", "\\\""); using var process = new Process { StartInfo = new ProcessStartInfo { RedirectStandardOutput = true, UseShellExecute = false, CreateNoWindow = true, WindowStyle = ProcessWindowStyle.Hidden, FileName = "/bin/bash", Arguments = $"-c \"{escapedArgs}\"" } }; process.Start(); process.WaitForExit(); } public static async Task> GetAllMcVersions() { return await Task.Run(async() => { var ln = new MinecraftLauncher(); var result = new List(); foreach (var x in await ln.GetAllVersionsAsync()) { result.Add(x.Name); } return result; }); } } }