Class OsUtils

    • Field Detail

      • CURRENT_USER_OVERRIDE_PROP

        public static final String CURRENT_USER_OVERRIDE_PROP
        Property that can be used to override the reported value from getCurrentUser(). If not set then "user.name" system property is used
        See Also:
        Constant Field Values
      • JAVA_VERSION_OVERRIDE_PROP

        public static final String JAVA_VERSION_OVERRIDE_PROP
        Property that can be used to override the reported value from getJavaVersion(). If not set then "java.version" system property is used
        See Also:
        Constant Field Values
      • OS_TYPE_OVERRIDE_PROP

        public static final String OS_TYPE_OVERRIDE_PROP
        Property that can be used to override the reported value from isWin32(). If not set then "os.name" system property is used
        See Also:
        Constant Field Values
      • LINUX_COMMAND

        public static final List<String> LINUX_COMMAND
      • WINDOWS_COMMAND

        public static final List<String> WINDOWS_COMMAND
    • Method Detail

      • isUNIX

        public static boolean isUNIX()
        Returns:
        true if the host is a UNIX system (and not Windows).
      • isOSX

        public static boolean isOSX()
        Returns:
        true if the host is a OSX (and not Windows or Unix).
      • resolveDefaultInteractiveShellCommand

        public static String resolveDefaultInteractiveShellCommand()
      • resolveDefaultInteractiveShellCommand

        public static String resolveDefaultInteractiveShellCommand​(boolean winOS)
      • resolveDefaultInteractiveCommandElements

        public static List<String> resolveDefaultInteractiveCommandElements()
      • resolveDefaultInteractiveCommandElements

        public static List<String> resolveDefaultInteractiveCommandElements​(boolean winOS)
      • getCanonicalUser

        public static String getCanonicalUser​(String user)
        Remove Windows domain and/or group prefix as well as "(User);" suffix
        Parameters:
        user - The original username - ignored if null/empty
        Returns:
        The canonical user - unchanged if Unix O/S
      • resolveCanonicalGroup

        public static String resolveCanonicalGroup​(String group,
                                                   String user)
        Attempts to resolve canonical group name for Windows
        Parameters:
        group - The original group name - used if not null/empty
        user - The owner name - sometimes it contains a group name
        Returns:
        The canonical group name
      • setCurrentUser

        public static void setCurrentUser​(String username)
        Can be used to programmatically set the username reported by getCurrentUser()
        Parameters:
        username - The username to set - if null then CURRENT_USER_OVERRIDE_PROP will be consulted
      • setJavaVersion

        public static void setJavaVersion​(VersionInfo version)
        Set programmatically the reported Java version
        Parameters:
        version - The version - if null then it will be automatically resolved
      • getComparablePath

        public static String getComparablePath​(String path)
        Parameters:
        path - The original path
        Returns:
        A path that can be compared with another one where case sensitivity of the underlying O/S has been taken into account - never null