Information Technology Reference
In-Depth Information
Creating a Directory Entry
After finding an empty entry, a host can store information about a new file
or subdirectory. The PopulateEntries function accepts pointers to a FILE
structure (fo), a file name (name), and the number of the file's entry in its
directory (fHandle). The function stores the file name and other informa-
tion in the entry and returns a status code.
The function calls the Cache_File_Entry and Write_File_Entry functions
from Chapter 9. In the passed file structure, the dirclus member must con-
tain the number of the first cluster in the entry's directory.
#define ATTR_ARCHIVE 0x20
#define DIR_NAMECOMP (DIR_NAMESIZE + DIR_EXTENSION) // 11
byte PopulateEntries(FILEOBJ fo, char *name , word *fHandle)
{
byte csum;
DIRENTRY dir;
byte
error = CE_GOOD;
byte
index;
byte
nameptr;
byte
temp;
// Get the file's directory entry.
// The FILE structure's dirclus member is the first cluster
// of the directory containing the entry to read.
dir = Cache_File_Entry( fo, fHandle, TRUE);
// Copy information into the entry.
strncpy(dir -> DIR_Name, name, DIR_NAMECOMP);
dir -> DIR_Attr = ATTR_ARCHIVE;
dir -> DIR_NTRes = 0x00;
Search WWH ::




Custom Search