|
楼主 |
发表于 2008-5-13 12:40:49
|
显示全部楼层
RE:九天论道-谈单片机程序的编程风格
在底层函数基础上FAT16的实现,可惜有些功能没完全实现
/*********************************************************************
** Module Name: efat.c **
** Author: Huozq **
** Version: 1.0 **
** CreateDate: 2001-07-15 **
** Description: Encapsolution similar file system **
** Remark: **
** Revision History: 2001-07-15 **
**********************************************************************/
#include "..\include\DataType.h"
#include "..\include\Fat16.h"
#include "..\include\Atapi_OEM_Data.h"
//May be for public use
void e_strcpy(UCHAR *s, UCHAR *d);
void e_strncpy(UCHAR *s, UCHAR *d, UWORD l);
SWORD e_strcmp(UCHAR *s, UCHAR *d);
typedef struct
{
UWORD Bytes_Per_Sector;
UWORD Sectors_Per_Cluster;
UWORD FAT_Number;
UWORD Root_Item_Number;
UWORD Sectors_Per_FAT;
} DISK_PARAMETER;
DISK_PARAMETER Disk_Parameter;
//Store file parameter
UCHAR Para_Buffer[512];
/*****************************************************************************
** Prototype: SWORD Get_Disk_Information(DISK_INFORMATION *ptrInfor); **
** Description: Get the information of the disk **
** Input Parameter:ptrInfor--The information about the disk **
** Return: Error Code **
******************************************************************************/
SWORD Get_Disk_Information(DISK_INFORMATION *ptrInfor)
{
UWORD errno,i;
UCHAR filename[12];
UCHAR *buffer;
//Read the information of index
while( errno = Packet_Drive_Ready() ) ;
if( errno = Packet_Read(0,1,Para_Buffer) ) return errno;
//Point to the head of Para_Buffer
buffer=Para_Buffer;
//Sum the total file number and total song number
ptrInfor->Total_Song_Number = *(buffer+1);
ptrInfor->Total_File_Number = *(buffer+1);
//Locate to file information
buffer+=0x20;
buffer+=0x04;
//Get the file name and length
for( i=0; i< ptrInfor->Total_Song_Number; i++,buffer+=8 )
{
e_strcpy( (UCHAR *)"EWORLD",filename);
filename[6]=i+1+0x30;
e_strcpy( (UCHAR *)".DEC",filename+7);
e_strcpy(filename,ptrInfor->Song_Infor.Song_Name);
ptrInfor->Song_Infor.Song_Length= \
(*(buffer+1)) |
|