Class DirectoryEntry

java.lang.Object
   |
   +----DirectoryEntry

public class DirectoryEntry
extends Object
A directory entry for a simulated file system.

Author:
Ray Ontko

Variable Index

 o d_ino
i-node number for this DirectoryEntry
 o d_name
file name for this DirectoryEntry
 o DIRECTORY_ENTRY_SIZE
Size of a directory entry (on disk) in bytes.
 o MAX_FILENAME_LENGTH
Maximum length of a file name.

Constructor Index

 o DirectoryEntry()
Constructs an empty DirectoryEntry.
 o DirectoryEntry(short, String)
Constructs a DirectoryEntry for the given inode and name.

Method Index

 o getIno()
Gets the inode number for this DirectoryEntry
 o getName()
Gets the name for this DirectoryEntry
 o main(String[])
A test driver for this class.
 o read(byte[], int)
Reads a DirectoryEntry from the spcified byte array at the specified offset.
 o setIno(short)
Sets the inode number for this DirectoryEntry
 o setName(String)
Sets the name for this DirectoryEntry
 o toString()
Converts a DirectoryEntry to a printable string.
 o write(byte[], int)
Writes a DirectoryEntry to the specified byte array at the specified offset.

Variables

 o MAX_FILENAME_LENGTH
 public static final int MAX_FILENAME_LENGTH
Maximum length of a file name.

 o DIRECTORY_ENTRY_SIZE
 public static final int DIRECTORY_ENTRY_SIZE
Size of a directory entry (on disk) in bytes.

 o d_ino
 public short d_ino
i-node number for this DirectoryEntry

 o d_name
 public byte d_name[]
file name for this DirectoryEntry

Constructors

 o DirectoryEntry
 public DirectoryEntry()
Constructs an empty DirectoryEntry.

 o DirectoryEntry
 public DirectoryEntry(short ino,
                       String name)
Constructs a DirectoryEntry for the given inode and name. Note that the name is stored internally as a byte[], not as a string.

Parameters:
ino - the inode number for this DirectoryEntry
name - the file name for this DirectoryEntry

Methods

 o setIno
 public void setIno(short newIno)
Sets the inode number for this DirectoryEntry

Parameters:
newIno - the new inode number
 o getIno
 public short getIno()
Gets the inode number for this DirectoryEntry

Returns:
the inode number
 o setName
 public void setName(String newName)
Sets the name for this DirectoryEntry

Parameters:
newName - the new name
 o getName
 public String getName()
Gets the name for this DirectoryEntry

Returns:
the name
 o write
 public void write(byte buffer[],
                   int offset)
Writes a DirectoryEntry to the specified byte array at the specified offset.

Parameters:
buffer - the byte array to which the directory entry should be written
offset - the offset from the beginning of the buffer to which the directory entry should be written
 o read
 public void read(byte buffer[],
                  int offset)
Reads a DirectoryEntry from the spcified byte array at the specified offset.

Parameters:
buffer - the byte array from which the directory entry should be read
offset - the offset from the beginning of the buffer from which the directory entry should be read
 o toString
 public String toString()
Converts a DirectoryEntry to a printable string.

Returns:
the printable string
Overrides:
toString in class Object
 o main
 public static void main(String args[]) throws Exception
A test driver for this class.

Throws: Exception
any exception which may occur.