📄 file_io.c
字号:
/*-------------------------------------------------------------
FileName : file_io.c
Created by : Datazyb
Created Date: 2006.4.8
Function : read or write file with fat filesystem
Comments : These are high level operations.
LastModified: 2007.5.2, for printing file name to pc
--------------------------------------------------------------*/
#include "file_io.h"
//**************************************************************
//Read a sector of file(512 bytes)
void read_a_sector_file(unsigned char *buffer)
//**************************************************************
{
dword sector;
if(sectorPos==Sectors_Per_Cluster)
{
//if whole cluster is already read then
//a new cluster must be read by looking into FAT
currentCluster=findNextCluster();
readPos=0;
sectorPos=0;
}
//get lba address
sector=clust2LBA(currentCluster)+sectorPos;
ATA_Read_Sector(sector, buffer);
sectorPos++;
filePos += 512;
}
//*********************************************************************
//Find UNICODE.BIN
//UNICODE.BIN is used for decoding chinese file name:)
byte findSystemFile(void)
//*********************************************************************
{
byte i; dword extension;
currentFileNum=0;
i=0;
while((i<1)&&(getDirEntry(0)==1))
{
extension = (*(dword *)fileExtension) & 0x00FFFFFF;
if((extension==0x004E4942)&&((fileName[0] & 0x55)==0x55))
{
tableStartCluster=currentCluster;
tableFileSize=FileSize;
i++;
} //UNICODE.BIN file address
} //while((i<1)&&(getDirEntry(0)==1))
if(i==1) return 1;
else return 0; //Missing UNICODE.BIN
}
void save_file_info(void)
{
byte i;
currentFileInfo.startCluster = currentCluster;
currentFileInfo.fileSize = FileSize;
for(i=0; i<3; i++)
{currentFileInfo.fileExtName[i] = fileExtension[i];};
currentFileInfo.fileNumber = currentFileNum;
}
void load_file_info(void)
{
byte i;
currentCluster = currentFileInfo.startCluster;
FileSize = currentFileInfo.fileSize;
for(i=0; i<3; i++)
{fileExtension[i] = currentFileInfo.fileExtName[i];};
currentFileNum = currentFileInfo.fileNumber;
}
/*------------------- end of file_io.c ----------------------*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -