//遍历文件
//path:路径
//返回值:执行结果
u8 mf_scan_files(u8 * path)
{
FRESULT res;
char *fn;
char *p;
#if _USE_LFN
fileinfo.lfsize = _MAX_LFN * 2 + 1;
fileinfo.lfname = mymalloc(SRAMIN,fileinfo.lfsize);
#endif
res = f_opendir(&DirInfo,(const XCHAR*)path); //打开一个目录
if (res == FR_OK)
{
printf("\r\n");
while(1)
{
res = f_readdir(&DirInfo, &FilInfo); //读取目录下的一个文件
if (res != FR_OK || FilInfo.fname[0] == 0) break; //错误了/到末尾了,退出
#if _USE_LFN
fn = *fileinfo.lfname ? fileinfo.lfname : fileinfo.fname;
#else
fn = FilInfo.fname;
#endif
p=strstr(fn,"bin");
if(p!=NULL)
{
File_Name=fn;
break;
}
}
}
return res;
}
void FatReadDirTest(s8 *path)
{
// FRESULT res;
#if _USE_LFN//如果使能支持长文件名 先对下面两项初始化
fileinfo.lfsize=_MAX_LFN * 2 + 1;//
fileinfo.lfname=(TCHAR*)FileName;//
#endif
if(f_opendir(&DirInfo,(const XCHAR*)path) == FR_OK)
{
while(f_readdir(&DirInfo, &FilInfo) == FR_OK)
{
if(!FilInfo.fname[0]) break;
printf("%s/",path);//打印路径
#if _USE_LFN
printf("文件名:%s\r\n",fileinfo.lfname );//打印信息到串口
#else
printf("文件名:%s\r\n", FilInfo.fname);//
#endif
}
}
}