tac0S
Template Affectional Command Operating System
Public Member Functions | List of all members
Directory Class Reference

Public Member Functions

 Directory (int size)
 Directory::Directory Initialize a directory; initially, the directory is completely empty. If the disk is being formatted, an empty directory is all we need, but otherwise, we need to call FetchFrom in order to initialize it from disk. More...
 
 ~Directory ()
 Directory::~Directory De-allocate directory data structure.
 
void FetchFrom (OpenFile *file)
 Directory::FetchFrom Read the contents of the directory from disk. More...
 
void WriteBack (OpenFile *file)
 Directory::WriteBack Write any modifications to the directory back to disk. More...
 
int Find (const char *name)
 Directory::Find Look up file name in directory, and return the disk sector number where the file's header is stored. Return -1 if the name isn't in the directory. More...
 
bool Add (const char *name, int newSector)
 Directory::Add Add a file into the directory. Return TRUE if successful;. More...
 
bool Remove (const char *name)
 Directory::Remove Remove a file name from the directory. Return TRUE if successful;. More...
 
void List ()
 Directory::List List all the file names in the directory.
 
void Print ()
 Directory::Print List all the file names in the directory, their FileHeader locations, and the contents of each file. For debugging.
 
bool isEmpty ()
 Directory::isEmpty Check if the folder is empty.
 

Constructor & Destructor Documentation

Directory::Directory ( int  size)

Directory::Directory Initialize a directory; initially, the directory is completely empty. If the disk is being formatted, an empty directory is all we need, but otherwise, we need to call FetchFrom in order to initialize it from disk.

Parameters
sizeis the number of entries in the directory

Member Function Documentation

bool Directory::Add ( const char *  name,
int  newSector 
)

Directory::Add Add a file into the directory. Return TRUE if successful;.

Returns
return FALSE if the file name is already in the directory, or if the directory is completely full, and has no more space for additional file names.
Parameters
name– the name of the file being added
newSector– the disk sector containing the added file's header
void Directory::FetchFrom ( OpenFile file)

Directory::FetchFrom Read the contents of the directory from disk.

Parameters
file– file containing the directory contents
int Directory::Find ( const char *  name)

Directory::Find Look up file name in directory, and return the disk sector number where the file's header is stored. Return -1 if the name isn't in the directory.

Parameters
name– the file name to look up
bool Directory::Remove ( const char *  name)

Directory::Remove Remove a file name from the directory. Return TRUE if successful;.

Returns
FALSE if the file isn't in the directory.
Parameters
name– the file name to be removed
void Directory::WriteBack ( OpenFile file)

Directory::WriteBack Write any modifications to the directory back to disk.

Parameters
file– file to contain the new directory contents

The documentation for this class was generated from the following files: