OpenEdv-开源电子网

 找回密码
 立即注册
正点原子全套STM32/Linux/FPGA开发资料,上千讲STM32视频教程免费下载...
查看: 3865|回复: 4

新版文件系统Fatfs0.14A里的FIL没有了DWORD fsize变量怎办?

[复制链接]

10

主题

60

帖子

0

精华

高级会员

Rank: 4

积分
676
金钱
676
注册时间
2018-8-9
在线时间
158 小时
发表于 2021-3-6 15:34:01 | 显示全部楼层 |阅读模式
1金钱
看了很多教程升级字库会在显示屏弄一条进度条,但是这个进度条的计算用到了FIL结构体里的DWORD fsize变量,今天想改个新版文件系统Fatfs0.14A用用,发现里面的FIL没有了DWORD fsize变量,那怎办呢?请大家指导,谢谢!

/* File object structure (FIL) */

typedef struct {
        FFOBJID        obj;                        /* Object identifier (must be the 1st member to detect invalid object pointer) */
        BYTE        flag;                        /* File status flags */
        BYTE        err;                        /* Abort flag (error code) */
        FSIZE_t        fptr;                        /* File read/write pointer (Zeroed on file open) */
        DWORD        clust;                        /* Current cluster of fpter (invalid when fptr is 0) */
        LBA_t        sect;                        /* Sector number appearing in buf[] (0:invalid) */
#if !FF_FS_READONLY
        LBA_t        dir_sect;                /* Sector number containing the directory entry (not used at exFAT) */
        BYTE*        dir_ptr;                /* Pointer to the directory entry in the win[] (not used at exFAT) */
#endif
#if FF_USE_FASTSEEK
        DWORD*        cltbl;                        /* Pointer to the cluster link map table (nulled on open, set by application) */
#endif
#if !FF_FS_TINY
        BYTE        buf[FF_MAX_SS];        /* File private data read/write window */
#endif
} FIL;



下面是旧版的文件系统FIL结构体
/* File object structure (FIL) */

typedef struct {
        FATFS*        fs;                                /* Pointer to the related file system object (**do not change order**) */
        WORD        id;                                /* Owner file system mount ID (**do not change order**) */
        BYTE        flag;                        /* Status flags */
        BYTE        err;                        /* Abort flag (error code) */
        DWORD        fptr;                        /* File read/write pointer (Zeroed on file open) */
        DWORD        fsize;                        /* File size */
        DWORD        sclust;                        /* File start cluster (0:no cluster chain, always 0 when fsize is 0) */
        DWORD        clust;                        /* Current cluster of fpter (not valid when fprt is 0) */
        DWORD        dsect;                        /* Sector number appearing in buf[] (0:invalid) */
#if !_FS_READONLY
        DWORD        dir_sect;                /* Sector number containing the directory entry */
        BYTE*        dir_ptr;                /* Pointer to the directory entry in the win[] */
#endif
#if _USE_FASTSEEK
        DWORD*        cltbl;                        /* Pointer to the cluster link map table (Nulled on file open) */
#endif
#if _FS_LOCK
        UINT        lockid;                        /* File lock ID origin from 1 (index of file semaphore table Files[]) */
#endif
#if !_FS_TINY
        BYTE        buf[_MAX_SS];        /* File private data read/write window */
#endif
} FIL;

最佳答案

查看完整内容[请看2#楼]

/* Object ID and allocation information (FFOBJID) */ typedef struct { FATFS* fs; /* Pointer to the hosting volume of this object */ WORD id; /* Hosting volume mount ID */ BYTE attr; /* Object attribute */ BYTE stat; /* Object chain status (b1-0: =0:not contiguous, =2:contiguous, =3:fragmented in this session, b2:sub-directory stretched) */ DWORD sclust; /* Object data star ...
正点原子逻辑分析仪DL16劲爆上市
回复

使用道具 举报

120

主题

7878

帖子

13

精华

资深版主

Rank: 8Rank: 8

积分
12012
金钱
12012
注册时间
2013-9-10
在线时间
427 小时
发表于 2021-3-6 15:34:02 | 显示全部楼层
/* Object ID and allocation information (FFOBJID) */

typedef struct {
        FATFS*        fs;                                /* Pointer to the hosting volume of this object */
        WORD        id;                                /* Hosting volume mount ID */
        BYTE        attr;                        /* Object attribute */
        BYTE        stat;                        /* Object chain status (b1-0: =0:not contiguous, =2:contiguous, =3:fragmented in this session, b2:sub-directory stretched) */
        DWORD        sclust;                        /* Object data start cluster (0:no cluster or root directory) */
        FSIZE_t        objsize;                /* Object size (valid when sclust != 0) */
#if FF_FS_EXFAT
        DWORD        n_cont;                        /* Size of first fragment - 1 (valid when stat == 3) */
        DWORD        n_frag;                        /* Size of last fragment needs to be written to FAT (valid when not zero) */
        DWORD        c_scl;                        /* Containing directory start cluster (valid when sclust != 0) */
        DWORD        c_size;                        /* b31-b8:Size of containing directory, b7-b0: Chain status (valid when c_scl != 0) */
        DWORD        c_ofs;                        /* Offset in the containing directory (valid when file object and sclust != 0) */
#endif
#if FF_FS_LOCK
        UINT        lockid;                        /* File lock ID origin from 1 (index of file semaphore table Files[]) */
#endif
} FFOBJID;

看这个结构体,有这么一个变量
FSIZE_t        objsize;                /* Object size (valid when sclust != 0) */
看到没,这个就可以得到文件大小
现在,程序把烂铜烂铁变得智能化了,人呢,一旦离开了这烂铜烂铁就不知道干啥了
回复

使用道具 举报

10

主题

60

帖子

0

精华

高级会员

Rank: 4

积分
676
金钱
676
注册时间
2018-8-9
在线时间
158 小时
 楼主| 发表于 2021-3-6 21:27:39 | 显示全部楼层
问题已经解决,新版本的FFOBJID类型obj里面还有个变量objsize,只是改头换面了一下,能使用了
回复

使用道具 举报

10

主题

60

帖子

0

精华

高级会员

Rank: 4

积分
676
金钱
676
注册时间
2018-8-9
在线时间
158 小时
 楼主| 发表于 2021-3-6 21:29:46 | 显示全部楼层
已经解决了,新版的FFOBJID类型里面有一个objsize变量,只是改头换面了一下
回复

使用道具 举报

51

主题

2166

帖子

2

精华

论坛元老

Rank: 8Rank: 8

积分
10653
金钱
10653
注册时间
2017-4-14
在线时间
2780 小时
发表于 2021-3-6 23:49:20 | 显示全部楼层
http://elm-chan.org/fsw/ff/doc/size.html
给了个函数#define f_size(fp) ((fp)->obj.objsize)
这个里面FIL----FFOBJID        obj;  -----FSIZE_t        objsize;
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则



关闭

原子哥极力推荐上一条 /2 下一条

正点原子公众号

QQ|手机版|OpenEdv-开源电子网 ( 粤ICP备12000418号-1 )

GMT+8, 2025-6-11 05:26

Powered by OpenEdv-开源电子网

© 2001-2030 OpenEdv-开源电子网

快速回复 返回顶部 返回列表