#include <filehdr.h>
Public Methods | |
| bool | Allocate (BitMap *bitMap, int fileSize) |
| void | Deallocate (BitMap *bitMap) |
| void | FetchFrom (int sectorNumber) |
| void | WriteBack (int sectorNumber) |
| int | ByteToSector (int offset) |
| int | FileLength () |
| void | Print () |
Private Attributes | |
| int | numBytes |
| int | numSectors |
| int | dataSectors [NumDirect] |
|
||||||||||||
|
Definition at line 42 of file filehdr.cc. References dataSectors, divRoundUp, FALSE, BitMap::Find, numBytes, BitMap::NumClear, numSectors, SectorSize, and TRUE. Referenced by FileSystem::Create, and FileSystem::FileSystem.
00043 {
00044 numBytes = fileSize;
00045 numSectors = divRoundUp(fileSize, SectorSize);
00046 if (freeMap->NumClear() < numSectors)
00047 return FALSE; // not enough space
00048
00049 for (int i = 0; i < numSectors; i++)
00050 dataSectors[i] = freeMap->Find();
00051 return TRUE;
00052 }
|
|
|
Definition at line 107 of file filehdr.cc. References dataSectors, and SectorSize. Referenced by OpenFile::ReadAt, and OpenFile::WriteAt.
00108 {
00109 return(dataSectors[offset / SectorSize]);
00110 }
|
|
|
Definition at line 62 of file filehdr.cc. References ASSERT, BitMap::Clear, dataSectors, numSectors, and BitMap::Test. Referenced by FileSystem::Remove.
00063 {
00064 for (int i = 0; i < numSectors; i++) {
00065 ASSERT(freeMap->Test((int) dataSectors[i])); // ought to be marked!
00066 freeMap->Clear((int) dataSectors[i]);
00067 }
00068 }
|
|
|
Definition at line 78 of file filehdr.cc. Referenced by OpenFile::OpenFile, FileSystem::Print, Directory::Print, and FileSystem::Remove.
00079 {
00080 synchDisk->ReadSector(sector, (char *)this);
00081 }
|
|
|
Definition at line 118 of file filehdr.cc. References numBytes. Referenced by OpenFile::Length, OpenFile::ReadAt, and OpenFile::WriteAt.
00119 {
00120 return numBytes;
00121 }
|
|
|
Definition at line 130 of file filehdr.cc. References dataSectors, j, numBytes, numSectors, and SectorSize. Referenced by FileSystem::Print, and Directory::Print.
00131 {
00132 int i, j, k;
00133 char *data = new char[SectorSize];
00134
00135 printf("FileHeader contents. File size: %d. File blocks:\n", numBytes);
00136 for (i = 0; i < numSectors; i++)
00137 printf("%d ", dataSectors[i]);
00138 printf("\nFile contents:\n");
00139 for (i = k = 0; i < numSectors; i++) {
00140 synchDisk->ReadSector(dataSectors[i], data);
00141 for (j = 0; (j < SectorSize) && (k < numBytes); j++, k++) {
00142 if ('\040' <= data[j] && data[j] <= '\176') // isprint(data[j])
00143 printf("%c", data[j]);
00144 else
00145 printf("\\%x", (unsigned char)data[j]);
00146 }
00147 printf("\n");
00148 }
00149 delete [] data;
00150 }
|
|
|
Definition at line 91 of file filehdr.cc. Referenced by FileSystem::Create, and FileSystem::FileSystem.
00092 {
00093 synchDisk->WriteSector(sector, (char *)this);
00094 }
|
|
|
Definition at line 62 of file filehdr.h. Referenced by Allocate, ByteToSector, Deallocate, and Print. |
|
|
Definition at line 60 of file filehdr.h. Referenced by Allocate, FileLength, and Print. |
|
|
Definition at line 61 of file filehdr.h. Referenced by Allocate, Deallocate, and Print. |
1.2.14 written by Dimitri van Heesch,
© 1997-2002