Class DirectoryEntry
java.lang.Object
|
+----DirectoryEntry
- public class DirectoryEntry
- extends Object
A directory entry for a simulated file system.
- Author:
- Ray Ontko
-
d_ino
- i-node number for this DirectoryEntry
-
d_name
- file name for this DirectoryEntry
-
DIRECTORY_ENTRY_SIZE
- Size of a directory entry (on disk) in bytes.
-
MAX_FILENAME_LENGTH
- Maximum length of a file name.
-
DirectoryEntry()
- Constructs an empty DirectoryEntry.
-
DirectoryEntry(short, String)
- Constructs a DirectoryEntry for the given inode and name.
-
getIno()
- Gets the inode number for this DirectoryEntry
-
getName()
- Gets the name for this DirectoryEntry
-
main(String[])
- A test driver for this class.
-
read(byte[], int)
- Reads a DirectoryEntry from the spcified byte array at the specified
offset.
-
setIno(short)
- Sets the inode number for this DirectoryEntry
-
setName(String)
- Sets the name for this DirectoryEntry
-
toString()
- Converts a DirectoryEntry to a printable string.
-
write(byte[], int)
- Writes a DirectoryEntry to the specified byte array at the specified
offset.
MAX_FILENAME_LENGTH
public static final int MAX_FILENAME_LENGTH
- Maximum length of a file name.
DIRECTORY_ENTRY_SIZE
public static final int DIRECTORY_ENTRY_SIZE
- Size of a directory entry (on disk) in bytes.
d_ino
public short d_ino
- i-node number for this DirectoryEntry
d_name
public byte d_name[]
- file name for this DirectoryEntry
DirectoryEntry
public DirectoryEntry()
- Constructs an empty DirectoryEntry.
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
setIno
public void setIno(short newIno)
- Sets the inode number for this DirectoryEntry
- Parameters:
- newIno - the new inode number
getIno
public short getIno()
- Gets the inode number for this DirectoryEntry
- Returns:
- the inode number
setName
public void setName(String newName)
- Sets the name for this DirectoryEntry
- Parameters:
- newName - the new name
getName
public String getName()
- Gets the name for this DirectoryEntry
- Returns:
- the name
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
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
toString
public String toString()
- Converts a DirectoryEntry to a printable string.
- Returns:
- the printable string
- Overrides:
- toString in class Object
main
public static void main(String args[]) throws Exception
- A test driver for this class.
- Throws: Exception
- any exception which may occur.