Information Technology Reference
In-Depth Information
// If we've reached the end of a sector, write the data to the media and
// load another sector.
if (pos == SDC_SECTOR_SIZE)
{
if (sectorloaded)
{
// The DISK structure's buffer member contains data to be written.
// Copy the data to the storage media.
if (SectorWrite( l, dsk -> buffer) != sdcValid)
error = CE_WRITE_ERROR;
}
// Reset the offset within the sector.
pos = 0;
// Increment the sector number.
fo -> sec++;
// The sector number (sec) must be a value between 0 and SecPerClus - 1.
// If sec = SecPerClus, the sector is the first sector in a new cluster.
if (fo -> sec == dsk -> SecPerClus)
{
// Reset the sector number for the new cluster.
fo -> sec = 0;
if (fo -> Flags.FileWriteEOF)
// It's the end of the file. Allocate a new cluster for additional data.
error = FILEallocate_new_cluster(fo);
else
// Not the end of the file. Get the next cluster allocated to the file.
error = FILEget_next_cluster( fo, 1);
}
Search WWH ::




Custom Search