Skip to content

Commit

Permalink
Detect when EXE is launched through a symlink (#125)
Browse files Browse the repository at this point in the history
  • Loading branch information
MichalStrehovsky committed Nov 5, 2023
1 parent f81771e commit 623d32a
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/bflat/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
using System.CommandLine.Builder;
using System.CommandLine.Help;
using System.CommandLine.Parsing;
using System.Diagnostics;
using System.IO;
using System.Reflection;

class Program
Expand All @@ -27,6 +29,18 @@ class Program

private static int Main(string[] args)
{
string exeName = Environment.ProcessPath;
if (exeName != null)
{
FileSystemInfo actualExeInfo = File.ResolveLinkTarget(exeName, returnFinalTarget: true);
if (actualExeInfo != null)
{
Process p = Process.Start(actualExeInfo.FullName, args);
p.WaitForExit();
return p.ExitCode;
}
}

using PerfWatch total = new PerfWatch("Total");

var root = new RootCommand(
Expand Down

0 comments on commit 623d32a

Please sign in to comment.