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

前端之家收集整理的这篇文章主要介绍了如何检测FAT32数据区中的目录结尾?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在使用磁盘文件.由于目录结构中目录的大小为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;

强调补充说.

猜你在找的C&C++相关文章