Class Directory

java.lang.Object
  extended byFile
      extended byDirectory

public class Directory
extends File

A Directory represents an operating system structure that is used to access the contents of a directory.


Field Summary
private  java.util.Map entries
          entries is the table of directory entries for this directory.
static char SEPARATOR
          Directory.SEPARATOR is the direcory separator character in file paths.
 
Fields inherited from class File
NULL
 
Constructor Summary
Directory()
          new Directory() returns a new empty directory.
 
Method Summary
 java.util.Iterator entries()
          d.entries() returns an iterator for the directory entries in d, excluding the entries for "." and "..".
 int getFileNumber(java.lang.String nm)
          d.getFileNumber(nm) returns the file number in d whose simple name is nm, or File.NULL if there is no such file.
 boolean isDirectory()
          d.isDirectory() returns true if f is a directory.
static boolean isSimpleName(java.lang.String nm)
          Directory.isSimpleName(nm) returns true if nm is a valid simple file name.
 int link(java.lang.String nm, int fn)
          d.link(nm, fn) links fn into d with simple name nm and returns the file number that was previously linked with name nm.
static void main(java.lang.String[] args)
          main(args) is a program to test the Directory class.
 int size()
          d.size() returns the number of directory entries in d, excluding the entries for "." and "..".
 int unlink(java.lang.String nm)
          d.unlink(nm) unlinks the file whose simple name is nm from d and returns the file.
 
Methods inherited from class File
fileNumber, getFileNumber, setFileNumber, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SEPARATOR

public static final char SEPARATOR
Directory.SEPARATOR is the direcory separator character in file paths.

See Also:
Constant Field Values

entries

private java.util.Map entries
entries is the table of directory entries for this directory.

Constructor Detail

Directory

public Directory()
new Directory() returns a new empty directory.

Method Detail

isDirectory

public boolean isDirectory()
d.isDirectory() returns true if f is a directory.

Overrides:
isDirectory in class File

link

public int link(java.lang.String nm,
                int fn)
d.link(nm, fn) links fn into d with simple name nm and returns the file number that was previously linked with name nm. If there was no file number linked with name nm then File.NULL is returned.


getFileNumber

public int getFileNumber(java.lang.String nm)
d.getFileNumber(nm) returns the file number in d whose simple name is nm, or File.NULL if there is no such file.


unlink

public int unlink(java.lang.String nm)
d.unlink(nm) unlinks the file whose simple name is nm from d and returns the file. If there is no such file then no action is taken and File.NULL is returned.


entries

public java.util.Iterator entries()
d.entries() returns an iterator for the directory entries in d, excluding the entries for "." and "..". These entries have type Map.Entry (java.util package). The entry keys are file names of type String. The entry values are file numbers of type Integer. File numbers can be converted to int using File.fileNumber().


size

public int size()
d.size() returns the number of directory entries in d, excluding the entries for "." and "..".


isSimpleName

public static boolean isSimpleName(java.lang.String nm)
Directory.isSimpleName(nm) returns true if nm is a valid simple file name. nm is a valid simple name if it contains no path separator characters.


main

public static void main(java.lang.String[] args)
main(args) is a program to test the Directory class.