From 3862f6c97c0a7574fec1919b96732918928c2999 Mon Sep 17 00:00:00 2001 From: JieXu Date: Fri, 12 Sep 2025 11:43:42 +0800 Subject: [PATCH] Update Utils.cs --- v2rayN/AmazTool/Utils.cs | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/v2rayN/AmazTool/Utils.cs b/v2rayN/AmazTool/Utils.cs index df13ecf6..1d9fdb33 100644 --- a/v2rayN/AmazTool/Utils.cs +++ b/v2rayN/AmazTool/Utils.cs @@ -1,4 +1,7 @@ +using System; using System.Diagnostics; +using System.IO; +using System.Threading; namespace AmazTool; @@ -48,4 +51,31 @@ internal class Utils Thread.Sleep(1000); } } + + public static bool IsPackagedInstall() + { + try + { + if (OperatingSystem.IsWindows() || OperatingSystem.IsMacOS()) + return false; + + if (!string.IsNullOrEmpty(Environment.GetEnvironmentVariable("APPIMAGE"))) + return true; + + var sp = StartupPath()?.Replace('\\', '/'); + if (!string.IsNullOrEmpty(sp) && sp.StartsWith("/opt/v2rayN", StringComparison.Ordinal)) + return true; + + var procPath = Environment.ProcessPath; + var procDir = string.IsNullOrEmpty(procPath) + ? "" + : Path.GetDirectoryName(procPath)?.Replace('\\', '/'); + if (!string.IsNullOrEmpty(procDir) && procDir.StartsWith("/opt/v2rayN", StringComparison.Ordinal)) + return true; + } + catch + { + } + return false; + } }