Information Technology Reference
In-Depth Information
Allocating a File's First Cluster
The CreateFirstCluster function stores a cluster number in a file's directory
entry. The function accepts a pointer to a FILE structure (fo) and returns a
status code. The function calls the LoadDirAttrib and Write_File_Entry
functions from Chapter 9 and the FILECreateHeadCluster function above.
CETYPE CreateFirstCluster(FILEOBJ fo)
{
word cluster;
DIRENTRY dir;
CETYPE
error;
word
fHandle;
// Save the number of the file's entry in the directory.
fHandle = fo -> entry;
// Allocate a cluster for the file.
if ((error = FILECreateHeadCluster(fo, &cluster)) == CE_GOOD)
{
// Get the file's directory entry.
dir = LoadDirAttrib(fo, &fHandle);
// Store the file's cluster number in the directory entry.
dir -> DIR_FstClusLO = cluster;
// Write the entry to the directory.
if (Write_File_Entry(fo, &fHandle) != TRUE)
error = CE_WRITE_ERROR;
}
return(error);
}
Allocating Additional Clusters
If a write operation needs additional storage beyond the clusters allocated to
a file, the host must find a new available cluster and allocate it to the file.
Another situation where the host needs to allocate an additional cluster is
Search WWH ::




Custom Search