Class HierarchicalFileSystem

java.lang.Object
  extended byHierarchicalFileSystem

public class HierarchicalFileSystem
extends java.lang.Object

A HierarchicalFileSystem represents a hierarchical file system in which files are referenced by UNIX style path names.


Field Summary
private  BaseFileSystem base
          base is the base file system wrapped by this hierarchical file system.
private  int root
          root is the file number of the root directory of this hierarchical file system.
 
Constructor Summary
HierarchicalFileSystem(BaseFileSystem bfs)
          new HierarchicalFileSystem(bfs) returns a new hierarchical file system wrapper for the base file system bfs.
 
Method Summary
private  void checkTestPath(java.lang.String pth)
          checkTestPath(pth) prints pth and its tail and last directory.
 void create(java.lang.String pth)
          fs.create(pth) creates a regular file with absolute path pth in fs.
 void createDir(java.lang.String pth)
          fs.createDir(pth) creates a new directory with absolute path pth in fs.
 void delete(java.lang.String pth)
          fs.delete(pth) removes the regular file with absolute path pth from fs.
 void deleteDir(java.lang.String pth)
          fs.deleteDir(pth) removes the directory with absolute path pth from fs.
 int getCapacity()
          fs.getCapacity() returns the maximum number of files for fs.
private  Directory getLastDir(java.lang.String pth)
          getLastDir(pth) returns the directory before the tail of pth or null if there is no such directory.
private  java.lang.String getTail(java.lang.String pth)
          getTail(pth) returns the name at the tail of pth.
private  void initForTest()
          initForTest() manually creates directories and files for testing purposes.
static void main(java.lang.String[] args)
          main(args) is a program for testing the private methods of the HierarchicalFileSystem class.
 File open(java.lang.String pth)
          fs.open(pth) returns a file access structure for the file with absolute path pth.
 File openDir(java.lang.String pth)
          fs.openDir(pth) returns a directory access structure for the directory with absolute path pth.
 java.lang.String toString()
          fs.toString() returns the class name and file system name of fs as a string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

base

private BaseFileSystem base
base is the base file system wrapped by this hierarchical file system.


root

private int root
root is the file number of the root directory of this hierarchical file system.

Constructor Detail

HierarchicalFileSystem

public HierarchicalFileSystem(BaseFileSystem bfs)
new HierarchicalFileSystem(bfs) returns a new hierarchical file system wrapper for the base file system bfs.

Method Detail

getTail

private java.lang.String getTail(java.lang.String pth)
getTail(pth) returns the name at the tail of pth. If pth ends with '/' then getTail returns an empty string.


getLastDir

private Directory getLastDir(java.lang.String pth)
getLastDir(pth) returns the directory before the tail of pth or null if there is no such directory. The last directory before the tail of "/" is the root directory.


initForTest

private void initForTest()
initForTest() manually creates directories and files for testing purposes. This method is only invoked from the main() method.


checkTestPath

private void checkTestPath(java.lang.String pth)
checkTestPath(pth) prints pth and its tail and last directory. This method is only invoked from the main() method.


create

public void create(java.lang.String pth)
fs.create(pth) creates a regular file with absolute path pth in fs.

An IllegalStateException is thrown

An IllegalArgumentException is thrown


createDir

public void createDir(java.lang.String pth)
fs.createDir(pth) creates a new directory with absolute path pth in fs.

An IllegalStateException is thrown

An IllegalArgumentException is thrown if any of the directories in pth except the last is missing.


delete

public void delete(java.lang.String pth)
fs.delete(pth) removes the regular file with absolute path pth from fs.

An IllegalArgumentException is thrown


deleteDir

public void deleteDir(java.lang.String pth)
fs.deleteDir(pth) removes the directory with absolute path pth from fs.

An IllegalArgumentException is thrown


open

public File open(java.lang.String pth)
fs.open(pth) returns a file access structure for the file with absolute path pth.

Null is returned


openDir

public File openDir(java.lang.String pth)
fs.openDir(pth) returns a directory access structure for the directory with absolute path pth.

Null is returned


getCapacity

public int getCapacity()
fs.getCapacity() returns the maximum number of files for fs.


toString

public java.lang.String toString()
fs.toString() returns the class name and file system name of fs as a string.


main

public static void main(java.lang.String[] args)
main(args) is a program for testing the private methods of the HierarchicalFileSystem class.