DIR_Name[0] == 0x00
上面检测目录结尾的方法似乎不可靠.我在wiki上发现FAT32中根目录的大小固定为512个条目,但其他子目录呢.我可能需要使用FAT和群集号遍历目录.
解决方法
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个条目;其大小的确定方式与其他任何目录完全相同.
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;
强调补充说.