示例#1
0
        private static OsFlavor DetermineOSFlavor()
        {
            if (!IsUnix) // assume Windows
            {
                return(OsFlavor.Windows);
            }

            string uname = null;

            try
            {
                uname = ShellExecutor.GetOutput("uname", "");
            }
            catch (Exception ex)
            {
                Log.ErrorException(ex, "Couldn't determine the flavor of Unix-like OS.");
            }
            uname = uname.Trim().ToLower();
            switch (uname)
            {
            case "linux":
                return(OsFlavor.Linux);

            case "darwin":
                return(OsFlavor.MacOS);

            case "freebsd":
            case "netbsd":
            case "openbsd":
                return(OsFlavor.BSD);

            default:
                return(OsFlavor.Unknown);
            }
        }
示例#2
0
        private static OsFlavor DetermineOSFlavor()
        {
            if (!IsUnix) // assume Windows
            {
                return(OsFlavor.Windows);
            }

            string uname = null;

            try
            {
                uname = ShellExecutor.GetOutput("uname", "");
            }
            catch (Exception ex)
            {
                Log.ErrorException(ex, "Couldn't determine the flavor of Unix-like OS.");
            }

            switch (uname)
            {
            case "Linux":
                return(OsFlavor.Linux);

            case "Darwin":
                return(OsFlavor.MacOS);

            case "FreeBSD":
            case "NetBSD":
            case "OpenBSD":
                return(OsFlavor.BSD);

            default:
                return(OsFlavor.Unknown);
            }
        }