Information Technology Reference
In-Depth Information
This function is the most complicated one in this topic. Examine the com-
ments carefully to understand it.
// A 512-byte sector can hold sixteen 32-byte directory entries.
#define DIRENTRIES_PER_SECTOR 0x10
DIRENTRY Cache_File_Entry( FILEOBJ fo, word * curEntry, byte ForceRead)
{
word ccls;
word cluster;
DIRENTRY dir;
DISK
*dsk;
byte
numofclus;
byte
offset2;
dword
sector;
// Save the file structure's DISK member.
dsk = fo -> dsk;
// Save the number of the first cluster of the file's directory.
cluster = fo -> dirclus;
// Save the number of the directory cluster to begin looking for the file in.
// This value is unused if ForceRead is true.
ccls = fo -> dirccls;
// Get the number of the entry's sector within the directory.
// A sector can hold 16 directory entries. Shift right 4 times to get the entry number.
// For example, if curEntry < 10h, it's the directory's first sector and offset2 = 0.
// If curEntry >= 10h and < 20h, it's the directory's second sector and offset2 = 1.
offset2 = (*curEntry >> 4);
offset2 = offset2; // emulator issue
if (cluster != 0)
// It's not the root directory.
// To get the number of the entry's sector within its cluster,
// divide the sector number obtained above by the number of sectors per cluster.
// The remainder (offset2) is the sector's number within its cluster.
Search WWH ::




Custom Search