fat.c
来自「51环境下的FAT及FAT32文件系统源码」· C语言 代码 · 共 62 行
C
62 行
#include "common.h"
#include "fat.h"
#include "tpbulk.h"
#include "usb.h"
////////////////////////////////////////
extern SYS_INFO_BLOCK xdata DeviceInfo;
extern FILE_INFO xdata ThisFile;
unsigned int FatSectorPointer=-1;
extern UINT8 xdata FATBUF[512];
////////////////////////////////////////
unsigned int ThisFatSecNum(unsigned int clusterNum)
{
unsigned int temp;
temp=clusterNum*2;
temp=temp/DeviceInfo.BPB_BytesPerSec;
temp=temp+DeviceInfo.FatStartSector;
return temp;
}
unsigned long FirstSectorofCluster(unsigned int clusterNum)
{
unsigned long temp;
temp=clusterNum-2;
temp=temp*DeviceInfo.BPB_SecPerClus;
temp=temp+DeviceInfo.FirstDataSector;
return temp;
}
unsigned int ThisFatEntOffset(unsigned int clusterNum)
{
unsigned int temp1,temp2;
temp1=2*clusterNum;
temp2=temp1/DeviceInfo.BPB_BytesPerSec;
temp1=temp1-temp2*DeviceInfo.BPB_BytesPerSec;
return temp1;
}
unsigned int GetNextClusterNum(unsigned int clusterNum)
{
unsigned int xxgFatSecNum,xxgFatEntOffset;
xxgFatSecNum=ThisFatSecNum(clusterNum);
xxgFatEntOffset=ThisFatEntOffset(clusterNum);
if(FatSectorPointer!=xxgFatSecNum)
{
if(!RBC_ReadOneSec(xxgFatSecNum, FATBUF))
return 0xFFFF;
FatSectorPointer=xxgFatSecNum;
}
///////////////////////////////////////////////////
clusterNum=FATBUF[xxgFatEntOffset+1];
clusterNum=clusterNum<<8;
clusterNum+=FATBUF[xxgFatEntOffset];
return clusterNum;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?