各位大神,请教一个问题:
使用SD卡和Flash做2个磁盘,将SD或flash做为卷0,程序都可以正常访问目录,文件,另外可以对卷1进行格式化,但是却访问不了卷1的目录;有没有知道什么问题的?
void ShowSDFiles(u8 index)
{
FILINFO finfo;
DIR dirs;
char path[100] = {""};
printf("
SD file system starting!
");
disk_initialize(index);
printf("f_mount %d
", f_mount(index, &fs));
printf("f_mkfs %d
", f_mkfs(index, 0, 512)); // SD 卡时为4096
printf("----------------------------------------------------
");
printf("f_opendir(&dirs, "/") = %d;
", f_opendir(&dirs, "/"));
if(f_opendir(&dirs, path) == FR_OK)
{
while(f_readdir(&dirs, &finfo) == FR_OK)
{
if(!finfo.fname[0]) break;
if (finfo.fattrib & AM_ARC)
{
printf(" file name is: %s ", finfo.fname);
printf("file size is: %d
", finfo.fsize);
if(File_type_Check((u8 *)finfo.fname, "txt"))
{
printf("file contex is:");
res = f_open(&fsrc, finfo.fname, FA_OPEN_EXISTING | FA_READ);
while(1)
{
memset(buffer, 0, sizeof(buffer));
if(f_gets(buffer, 512, &fsrc))
{
printf("%s", buffer);
}
else break;
}
f_close(&fsrc);
}
}
else
{
printf("Path name is: %s
", finfo.fname);
continue; //break;
}
}
res = f_open(&fsrc, "armjishu.txt", FA_CREATE_ALWAYS | FA_WRITE);
res = f_write(&fsrc, &armjishu, sizeof(text), &bw);
f_close(&fsrc);
else
{
printf(" err: f_opendir
");
}
printf("----------------------------------------------------
");
f_mount(index, NULL);
} |