Working version

This commit is contained in:
2026-08-11 12:34:02 +02:00
parent 438f163630
commit ad205bb534
12 changed files with 1006 additions and 179 deletions
+34
View File
@@ -22,6 +22,18 @@ public static class ToolExtractor
return await ExtractAsync(cancellationToken);
}
public static bool TryResolveFromSystemPath(out ToolPaths? tools)
{
tools = null;
string? ffmpeg = FindOnPath("ffmpeg.exe");
string? ffprobe = FindOnPath("ffprobe.exe");
if (ffmpeg is null || ffprobe is null)
return false;
tools = new ToolPaths(ffmpeg, ffprobe);
return true;
}
private static async Task<ToolPaths> ExtractAsync(CancellationToken cancellationToken = default)
{
string toolDir = Path.Combine(
@@ -66,4 +78,26 @@ public static class ToolExtractor
byte[] bHash = sha.ComputeHash(b);
return aHash.AsSpan().SequenceEqual(bHash);
}
private static string? FindOnPath(string fileName)
{
string? path = Environment.GetEnvironmentVariable("PATH");
if (string.IsNullOrWhiteSpace(path))
return null;
foreach (string directory in path.Split(Path.PathSeparator, StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries))
{
try
{
string candidate = Path.Combine(directory, fileName);
if (File.Exists(candidate))
return candidate;
}
catch
{
}
}
return null;
}
}