Information Technology Reference
In-Depth Information
3. To read more data, get the next cluster number from the current cluster's
FAT entry, convert the cluster number to an LBA sector number, and read
the data in the cluster's sector(s).
4. Repeat step 3 as needed until a FAT entry indicates that the entry's cluster
is the last cluster in the file.
Performing a Read Operation
The fread function reads data from a file into a buffer. The function accepts
a FILEOBJ pointer to a FILE structure (fo), a pointer to a buffer to store the
data to be read (dest), and the number of bytes to read (count). The func-
tion returns a status code. In the FILE structure, pos is the offset to begin
reading from within the sector, seek is the offset to begin reading from
within the file, ccls is the number of the cluster to read from, and sec is the
number of the sector to read within the cluster. The function returns a status
code.
The RAMread macro reads a byte at an address (a) plus an offset (f ) in
RAM:
#define RAMread(a, f) *(a + f)
The fread function calls the SectorRead function from Chapter 5 and the
Cluster2Sector and FILEget_next_cluster functions from Chapter 8.
CETYPE fread (FILEOBJ fo, void *dest, word count)
{
DISK
*dsk;
CETYPE
error = CE_GOOD;
dword
l;
word
pos;
dword
seek;
dword
size;
dword
temp;
dsk = (DISK *)fo -> dsk;
temp = count;
Search WWH ::




Custom Search