Skip to content

Commit

Permalink
寻找工具时当然需要包含工作目录.
Browse files Browse the repository at this point in the history
  • Loading branch information
copyliu committed May 21, 2022
1 parent 06dd2d7 commit 199cd64
Showing 1 changed file with 5 additions and 27 deletions.
32 changes: 5 additions & 27 deletions BBDown/BBDownUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -812,33 +812,11 @@ public static string GetMp4boxMetaString(List<ViewPoint> points)

public static string FindExecutable(string name)
{
if (OperatingSystem.IsWindows())
{
var file = Path.Combine(Program.APP_DIR, name + ".exe");
if (File.Exists(file))
return file;
var path = Environment.GetEnvironmentVariable("PATH");
foreach (var item in path.Split(';'))
{
file = Path.Combine(item, name + ".exe");
if (File.Exists(file))
return file;
}
}
else
{
var file = Path.Combine(Program.APP_DIR, name);
if (File.Exists(file))
return file;
var path = Environment.GetEnvironmentVariable("PATH");
foreach (var item in path.Split(':'))
{
file = Path.Combine(item, name);
if (File.Exists(file))
return file;
}
}
return null;
var fileExt = OperatingSystem.IsWindows() ? ".exe" : "";
var searchPath = new List<string>() { Environment.CurrentDirectory, Program.APP_DIR };
var envPath = Environment.GetEnvironmentVariable("PATH")?.Split(Path.PathSeparator) ??
Array.Empty<string>();
return searchPath.Concat(envPath).Select(p => Path.Combine(p, name + fileExt)).FirstOrDefault(File.Exists);
}

public static async Task<bool> CheckLogin(string cookie)
Expand Down

0 comments on commit 199cd64

Please sign in to comment.