Data recovery and disk repair questions and discussions related to old-fashioned SATA, SAS, SCSI, IDE, MFM hard drives - any type of storage device that has moving parts
May 16th, 2014, 12:19
Hi,
In FAT system, the directory will have a size of 0, in such a case, how to know the number of entries in the directory. There seems no field records the total number of entries in the directory either.
Current I will check all the entries under a directory, and don’t know how to end the loop like below:
While (TRUE)
{
Read an entry from the directory data
Process the entry
Advance the offset to the next entry
}
Thanks
Alan
May 16th, 2014, 16:52
Can you show us what you mean by "directory data"?
I know how to locate all the directory entries manually with a hex editor, but that doesn't appear to be what you want.
May 16th, 2014, 19:56
The "directory data" are the data that store the entries for a directory, each entry is 16 byte long
May 16th, 2014, 20:05
You need to locate the entry for the first cluster of the directory in the FAT. This entry will be the first in a chain of clusters. It will point to the next cluster in the chain, and this second entry will point to the third cluster in the chain, and so on until you reach an "end of file" cluster.
The location of the two copies of the FAT will be recorded in the boot sector of the volume, as will the cluster size in sectors.
May 17th, 2014, 2:22
cant you do something similar to when we want to program something with an arbitrary number of bytes, words, lines etc?
change your code to something like:
- Code:
dir_entries.count = 0;
While (dir_entries.exists)
{
Read an entry from the directory data
if (dir_entries.exists)
{
dir_entries.count++
Process the entry
Advance the offset to the next entry
}
else
{
output dir_entries.count
}
}
obviously very rough and ready code, but general principle of an unknown amount if it isn't actually stored anywhere you have to count it.
May 19th, 2014, 6:33
chcw wrote:In FAT system, the directory will have a size of 0
In FAT directory size is always 0.
chcw wrote:how to know the number of entries in the directory
You need to go through the list until you face a zero record.
If you've reached the end of the cluster, then go to file allocation table to find out whether it's possible to continue.
May 19th, 2014, 19:35
depending on what language you want to program in, I would be surprised if many sourcecode examples don't already exist in some open source project. Try sourceforge github search and also asking at stack overflow may be a good idea.
Powered by phpBB © phpBB Group.