|
下面是制作MP3程序中有关FAT的程序。有些地方看不懂,盼高手指点一下。大致意思是通过文件起始簇号该文件在FAT表中对应的簇号的记录,也就是文件的下一簇簇号。if(FAT32_Enable)offset = cluster/128;是不是查找这个簇号在FAT表所在的扇区?为什么FAT32要除以128呢?
还有后面的offset=cluster%128;//find the position, sector=((unsigned long *)buffer)[offset];是不是查找簇号在FAT表中的所在扇区的偏移,然后读出该偏移的数据,也就是下一簇号的记录?
反正我搞得稀里湖涂的。winhex我用得不好,要是有个教程就好了,哪里有下的啊
//读下一簇簇号
//Return the cluster number of next cluster of file
//Suitable for system which has limited RAM
unsigned long FAT_NextCluster(unsigned long cluster)
{
BYTE buffer[512];
DWORD sector;
DWORD offset;
if(FAT32_Enable)offset = cluster/128;//??
else offset = cluster/256;//??
if(cluster<2)return 0x0ffffff8;//??
sector=FirstFATSector+offset;//calculate the actual sector
//文件所在的簇在FAT表内的偏移
if(FAT_ReadSector(sector,buffer))return 0x0ffffff8;//read fat table / return 0xfff8 when error occured
if(FAT32_Enable)
{
offset=cluster%128;//find the position,
sector=((unsigned long *)buffer)[offset];
}
else
{
offset=cluster%256;//find the position
sector=((unsigned int *)buffer)[offset];
}
return (unsigned long)sector;//return the cluste number
} |
阿莫论坛20周年了!感谢大家的支持与爱护!!
曾经有一段真挚的爱情摆在我的面前,我没有珍惜,现在想起来,还好我没有珍惜……
|