diff --git a/v2rayN/ServiceLib/Common/Utils.cs b/v2rayN/ServiceLib/Common/Utils.cs index c6937911..585951bb 100644 --- a/v2rayN/ServiceLib/Common/Utils.cs +++ b/v2rayN/ServiceLib/Common/Utils.cs @@ -710,7 +710,7 @@ namespace ServiceLib.Common public static string StartupPath() { - if (Utils.IsLinux() && Environment.GetEnvironmentVariable("V2RAYN_LOCAL_APPLICATION_DATA") == "1") + if (Utils.IsNonWindows() && Environment.GetEnvironmentVariable("V2RAYN_LOCAL_APPLICATION_DATA") == "1") { return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "v2rayN"); } @@ -838,6 +838,8 @@ namespace ServiceLib.Common public static bool IsOSX() => RuntimeInformation.IsOSPlatform(OSPlatform.OSX); + public static bool IsNonWindows() => !RuntimeInformation.IsOSPlatform(OSPlatform.Windows); + public static string GetExeName(string name) { return IsWindows() ? $"{name}.exe" : name; diff --git a/v2rayN/ServiceLib/Handler/AppHandler.cs b/v2rayN/ServiceLib/Handler/AppHandler.cs index c8e31186..31cb8b2e 100644 --- a/v2rayN/ServiceLib/Handler/AppHandler.cs +++ b/v2rayN/ServiceLib/Handler/AppHandler.cs @@ -46,7 +46,7 @@ public bool InitApp() { - if (Utils.IsLinux() && Utils.HasWritePermission() == false) + if (Utils.IsNonWindows() && Utils.HasWritePermission() == false) { Environment.SetEnvironmentVariable("V2RAYN_LOCAL_APPLICATION_DATA", "1", EnvironmentVariableTarget.Process); } diff --git a/v2rayN/ServiceLib/Handler/CoreHandler.cs b/v2rayN/ServiceLib/Handler/CoreHandler.cs index 60c7175a..5dc62332 100644 --- a/v2rayN/ServiceLib/Handler/CoreHandler.cs +++ b/v2rayN/ServiceLib/Handler/CoreHandler.cs @@ -24,7 +24,7 @@ namespace ServiceLib.Handler Environment.SetEnvironmentVariable("V2RAY_LOCATION_ASSET", Utils.GetBinPath(""), EnvironmentVariableTarget.Process); Environment.SetEnvironmentVariable("XRAY_LOCATION_ASSET", Utils.GetBinPath(""), EnvironmentVariableTarget.Process); - if (Utils.IsLinux() || Utils.IsOSX()) + if (Utils.IsNonWindows()) { var coreInfo = CoreInfoHandler.Instance.GetCoreInfo(); foreach (var it in coreInfo) @@ -221,7 +221,7 @@ namespace ServiceLib.Handler { return _config.TunModeItem.EnableTun && eCoreType == ECoreType.sing_box - && (Utils.IsLinux() || Utils.IsOSX()) + && (Utils.IsNonWindows()) //&& _config.TunModeItem.LinuxSudoPwd.IsNotEmpty() ; } diff --git a/v2rayN/ServiceLib/ViewModels/CheckUpdateViewModel.cs b/v2rayN/ServiceLib/ViewModels/CheckUpdateViewModel.cs index dcfc122e..f4e31c09 100644 --- a/v2rayN/ServiceLib/ViewModels/CheckUpdateViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/CheckUpdateViewModel.cs @@ -262,7 +262,7 @@ namespace ServiceLib.ViewModels FileManager.ZipExtractToFile(fileName, toPath, _config.GuiItem.IgnoreGeoUpdateCore ? "geo" : ""); } - if (Utils.IsLinux() || Utils.IsOSX()) + if (Utils.IsNonWindows()) { var filesList = (new DirectoryInfo(toPath)).GetFiles().Select(u => u.FullName).ToList(); foreach (var file in filesList) diff --git a/v2rayN/v2rayN.Desktop/Views/OptionSettingWindow.axaml.cs b/v2rayN/v2rayN.Desktop/Views/OptionSettingWindow.axaml.cs index 84270380..af27a10f 100644 --- a/v2rayN/v2rayN.Desktop/Views/OptionSettingWindow.axaml.cs +++ b/v2rayN/v2rayN.Desktop/Views/OptionSettingWindow.axaml.cs @@ -215,7 +215,7 @@ namespace v2rayN.Desktop.Views { return lstFonts; } - else if (Utils.IsLinux() || Utils.IsOSX()) + else if (Utils.IsNonWindows()) { var result = await Utils.GetLinuxFontFamily("zh"); if (result.IsNullOrEmpty())