using System; using StardewModdingAPI.Toolkit.Framework; namespace StardewModdingAPI.Toolkit.Utilities { /// Provides methods for fetching environment information. public static class EnvironmentUtility { /********* ** Fields *********/ /// The cached platform. private static Platform? CachedPlatform; /********* ** Public methods *********/ /// Detect the current OS. public static Platform DetectPlatform() { Platform? platform = EnvironmentUtility.CachedPlatform; if (platform == null) { string rawPlatform = LowLevelEnvironmentUtility.DetectPlatform(); EnvironmentUtility.CachedPlatform = platform = (Platform)Enum.Parse(typeof(Platform), rawPlatform, ignoreCase: true); } return platform.Value; } /// Get the human-readable OS name and version. /// The current platform. public static string GetFriendlyPlatformName(Platform platform) { return LowLevelEnvironmentUtility.GetFriendlyPlatformName(platform.ToString()); } /// Get whether an executable is 64-bit. /// The absolute path to the assembly file. public static bool Is64BitAssembly(string path) { return LowLevelEnvironmentUtility.Is64BitAssembly(path); } } }