Class Platform


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

      Constructors 
      Modifier Constructor Description
      protected Platform​(java.lang.String name)
      Constructor.
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String getEnv​(java.lang.String varname)
      Returns the value of an environment variable.
      protected abstract java.lang.String[] getGetenvArgs​(java.lang.String varname)
      Returns an array of words to pass to Runtime.exec(java.lang.String[]) in order to read an environment variable name.
      abstract java.io.File getHomeDirectory()
      Returns SAMP's definition of the "home" directory.
      static Platform getPlatform()
      Returns a Platform instance for the current system.
      protected abstract java.lang.String[] getPrivateReadArgs​(java.io.File file)
      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.
      void setPrivateRead​(java.io.File file)
      Sets file permissions on a given file so that it cannot be read by anyone other than its owner.
      • Methods inherited from class java.lang.Object

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

      • Platform

        protected Platform​(java.lang.String name)
        Constructor.
        Parameters:
        name - platform name
    • Method Detail

      • getHomeDirectory

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

        public java.lang.String getEnv​(java.lang.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​(java.io.File file)
                            throws java.io.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:
        java.io.IOException - if permissions cannot be changed
      • getGetenvArgs

        protected abstract java.lang.String[] getGetenvArgs​(java.lang.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 java.lang.String[] getPrivateReadArgs​(java.io.File file)
                                                          throws java.io.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:
        java.io.IOException
      • getPlatform

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