/* * GNU AFFERO GENERAL PUBLIC LICENSE * Version 3, 19 November 2007 * Copyright (C) 2007 Free Software Foundation, Inc. * Everyone is permitted to copy and distribute verbatim copies * of this license document, but changing it is not allowed. */ using System; using System.IO; namespace UVtools.Core.SystemOS; /// /// MacOS specific methods /// public static class macOS { /// /// Gets if is running under MacOS and under .app format /// public static bool IsRunningApp => OperatingSystem.IsMacOS() && AppContext.BaseDirectory.EndsWith(Path.Combine(".app", "Contents", $"MacOS{Path.DirectorySeparatorChar}")); /// /// Gets if is running under macOS and under .app format and return the full root path for the running .app /// public static bool IsRunningAppGetPath(out string? path) { path = RunningAppRootPath; return !string.IsNullOrWhiteSpace(path); } /// /// Gets the full root path for the running .app. Returns null or empty if not running an macOS .app /// public static string? RunningAppRootPath => IsRunningApp ? Directory.GetParent(AppContext.BaseDirectory)?.Parent?.Parent?.FullName : null; /// /// Gets the name of the running .app. Returns null or empty if not running an macOS .app /// public static string? RunningAppName => IsRunningApp ? Directory.GetParent(AppContext.BaseDirectory)?.Parent?.Parent?.Name : null; }