[ RCOS.java Home | RCOS Home | David's Home ]
Name: |
Directory |
Comment: |
The following class defines a UNIX-like "directory". Each entry in
the directory describes a file, and where to find it on disk.
The directory data structure can be stored in memory, or on disk. When it is on disk, it is stored as a regular Nachos file. The constructor initializes a directory structure in memory; the FetchFrom/WriteBack operations shuffle the directory information from/to disk. |
Collaborators: |
class Directory { public: Directory(int size); // Initialize an empty directory // with space for "size" files ~Directory(); // De-allocate the directory void FetchFrom(OpenFile *file); // Init directory contents from disk void WriteBack(OpenFile *file); // Write modifications to // directory contents back to disk int Find(char *name); // Find the sector number of the // FileHeader for file: "name" bool Add(char *name, int newSector); // Add a file name into the directory bool Remove(char *name); // Remove a file from the directory void List(); // Print the names of all the files // in the directory void Print(); // Verbose print of the contents // of the directory -- all the file // names and their contents. private: int tableSize; // Number of directory entries DirectoryEntry *table; // Table of pairs: //int FindIndex(char *name); // Find the index into the directory // table corresponding to "name" };