Information Technology Reference
In-Depth Information
// A system with a real-time clock would retrieve these values from the clock
// instead of using these fixed values.
dir -> DIR_CrtTimeTenth =0x64;
// creation time, hundredths of a second (1 sec.)
dir -> DIR_CrtTime =
0x43C5;
// creation time (8:30:10)
dir -> DIR_CrtDate =
0x34B0;
// creation date (5/16/2006)
dir -> DIR_LstAccDate =
0x34B0;
// last access date
dir -> DIR_FstClusHI =
0x0000;
// high word of this enty's first cluster number
dir -> DIR_WrtTime =
0x43C6;
// last modified time (8:30:12)
dir -> DIR_WrtDate =
0x34B0;
// last modified date
dir->DIR_FstClusLO =
0x0000;
// low word of this entry's first cluster number
dir->DIR_FileSize =
0x0;
// file size
// Save information in the file structure.
fo -> size =
dir -> DIR_FileSize;
fo -> time =
dir -> DIR_CrtTime;
fo -> date =
dir -> DIR_CrtDate;
fo -> attributes =
dir -> DIR_Attr;
fo -> entry =
*fHandle;
// Write the entry to the directory.
Write_File_Entry(fo,fHandle);
return(error);
}
Finding an Available Entry
To create a file, the host must find an available entry in the directory the file
will reside in. The FindEmpyEntries function performs this task. The func-
tion accepts a pointer to a FILE structure (fo) that contains the number of a
directory's first cluster and a pointer to a variable that will hold the number
of the found entry within the directory (fHandle). To start at the beginning
of the directory, fHandle should equal zero. In the passed file structure, the
dirclus member must contain the number of the first cluster in the directory
to search. The function returns a status code. The function calls the
Cache_File_Entry function from Chapter 9 and the
FILEAllocate_New_Cluster function above. (The FILEfind function in this
chapter can also find an available directory entry.)
Search WWH ::




Custom Search