oscript.fs
Class AbstractFileSystem.BogusFile

java.lang.Object
  extended byoscript.fs.AbstractFileSystem.BogusFile
All Implemented Interfaces:
AbstractFile
Direct Known Subclasses:
AbstractFileSystem.MountPointFile
Enclosing class:
AbstractFileSystem

protected static class AbstractFileSystem.BogusFile
extends java.lang.Object
implements AbstractFile

A non-existant file which is created to simulate non-existant directories that are in a path to a mount point, or files which simply don't exist.


Method Summary
 boolean canRead()
          Is it possible to read from this file.
 boolean canWrite()
          Is it possible to write to this file.
 boolean createNewFile()
          Create a new empty file, if it does not yet exist.
 boolean delete()
          Delete this file.
 boolean equals(java.lang.Object obj)
           
 boolean exists()
          Tests whether this file exists.
 java.lang.String getExtension()
          Get the extension, which indicates the type of file.
 java.io.InputStream getInputStream()
          Get an input stream to read from this file.
 java.lang.String getName()
          Get the name of this file, which is the last component of the complete path.
 java.io.OutputStream getOutputStream(boolean append)
          Get an output stream to write to this file.
 java.lang.String getPath()
          Get the file path, which globally identifies the file.
 int hashCode()
           
 boolean isDirectory()
          Test whether this file is a directory.
 boolean isFile()
          Test whether this file is a regular file.
 long lastModified()
          Return the time of last modification.
 long length()
          Return the length of the file in bytes.
 boolean mkdir()
          If this file does not exist, create it as a directory.
 boolean mkdirs()
          If this file does not exist, create it as a directory.
 java.lang.String toString()
           
 void touch()
          Update the timestamp on this file to the current time.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

equals

public boolean equals(java.lang.Object obj)

hashCode

public int hashCode()

getInputStream

public java.io.InputStream getInputStream()
                                   throws java.io.IOException
Description copied from interface: AbstractFile
Get an input stream to read from this file.

Specified by:
getInputStream in interface AbstractFile
Returns:
input stream
Throws:
java.io.IOException
See Also:
AbstractFile.canRead()

getOutputStream

public java.io.OutputStream getOutputStream(boolean append)
                                     throws java.io.IOException
Description copied from interface: AbstractFile
Get an output stream to write to this file.

Specified by:
getOutputStream in interface AbstractFile
Returns:
output stream
Throws:
java.io.IOException
See Also:
AbstractFile.canWrite()

getPath

public java.lang.String getPath()
Description copied from interface: AbstractFile
Get the file path, which globally identifies the file.

Specified by:
getPath in interface AbstractFile
Returns:
a unique string
See Also:
AbstractFile.getName()

getName

public java.lang.String getName()
Description copied from interface: AbstractFile
Get the name of this file, which is the last component of the complete path.

Specified by:
getName in interface AbstractFile
Returns:
the file name
See Also:
AbstractFile.getPath()

lastModified

public long lastModified()
Description copied from interface: AbstractFile
Return the time of last modification. The meaning of these value is not so important, but the implementation must ensure that a higher value is returned for the more recent version of a given element. Ie. if at some point this returns X, an AbstractFile representing the same "file", but created at a later time, should return X if the file has not been modified, or >X if the file has been modified.

Specified by:
lastModified in interface AbstractFile
Returns:
larger value indicates more recent modification

length

public long length()
Description copied from interface: AbstractFile
Return the length of the file in bytes.

Specified by:
length in interface AbstractFile

canRead

public boolean canRead()
Description copied from interface: AbstractFile
Is it possible to read from this file.

Specified by:
canRead in interface AbstractFile

canWrite

public boolean canWrite()
Description copied from interface: AbstractFile
Is it possible to write to this file.

Specified by:
canWrite in interface AbstractFile

exists

public boolean exists()
Description copied from interface: AbstractFile
Tests whether this file exists.

Specified by:
exists in interface AbstractFile
Returns:
true iff the file exists

isDirectory

public boolean isDirectory()
Description copied from interface: AbstractFile
Test whether this file is a directory.

Specified by:
isDirectory in interface AbstractFile
Returns:
true iff this file is a directory

isFile

public boolean isFile()
Description copied from interface: AbstractFile
Test whether this file is a regular file. A file is a regular file if it is not a directory.

Specified by:
isFile in interface AbstractFile
Returns:
true iff this file is a regular file.

createNewFile

public boolean createNewFile()
                      throws java.io.IOException
Description copied from interface: AbstractFile
Create a new empty file, if it does not yet exist.

Specified by:
createNewFile in interface AbstractFile
Returns:
true iff the file does not exist and was successfully created.
Throws:
java.io.IOException

touch

public void touch()
Description copied from interface: AbstractFile
Update the timestamp on this file to the current time.

Specified by:
touch in interface AbstractFile

delete

public boolean delete()
               throws java.io.IOException
Description copied from interface: AbstractFile
Delete this file. If this file is a directory, then the directory must be empty.

Specified by:
delete in interface AbstractFile
Returns:
true iff the directory is successfully deleted.
Throws:
java.io.IOException

mkdir

public boolean mkdir()
              throws java.io.IOException
Description copied from interface: AbstractFile
If this file does not exist, create it as a directory.

Specified by:
mkdir in interface AbstractFile
Returns:
true iff directory successfully created
Throws:
java.io.IOException

mkdirs

public boolean mkdirs()
               throws java.io.IOException
Description copied from interface: AbstractFile
If this file does not exist, create it as a directory. All necessary parent directories are also created. If this operation fails, it may have successfully created some or all of the parent directories.

Specified by:
mkdirs in interface AbstractFile
Returns:
true iff directory successfully created
Throws:
java.io.IOException

getExtension

public java.lang.String getExtension()
Description copied from interface: AbstractFile
Get the extension, which indicates the type of file. Usually the extension is part of the filename, ie. if the extension was os, the filename would end with .os.

Specified by:
getExtension in interface AbstractFile
Returns:
a string indicating the type of file

toString

public java.lang.String toString()