mirror of
https://gitlab.com/nullmax17/PlombirLauncher.git
synced 2025-03-15 02:11:11 +03:00
74 lines
2.1 KiB
C#
74 lines
2.1 KiB
C#
|
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<List<string>> GetAllMcVersions()
|
||
|
{
|
||
|
return await Task.Run(async() => {
|
||
|
var ln = new MinecraftLauncher();
|
||
|
var result = new List<string>();
|
||
|
foreach (var x in await ln.GetAllVersionsAsync())
|
||
|
{
|
||
|
result.Add(x.Name);
|
||
|
}
|
||
|
return result;
|
||
|
});
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
}
|
||
|
|
||
|
}
|