stabilizaiton work - projects rework for maintenanceability and ui livening

This commit is contained in:
master
2026-02-03 23:40:04 +02:00
parent 074ce117ba
commit 557feefdc3
3305 changed files with 186813 additions and 107843 deletions

View File

@@ -0,0 +1,64 @@
using System;
using System.Collections.Generic;
using System.IO;
namespace StellaOps.Interop;
internal sealed class ToolPathResolver : IToolPathResolver
{
private readonly IReadOnlyDictionary<string, string> _toolPaths;
public ToolPathResolver(IReadOnlyDictionary<string, string> toolPaths)
{
_toolPaths = toolPaths ?? throw new ArgumentNullException(nameof(toolPaths));
}
public string? ResolveToolPath(string tool)
{
if (_toolPaths.TryGetValue(tool, out var configured) && File.Exists(configured))
{
return configured;
}
return FindOnPath(tool);
}
public static string? FindOnPath(string tool)
{
if (File.Exists(tool))
{
return Path.GetFullPath(tool);
}
var path = Environment.GetEnvironmentVariable("PATH");
if (string.IsNullOrWhiteSpace(path))
{
return null;
}
foreach (var dir in path.Split(Path.PathSeparator))
{
if (string.IsNullOrWhiteSpace(dir))
{
continue;
}
var candidate = Path.Combine(dir, tool);
if (File.Exists(candidate))
{
return candidate;
}
if (OperatingSystem.IsWindows())
{
var exeCandidate = candidate + ".exe";
if (File.Exists(exeCandidate))
{
return exeCandidate;
}
}
}
return null;
}
}