加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

如何检测FAT32数据区中的目录结尾?

发布时间:2020-12-16 03:47:06 所属栏目:百科 来源:网络整理
导读:我正在使用磁盘文件.由于目录结构中目录的大小为0,我想知道如何检测磁盘上目录文件的结尾. DIR_Name[0] == 0x00 上面检测目录结尾的方法似乎不可靠.我在wiki上发现FAT32中根目录的大小固定为512个条目,但其他子目录呢.我可能需要使用FAT和群集号遍历目录. 解
我正在使用磁盘文件.由于目录结构中目录的大小为0,我想知道如何检测磁盘上目录文件的结尾.
DIR_Name[0] == 0x00

上面检测目录结尾的方法似乎不可靠.我在wiki上发现FAT32中根目录的大小固定为512个条目,但其他子目录呢.我可能需要使用FAT和群集号遍历目录.

解决方法

从 the first Google search result开始,“fat32 on disk format”,第24页:

When a directory is created,a file with the ATTR_DIRECTORY bit set in
its DIR_Attr field,you set its DIR_FileSize to 0. DIR_FileSize is not
used and is always 0 on a file with the ATTR_DIRECTORY attribute
(directories are sized by simply following their cluster chains to the
EOC mark).

另外:FAT32根目录大小不固定为512个条目;其大小的确定方式与其他任何目录完全相同.

从another reliable source开始:

Reading Directories

The first step in reading directories is finding and reading the root
directory. On a FAT 12 or FAT 16 volumes the root directory is at a
fixed position immediately after the File Allocation Tables:

first_root_dir_sector = first_data_sector - root_dir_sectors;

In FAT32,root directory appears in data area on given cluster and can be
a cluster chain.

root_cluster_32 = extBS_32->root_cluster;

强调补充说.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读