http://elm-chan.org/fsw/ff/en/sfile.html
The FIL structure
(file object) holds the state of an open file. It is created by f_open() function
and discarded byf_close() function.
Application program must not modify any member in this structure except for cltbl.
Note that a sector buffer is defined in this structure at non-tiny configuration (_FS_TINY == 0),
so that the FIL structures at that configuration
should not be defined as auto variable.
FIL(file object 文件对象)掌控一个已打开的文件。由f_open()创建,由f_close()抛弃。应用程序除了可以修改结构里的cltbl,结构里的其他成员必须不能修改。注意,在此结构中一扇区的缓冲已被定义(_FS_TINY
== 0下),所以在这种设置下FIL结构不能被定义为auto variable(ysmz4:这是什么东西?..)
好抽象..测一下:
typedef struct _FIL {
FATFS*fs;/*
Pointer to the owner file system object */
WORDid;/*
Owner file system mount ID */ /* 所在的fs挂载编号*/
BYTEflag;/*
File status flags */
BYTEcsect;/*
Sector address in the cluster */
DWORDfptr;/*
File R/W pointer */
DWORDfsize;/*
File size */
DWORDorg_clust;/*
File start cluster */
DWORDcurr_clust;/*
Current cluster */
DWORDdsect;/*
Current data sector */
#if !_FS_READONLY
DWORDdir_sect;/*
Sector containing the directory entry *//* 包含目录项的扇区 */
BYTE*dir_ptr;/*
Ponter to the directory entry in the window */
#endif
#if !_FS_TINY
BYTEbuf[_MAX_SS];/*
File R/W buffer */
#endif
} FIL;
fs 主文件系统对象
id owner file system mount ID 主文件系统挂载ID,为什么是1???
flag 文件对象状态
csect 簇内的扇区地址
fptr 文件读/写指针
fsize 文件大小
org_clust 文件起始簇
curr_clust 当前簇
dsect 当前数据扇区
dir_sect 包含目录项的扇区
dir_ptr 窗口里的目录项指针