Class SystemHelper


  • public class SystemHelper
    extends java.lang.Object
    Helper class for system variables handling.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String PATH_SEPARATOR  
    • Constructor Summary

      Constructors 
      Constructor Description
      SystemHelper()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String[] addEnv​(java.lang.String[] pEnv, java.lang.String pName, java.lang.String pValue, java.lang.String pSeparator)
      Add an environment variable to an array of existing variables.
      static java.lang.String[] addPathEnv​(java.lang.String[] pEnv, java.lang.String pName, java.lang.String[] pValue)
      Add an environment variable to an array of existing variables.
      static java.io.File getFile​(org.eclipse.core.resources.IResource pRes)
      Get a normal Java File from an Eclipse IResource.
      static java.io.File getFile​(IUnoidlProject pPrj)
      Get a normal Java File from an IUnoidlProject.
      static java.lang.String[] getSystemEnvironement()  
      static java.lang.Process runTool​(java.lang.String pShellCommand, java.lang.String[] pEnv, java.io.File pExecDir)
      Run a shell command with a given environment and an optional execution directory.
      static java.lang.Process runToolWithSysEnv​(java.lang.String pShellCommand, java.io.File pExecDir)
      Run a shell command with the system environment and an optional execution directory.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • PATH_SEPARATOR

        public static final java.lang.String PATH_SEPARATOR
    • Constructor Detail

      • SystemHelper

        public SystemHelper()
    • Method Detail

      • getFile

        public static java.io.File getFile​(org.eclipse.core.resources.IResource pRes)
        Get a normal Java File from an Eclipse IResource.
        Parameters:
        pRes - the IResource to convert
        Returns:
        the equivalent File
      • addPathEnv

        public static java.lang.String[] addPathEnv​(java.lang.String[] pEnv,
                                                    java.lang.String pName,
                                                    java.lang.String[] pValue)
        Add an environment variable to an array of existing variables.
        Parameters:
        pEnv - the array of existing environment variables where to add the new variable
        pName - the name of the variable to add
        pValue - the value of the variable to add
        Returns:
        the completed array
      • addEnv

        public static java.lang.String[] addEnv​(java.lang.String[] pEnv,
                                                java.lang.String pName,
                                                java.lang.String pValue,
                                                java.lang.String pSeparator)
        Add an environment variable to an array of existing variables.
        Parameters:
        pEnv - the array of existing environment variables where to add the new variable
        pName - the name of the variable to add
        pValue - the value of the variable to add
        pSeparator - the separator to use if there is already a variable with the same name. If null, the old variable will be replaced
        Returns:
        the completed array
      • getSystemEnvironement

        public static java.lang.String[] getSystemEnvironement()
        Returns:
        the system environment variables
      • runToolWithSysEnv

        public static java.lang.Process runToolWithSysEnv​(java.lang.String pShellCommand,
                                                          java.io.File pExecDir)
                                                   throws java.io.IOException
        Run a shell command with the system environment and an optional execution directory.
        Parameters:
        pShellCommand - the command to run
        pExecDir - the execution directory or null if none
        Returns:
        the process for the running command
        Throws:
        java.io.IOException - if anything wrong happens during the command launch
      • runTool

        public static java.lang.Process runTool​(java.lang.String pShellCommand,
                                                java.lang.String[] pEnv,
                                                java.io.File pExecDir)
                                         throws java.io.IOException
        Run a shell command with a given environment and an optional execution directory.
        Parameters:
        pShellCommand - the command to run
        pEnv - the environment variables
        pExecDir - the execution directory or null if none
        Returns:
        the process for the running command
        Throws:
        java.io.IOException - if anything wrong happens during the command launch