Information Technology Reference
In-Depth Information
// A sector can hold 16 directory entries.
// Shift right 4 times to get the number of the sector within the directory.
// 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);
// If it's not the root directory,
// divide the sector number obtained above by the number of sectors per cluster.
// The remainder (offset2) is the sector number within the cluster.
if (ccls != 0)
offset2 = offset2 % (dsk -> SecPerClus);
// Get the sector number of the passed directory cluster.
sector = Cluster2Sector(dsk, ccls);
// Write the data in dsk -> buffer to the entry's sector in the media.
if (SectorWrite(sector + offset2, dsk -> buffer) != sdcValid)
status = FALSE;
else
status = TRUE;
return(status);
}
Updating the Time and Date
The IncrementTimeStamp function accepts a DIRENTRY structure (dir)
and writes time and date information in the fields that hold the file's
last-modified time and date.
The function emulates a real-time clock for systems that don't have one. The
function increments the time in units of two seconds on each write. A sys-
tem with a real-time clock should of course obtain the current values from
the clock and store these in the DIRENTRY structure.
Search WWH ::




Custom Search