content: package org.example.utils;
  
  import org.example.common.PlatformEnum;
  
  import java.util.Locale;
  
  /**
   *
   * referer https://github.com/alibaba/arthas/blob/master/common/src/main/java/com/taobao/arthas/common/OSUtils.java
   *
   */
  
  public class OSUtils {
      private static final String OPERATING_SYSTEM_NAME = System.getProperty("os.name").toLowerCase(Locale.ENGLISH);
  
      static PlatformEnum platform;
      static {
          if (OPERATING_SYSTEM_NAME.startsWith("linux")) {
              platform = PlatformEnum.LINUX;
          } else if (OPERATING_SYSTEM_NAME.startsWith("mac") || OPERATING_SYSTEM_NAME.startsWith("darwin")) {
              platform = PlatformEnum.MACOSX;
          } else if (OPERATING_SYSTEM_NAME.startsWith("windows")) {
              platform = PlatformEnum.WINDOWS;
          } else {
              platform = PlatformEnum.UNKNOWN;
          }
      }
  
      private OSUtils() {
      }
  
      public static boolean isWindows() {
          return platform == PlatformEnum.WINDOWS;
      }
  
      public static boolean isLinux() {
          return platform == PlatformEnum.LINUX;
      }
  
      public static boolean isMac() {
          return platform == PlatformEnum.MACOSX;
      }
  
      public static boolean isCygwinOrMinGW() {
          if (isWindows()) {
              if ((System.getenv("MSYSTEM") != null && System.getenv("MSYSTEM").startsWith("MINGW"))
                      || "/bin/bash".equals(System.getenv("SHELL"))) {
                  return true;
              }
          }
          return false;
      }
  
  }
  