This commit is contained in:
nub31
2025-06-29 16:03:56 +02:00
parent 253e7e1e24
commit 5127882163

View File

@@ -0,0 +1,29 @@
using System.Diagnostics;
namespace CLI;
public static class Archive
{
public static async Task<bool> Invoke(string fileName, IEnumerable<string> objectFiles)
{
using var process = new Process();
process.StartInfo = new ProcessStartInfo("ar", ["rcs", fileName, ..objectFiles])
{
UseShellExecute = false,
RedirectStandardOutput = true,
RedirectStandardError = true,
CreateNoWindow = true
};
process.Start();
await process.WaitForExitAsync();
var errors = await process.StandardError.ReadToEndAsync();
if (!string.IsNullOrWhiteSpace(errors))
{
await Console.Error.WriteLineAsync("ar error when archiving:\n" + errors);
}
return process.ExitCode == 0;
}
}