Class OsUtils

    • Method Detail

      • setAndroid

        public static void setAndroid​(Boolean value)
        Override the value returned by isAndroid() programmatically
        Parameters:
        value - Value to set if null then value is auto-detected
      • setDalvikMachine

        public static void setDalvikMachine​(Boolean value)
        Override the value returned by isDalvikMachine() programmatically
        Parameters:
        value - Value to set if null then value is auto-detected
      • isUNIX

        public static boolean isUNIX()
        Returns:
        true if the host is a UNIX system (and not Windows). Note: this does not preclude isAndroid() or isDalvikMachine() from being true as well.
      • 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)
      • getCurrentWorkingDirectory

        public static Path getCurrentWorkingDirectory()
        Returns:
        The (C)urrent (W)orking (D)irectory Path - null if cannot resolve it. Resolution occurs as follows:
        • Consult any currently registered resolver.
        • If no resolver registered, then "user.dir" system property is consulted.
        See Also:
        setCurrentWorkingDirectoryResolver(Supplier)
      • setCurrentWorkingDirectoryResolver

        public static void setCurrentWorkingDirectoryResolver​(Supplier<? extends Path> cwdProvider)
        Allows the user to "plug-in" a resolver for the getCurrentWorkingDirectory() method
        Parameters:
        cwdProvider - The Supplier of the (C)urrent (W)orking (D)irectory Path - if null then "user.dir" system property is consulted
      • 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