Class SystemHelper

java.lang.Object
org.libreoffice.ide.eclipse.core.model.utils.SystemHelper

public class SystemHelper extends Object
Helper class for system variables handling.
  • Field Details

    • PATH_SEPARATOR

      public static final String PATH_SEPARATOR
  • Constructor Details

    • SystemHelper

      public SystemHelper()
  • Method Details

    • getFile

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

      public static File getFile(IUnoidlProject unoPrj)
      Get a normal Java File from an IUnoidlProject.
      Parameters:
      unoPrj - IUnoidlProject to convert
      Returns:
      the equivalent File
    • addPathEnv

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

      public static String[] addEnv(String[] env, String name, String value, String separator)
      Add an environment variable to an array of existing variables.
      Parameters:
      env - the array of existing environment variables where to add the new variable
      name - the name of the variable to add
      value - the value of the variable to add
      separator - 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 String[] getSystemEnvironement()
      Returns:
      the system environment variables
    • runToolWithSysEnv

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

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