#include <directory.h>
Public Methods | |
| Directory (int size) | |
| ~Directory () | |
| void | FetchFrom (OpenFile *file) |
| void | WriteBack (OpenFile *file) |
| int | Find (char *name) |
| bool | Add (char *name, int newSector) |
| bool | Remove (char *name) |
| void | List () |
| void | Print () |
Private Methods | |
| int | FindIndex (char *name) |
Private Attributes | |
| int | tableSize |
| DirectoryEntry * | table |
|
|
Definition at line 38 of file directory.cc. References FALSE, DirectoryEntry::inUse, table, and tableSize.
|
|
|
Definition at line 51 of file directory.cc. References table.
00052 {
00053 delete [] table;
00054 }
|
|
||||||||||||
|
Definition at line 130 of file directory.cc. References FALSE, FileNameMaxLen, FindIndex, DirectoryEntry::inUse, DirectoryEntry::sector, table, tableSize, and TRUE. Referenced by FileSystem::Create.
00131 {
00132 if (FindIndex(name) != -1)
00133 return FALSE;
00134
00135 for (int i = 0; i < tableSize; i++)
00136 if (!table[i].inUse) {
00137 table[i].inUse = TRUE;
00138 strncpy(table[i].name, name, FileNameMaxLen);
00139 table[i].sector = newSector;
00140 return TRUE;
00141 }
00142 return FALSE; // no space. Fix when we have extensible files.
00143 }
|
|
|
Definition at line 64 of file directory.cc. References OpenFile::ReadAt, table, and tableSize. Referenced by FileSystem::Create, FileSystem::List, FileSystem::Open, FileSystem::Print, and FileSystem::Remove.
00065 {
00066 (void) file->ReadAt((char *)table, tableSize * sizeof(DirectoryEntry), 0);
00067 }
|
|
|
Definition at line 109 of file directory.cc. References FindIndex, DirectoryEntry::sector, and table. Referenced by FileSystem::Create, FileSystem::Open, and FileSystem::Remove.
|
|
|
Definition at line 91 of file directory.cc. References FileNameMaxLen, DirectoryEntry::inUse, table, and tableSize. Referenced by Add, Find, and Remove.
00092 {
00093 for (int i = 0; i < tableSize; i++)
00094 if (table[i].inUse && !strncmp(table[i].name, name, FileNameMaxLen))
00095 return i;
00096 return -1; // name not in directory
00097 }
|
|
|
Definition at line 170 of file directory.cc. References DirectoryEntry::inUse, table, and tableSize. Referenced by FileSystem::List.
|
|
|
Definition at line 184 of file directory.cc. References FileHeader::FetchFrom, DirectoryEntry::inUse, FileHeader::Print, table, and tableSize. Referenced by FileSystem::FileSystem, and FileSystem::Print.
00185 {
00186 FileHeader *hdr = new FileHeader;
00187
00188 printf("Directory contents:\n");
00189 for (int i = 0; i < tableSize; i++)
00190 if (table[i].inUse) {
00191 printf("Name: %s, Sector: %d\n", table[i].name, table[i].sector);
00192 hdr->FetchFrom(table[i].sector);
00193 hdr->Print();
00194 }
00195 printf("\n");
00196 delete hdr;
00197 }
|
|
|
Definition at line 154 of file directory.cc. References FALSE, FindIndex, DirectoryEntry::inUse, table, and TRUE. Referenced by FileSystem::Remove.
|
|
|
Definition at line 77 of file directory.cc. References table, tableSize, and OpenFile::WriteAt. Referenced by FileSystem::Create, FileSystem::FileSystem, and FileSystem::Remove.
00078 {
00079 (void) file->WriteAt((char *)table, tableSize * sizeof(DirectoryEntry), 0);
00080 }
|
|
|
Definition at line 76 of file directory.h. Referenced by Add, Directory, FetchFrom, Find, FindIndex, List, Print, Remove, WriteBack, and ~Directory. |
|
|
Definition at line 75 of file directory.h. Referenced by Add, Directory, FetchFrom, FindIndex, List, Print, and WriteBack. |
1.2.14 written by Dimitri van Heesch,
© 1997-2002