Information Technology Reference
In-Depth Information
Managing Files
To prepare to read or write to a file, a host must obtain information about
the file from the file's directory entry. A host might also need to create or
delete a file. The functions that follow show how to perform these opera-
tions.
Obtaining File Information
The Fill_File_Object function reads information from a file's directory entry
and stores the information in a FILE structure. The function accepts a
pointer to a FILE structure (fo) and a pointer to the number of the file's
entry in its directory (fHandle). The function returns a status code. The
FILEfind function later in this chapter shows how to find the number of a
file's directory entry.
The function calls the Cache_File_Entry function from Chapter 9.
Cache_File_Entry is called with ForceRead false, so in the FILE structure
passed to the function, the dsk -> buffer member must contain the sector
with the file's directory entry (unless it's the first entry in a sector), the
dirclus member must contain the number of the first cluster in the file's
directory, and the dirccls member must contain the dirclus value or another
directory-cluster number where the code should begin looking for the entry.
Defines
#define DIR_DEL
0xe5
// deleted entry
#define DIR_EMPTY
0
// last entry in a directory
#define FOUND
0
// directory entry match
#define NOT_FOUND
1
// directory entry not found
#define NO_MORE
2
// no more files found
Search WWH ::




Custom Search