Information Technology Reference
In-Depth Information
The function accepts a pointer to a file structure (fo), a pointer to the num-
ber of the file's entry in its directory (fHandle), and a character that specifies
whether to open the file for append (a), read (r), or write (w). In the passed
file structure, the dirclus member must contain the number of the first clus-
ter in the file's directory.
The function calls the SectorRead function from Chapter 5, the
Cluster2Sector function from Chapter 8, the Cache_File_Entry function
from Chapter 9, and the Fill_File_Object function from this chapter.
After calling the function, firmware can use the information in the FILE
structure to perform operations on the file's contents.
CETYPE FILEopen (FILEOBJ fo, word *fHandle, char type)
{
DISK
*dsk;
CETYPE
error = CE_GOOD;
dword
l;
byte
r;
// Save the FILE structure's dsk member.
dsk = (DISK *)(fo -> dsk);
if (dsk -> mount == FALSE)
error = CE_NOT_INIT; // The media isn't available.
else
{
// Get the file's directory entry and store the directory's sector
// in the dsk -> buffer member of the file structure (fo).
Cache_File_Entry(fo, fHandle, TRUE);
// Fill the file structure with information from the directory entry.
r = Fill_File_Object(fo, fHandle);
if (r != FOUND)
error = CE_FILE_NOT_FOUND;
Search WWH ::




Custom Search