Information Technology Reference
In-Depth Information
else
error = CE_WRITE_ERROR;
return(error);
}
Closing a File
When finished writing to a file, firmware must update the file's directory
entry. The fclose function handles this task. The function accepts a FILE-
OBJ pointer to a FILE structure for the file and returns a status code.
The function calls the LoadDirAttrib, IncrementTimeStamp, and
Write_File_Entry functions from Chapter 9.
CETYPE fclose(FILEOBJ fo)
{
CETYPE error = CE_GOOD;
DIRENTRY dir;
word
fHandle;
// Set fHandle to the number of the file's entry in its directory.
fHandle = fo -> entry;
// Nothing to do if the file wasn't opened for writing.
if (fo -> Flags.write)
{
// Get the file's attributes.
dir = LoadDirAttrib(fo, &fHandle);
// Update the time and date.
IncrementTimeStamp(dir);
// Set the DIRENTRY structure's DIR_FileSize member to the file's size.
dir -> DIR_FileSize = fo -> size;
Search WWH ::




Custom Search