com.dalsemi.fs
Class DSFile

java.lang.Object
  |
  +--java.io.File
        |
        +--com.dalsemi.fs.DSFile

public class DSFile
extends java.io.File

The TINI implementation of a file. This class has all of the methods defined in java.io.File in addition to methods for executing a file in a seperate process and setting the permissions defined by the TINI filesystem.

See Also:
Serialized Form

Fields inherited from class java.io.File
pathSeparator, pathSeparatorChar, separator, separatorChar
 
Constructor Summary
DSFile(java.io.File parent, java.lang.String child)
          Creates a new DSFile instance from a parent abstract pathname and a child pathname string.
DSFile(java.lang.String pathname)
          Creates a new DSFile instance by converting the given pathname string into an abstract pathname.
DSFile(java.lang.String parent, java.lang.String child)
          Creates a new DSFile instance from a parent pathname string and a child pathname string.
 
Method Summary
 boolean canExec()
          Determines if the current user has execute permissions for this file.
 int executeFile(java.io.InputStream stdin, java.io.OutputStream stdout, java.io.OutputStream stderr, java.lang.String[] args, boolean foreground, int ownerID, java.lang.String processName)
          Executes this file.
 int executeFile(int ownerID)
          Executes this file in the foreground using the default streams for in, out, and err.
 int getOtherPermissions()
          Gets the permissions for all users other than this file's owner.
 int getUserPermissions()
          Gets the permissions for this file's owner.
 java.lang.String[] list(boolean longls)
          If this file represents a directory, this method returns a listing of that directory's contents.
 void setOtherPermissions(int perms)
          Sets the permissions for all users other than this file's owner.
 void setUserPermissions(int perms)
          Sets the permissions for this file's owner.
 
Methods inherited from class java.io.File
canRead, canWrite, compareTo, compareTo, createNewFile, createTempFile, createTempFile, delete, deleteOnExit, equals, exists, getAbsoluteFile, getAbsolutePath, getCanonicalFile, getCanonicalPath, getName, getParent, getParentFile, getPath, hashCode, isAbsolute, isDirectory, isFile, isHidden, lastModified, length, list, list, listFiles, listFiles, listFiles, listRoots, mkdir, mkdirs, renameTo, setLastModified, setReadOnly, toString, toURL
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DSFile

public DSFile(java.lang.String pathname)
Creates a new DSFile instance by converting the given pathname string into an abstract pathname. If the given string is the empty string, then the result is the root directory.
Parameters:
pathname - A pathname string

DSFile

public DSFile(java.lang.String parent,
              java.lang.String child)
Creates a new DSFile instance from a parent pathname string and a child pathname string.

If parent is null then the new DSFile instance is created as if by invoking the single-argument DSFile constructor on the given child pathname string.

Otherwise the parent pathname string is taken to denote a directory, and the child pathname string is taken to denote either a directory or a file. If the child pathname string is absolute then it is converted into a relative pathname in a system-dependent way. If parent is the empty string then the new DSFile instance is created by converting child into an abstract pathname and resolving the result against a system-dependent default directory. Otherwise each pathname string is converted into an abstract pathname and the child abstract pathname is resolved against the parent.

Parameters:
parent - The parent pathname string
child - The child pathname string

DSFile

public DSFile(java.io.File parent,
              java.lang.String child)
Creates a new DSFile instance from a parent abstract pathname and a child pathname string.

If parent is null then the new DSFile instance is created as if by invoking the single-argument DSFile constructor on the given child pathname string.

Otherwise the parent abstract pathname is taken to denote a directory, and the child pathname string is taken to denote either a directory or a file. If the child pathname string is absolute then it is converted into a relative pathname in a system-dependent way. If parent is the empty abstract pathname then the new File instance is created by converting child into an abstract pathname and resolving the result against a system-dependent default directory. Otherwise each pathname string is converted into an abstract pathname and the child abstract pathname is resolved against the parent.

Parameters:
parent - The parent abstract pathname
child - The child pathname string
Method Detail

executeFile

public int executeFile(int ownerID)
                throws java.io.IOException
Executes this file in the foreground using the default streams for in, out, and err.
Parameters:
ownerID - the id of the user executing this file.
Returns:
the process id
Throws:
java.io.IOException -  

executeFile

public int executeFile(java.io.InputStream stdin,
                       java.io.OutputStream stdout,
                       java.io.OutputStream stderr,
                       java.lang.String[] args,
                       boolean foreground,
                       int ownerID,
                       java.lang.String processName)
                throws java.io.IOException
Executes this file.
Parameters:
stdin - the input stream used for this process's System.in
stdout - the output stream used for this process's System.out
stderr - the output stream used for this process's System.err
args - the arguments passes to this program
foreground - whether this method should block until execution completes
ownerID - the id of the user executing this file
processName - the name to associate with this process
Returns:
the process id
Throws:
java.io.IOException -  

setOtherPermissions

public void setOtherPermissions(int perms)
                         throws java.io.IOException
Sets the permissions for all users other than this file's owner. The 1st bit (Least Significant Bit) is used to represent the execute permission, the 2nd bit is the write permission, and the 3rd is the read permission. The following values can be used to set a file's permissions as shown.
    0 = ---
    1 = --x
    2 = -w-
    3 = -wx
    4 = r--
    5 = r-x
    6 = rw-
    7 = rwx
 
Parameters:
perms - the new permissions for this file.
Throws:
java.io.IOException -  

setUserPermissions

public void setUserPermissions(int perms)
                        throws java.io.IOException
Sets the permissions for this file's owner. The 1st bit (Least Significant Bit) is used to represent the execute permission, the 2nd bit is the write permission, and the 3rd is the read permission. The following values can be used to set a file's permissions as shown.
    0 = ---
    1 = --x
    2 = -w-
    3 = -wx
    4 = r--
    5 = r-x
    6 = rw-
    7 = rwx
 
Parameters:
perms - the new permissions for this file.
Throws:
java.io.IOException -  

getOtherPermissions

public int getOtherPermissions()
                        throws java.io.FileNotFoundException
Gets the permissions for all users other than this file's owner. The 1st bit (Least Significant Bit) is used to represent the execute permission, the 2nd bit is the write permission, and the 3rd is the read permission. The following values can be interpreted as shown.
    0 = ---
    1 = --x
    2 = -w-
    3 = -wx
    4 = r--
    5 = r-x
    6 = rw-
    7 = rwx
 
Parameters:
perms - the new permissions for this file.
Throws:
java.io.FileNotFoundException -  

getUserPermissions

public int getUserPermissions()
                       throws java.io.FileNotFoundException
Gets the permissions for this file's owner. The 1st bit (Least Significant Bit) is used to represent the execute permission, the 2nd bit is the write permission, and the 3rd is the read permission. The following values can be interpreted as shown.
    0 = ---
    1 = --x
    2 = -w-
    3 = -wx
    4 = r--
    5 = r-x
    6 = rw-
    7 = rwx
 
Parameters:
perms - the new permissions for this file.
Throws:
java.io.FileNotFoundException -  

canExec

public boolean canExec()
Determines if the current user has execute permissions for this file.
Returns:
the permission.

list

public java.lang.String[] list(boolean longls)
If this file represents a directory, this method returns a listing of that directory's contents. Setting the longls parameter to true will return a verbose listing that includes file permissions, modified date, file size, etc.
Parameters:
longls - true for verbose, false for java.io.File style.
Returns:
the file list