Information Technology Reference
In-Depth Information
File Information
A FILE structure can store information about a file, including its location in
a volume and a location currently being accessed in the file. (Chapter 9 has
more about directories, and Chapter 10 has more about accessing files.)
// A short file name has 11 or fewer characters, not counting the dot.
#define FILE_NAME_SIZE 11
typedef struct
{
unsigned write :1; // Set if the file was opened for writing.
unsigned FileWriteEOF :1; // Set if writing and have reached the end of the file.
}FileFlags;
typedef struct
{
DISK
*dsk;
// a DISK structure for the volume containing the file
word
cluster;
// number of the first file's cluster
word
ccls;
// current cluster
word
sec;
// current sector in the current cluster
word
pos;
// current byte location in the current sector
dword
seek;
// current byte location in the file
dword
size;
// file size
FileFlags
Flags;
// write mode and end-of-file indicators
word
time;
// last update time
word
date;
// last update date
char
name[FILE_NAME_SIZE];
// file name
word
entry;
// position of the file's entry in its directory
word
chk;
// FILE structure checksum = ~( entry + name[0])
word
attributes;
// file's attributes
word
dirclus;
// first cluster of the file's directory
word
dirccls;
// current cluster of the file's directory
} FILE;
A FILEOBJ is a pointer to a FILE structure:
typedef FILE * FILEOBJ;
Functions in this chapter use these defines:
#define CLUSTER_FAIL 0xffff
#define LAST_CLUSTER 0xfff8
#define LAST_CLUSTER_FAT16 0xfff8
Search WWH ::




Custom Search