Information Technology Reference
In-Depth Information
// Copy the passed value (v) into the FAT entry for the passed cluster number (cls)
// in the buffer. The LSB is at the lower offset.
RAMwrite(dsk -> buffer, p, v);
RAMwrite(dsk -> buffer, p+1, (v >> 8));
// Write the edited buffer to both FAT copies
for ( i = 0, li = l; i < dsk -> fatcopy; i++, li += dsk -> fatsize)
if ( SectorWrite(l, dsk -> buffer) != sdcValid)
return FAIL;
if (c >= LAST_CLUSTER_FAT16)
// The entry is an EOC marker.
c = LAST_CLUSTER;
return c;
}
Finding a File's Next Cluster
The FILEget_next_cluster function can find the next cluster in a file. The
function accepts a FILEOBJ pointer to a FILE structure (fo) and a number
(n) that specifies how many clusters beyond the current cluster to look. The
function sets the FILE structure's ccls member to the requested cluster num-
ber. If n = 1, the function sets ccls to point to the cluster following the cur-
rent cluster value in the passed file structure.
#define CE_GOOD
0
// No error.
#define CE_BAD_SECTOR_READ
7
// Error in reading a sector.
#define CE_FAT_EOF
60 // Attempt to read beyond the FAT's EOF.
#define CE_INVALID_CLUSTER
9
// The cluster number > maxcls.
byte FILEget_next_cluster(FILEOBJ fo, word n)
{
word c;
word c2;
DISK *disk;
byte error = CE_GOOD;
Search WWH ::




Custom Search