package com.rf.psychological.utils;

/**
 * @author zzf
 * @description:
 * @date 2021/3/5 9:34
 */

public class OSUtil {


    private static String OS = System.getProperty("os.name").toLowerCase();

    private static OSUtil _instance = new OSUtil();


    private OSUtil(){}

    public static boolean isLinux(){
        return OS.indexOf("linux")>=0;
    }

    public static boolean isMacOS(){
        return OS.indexOf("mac")>=0&&OS.indexOf("os")>0&&OS.indexOf("x")<0;
    }

    public static boolean isMacOSX(){
        return OS.indexOf("mac")>=0&&OS.indexOf("os")>0&&OS.indexOf("x")>0;
    }

    public static boolean isWindows(){
        return OS.indexOf("windows")>=0;
    }

    public static boolean isOS2(){
        return OS.indexOf("os/2")>=0;
    }

    public static boolean isSolaris(){
        return OS.indexOf("solaris")>=0;
    }

    public static boolean isSunOS(){
        return OS.indexOf("sunos")>=0;
    }

    public static boolean isMPEiX(){
        return OS.indexOf("mpe/ix")>=0;
    }

    public static boolean isHPUX(){
        return OS.indexOf("hp-ux")>=0;
    }

    public static boolean isAix(){
        return OS.indexOf("aix")>=0;
    }

    public static boolean isOS390(){
        return OS.indexOf("os/390")>=0;
    }

    public static boolean isFreeBSD(){
        return OS.indexOf("freebsd")>=0;
    }

    public static boolean isIrix(){
        return OS.indexOf("irix")>=0;
    }

    public static boolean isDigitalUnix(){
        return OS.indexOf("digital")>=0&&OS.indexOf("unix")>0;
    }

    public static boolean isNetWare(){
        return OS.indexOf("netware")>=0;
    }

    public static boolean isOSF1(){
        return OS.indexOf("osf1")>=0;
    }

    public static boolean isOpenVMS(){
        return OS.indexOf("openvms")>=0;
    }


    /**
     * 获取操作系统名字
     * @return 操作系统名
     */
    public static String getOSname(){
        if(isAix()){
            return "AIX";
        }else if (isDigitalUnix()) {
            return "Digital Unix";
        }else if (isFreeBSD()) {
            return "FreeBSD";
        }else if (isHPUX()) {
            return "HP-UX";
        }else if (isIrix()) {
            return "Irix";
        }else if (isLinux()) {
            return "Linux";
        }else if (isMacOS()) {
            return "Mac OS";
        }else if (isMacOSX()) {
            return "Mac OS X";
        }else if (isMPEiX()) {
            return "MPE/iX";
        }else if (isNetWare()) {
            return "NetWare";
        }else if (isOpenVMS()) {
            return "OpenVMS";
        }else if (isOS2()) {
            return "OS/2";
        }else if (isOS390()) {
            return "OS/390";
        }else if (isOSF1()) {
            return "OSF1";
        }else if (isSolaris()) {
            return "Solaris";
        }else if (isSunOS()) {
            return "SunOS";
        }else if (isWindows()) {
            return "Windows";
        }else{
            return "Others";
        }
    }
}
