Information Technology Reference
In-Depth Information
structure (fo), a pointer to a buffer containing the data to write (src), and
the number of bytes to write (count). In the FILE structure, pos is the offset
to begin writing to within the sector, seek is the offset to begin writing to
within the file, ccls is the number of the cluster to write to, and sec is the
number of the sector to write to within the cluster. The function returns a
status code.
The function calls the IsWriteProtected, SectorRead, and SectorWrite func-
tions from Chapter 5, the FILEget_next_cluster and Cluster2Sector func-
tions and RAMWrite macro from Chapter 8, and the
FILEallocate_new_cluster function from this chapter. To enable writing to
the file, Flags.write must be true. The File_Open function in this chapter
sets this value.
CETYPE fwrite( FILEOBJ fo, void * src, word count)
{
DISK *
dsk;
CETYPE
error = CE_GOOD;
dword
l;
word
pos;
byte
sectorloaded = FALSE;
dword
seek;
dword
size;
word
tempo;
// To enable writing, Flags.write must be true and IsWriteProtected must return false.
if (fo->Flags.write)
{
if (!IsWriteProtected())
{
// It's OK to write to the media.
tempo = count;
// Save the file structure's dsk structure, the offset within the current sector,
// and the absolute offset in the file.
dsk = fo -> dsk;
pos = fo -> pos;
seek = fo -> seek;
Search WWH ::




Custom Search