Class Platform

java.lang.Object
org.astrogrid.samp.Platform

public abstract class Platform extends Object
Platform-dependent features required by the SAMP implementation.
Since:
14 Jul 2008
Author:
Mark Taylor
  • Constructor Details

    • Platform

      protected Platform(String name)
      Constructor.
      Parameters:
      name - platform name
  • Method Details

    • getHomeDirectory

      public abstract File getHomeDirectory()
      Returns SAMP's definition of the "home" directory.
      Returns:
      directory containing SAMP lockfile
    • getEnv

      public String getEnv(String varname)
      Returns the value of an environment variable. If it can't be done, null is returned.
      Parameters:
      varname - name of environment variable
      Returns:
      value of environment variable
    • setPrivateRead

      public void setPrivateRead(File file) throws IOException
      Sets file permissions on a given file so that it cannot be read by anyone other than its owner.
      Parameters:
      file - file whose permissions are to be altered
      Throws:
      IOException - if permissions cannot be changed
    • getGetenvArgs

      protected abstract String[] getGetenvArgs(String varname)
      Returns an array of words to pass to Runtime.exec(java.lang.String[]) in order to read an environment variable name. If null is returned, no way is known to do this with a system command.
      Parameters:
      varname - environment variable name to read
      Returns:
      exec args
    • getPrivateReadArgs

      protected abstract String[] getPrivateReadArgs(File file) throws IOException
      Returns an array of words to pass to Runtime.exec(java.lang.String[]) in order to set permissions on a given file so that it cannot be read by anyone other than its owner. If null is returned, no way is known to do this with a system command.
      Parameters:
      file - file to alter
      Returns:
      exec args
      Throws:
      IOException
    • getPlatform

      public static Platform getPlatform()
      Returns a Platform instance for the current system.
      Returns:
      platform instance