大学生
最后登录1970-1-1
在线时间 小时
注册时间2022-12-8
|
问题及现象描述 :
我从FLASH内复制的文件到SD卡,然后用f_unlink()删除SD卡上的所有文件内容。
每次都只能删除一部分文件,另一部分文件报的结果是FR_WRITE_PROTECTED。
重置开发板,再来一遍,那些上次报FR_WRITE_PROTECTED的文件有部分这次又可以删除。
到最后有几个文件会无法删除。
下面是函数代码 :--------------------------------------------------
// 删除指定路径下所有文件
FRESULT fatfs_delete_all_file(char* path)
{
int i = 0;
u32 nCount = 0;
FRESULT res = FR_OK;
file_num = 0;
fatfs_scan_files(path); // 先扫描文件,将所有文件路径存入列表
for(i = 0 ; i < file_num;i++){
//拼接成新路径
//sprintf(absolute_path,"%s/%s",path,fn);
// nCount = 0xfffff;
// for(; nCount != 0; nCount--);
res = f_unlink(all_file_list);
printf("f_unlink %d.%s res=%d\n",i+1,all_file_list ,res);
}
return res;
}
下面是串口打印信息 :----------------------------------------------------------------
[2023-01-06 17:25:05.878]# RECV ASCII>
****** 这是一个删除SD卡上所有文件的测试 ******
>> 0:文件系统挂载成功,可以进行读写测试
1.0:/FatFs读写测试文件.txt
2.0:/FatFstest1.txt
3.0:/srcdata_new/Note/new.txt
4.0:/srcdata_new/Note/使用之前.txt
5.0:/srcdata_new/Picture/cat.gif
6.0:/srcdata_new/Picture/football.bmp
7.0:/srcdata_new/Picture/LuFuu.jpg
8.0:/srcdata_new/Picture/round.gif
9.0:/srcdata_new/Picture/sunset.bmp
10.0:/srcdata_new/System/messagelist.txt
11.0:/srcdata_new/System Volume Information/WPSettings.dat
12.0:/srcdata_new/System Volume Information/IndexerVolumeGuid
13.0:/srcdata_new/TestDir/testdir.txt
14.0:/srcdata_new/GB2312_H1616.FON
15.0:/srcdata_new/GB2312_H3232.FON
16.0:/srcdata_new/HZLIB.bin
17.0:/srcdata_new/songti.xbf
18.0:/srcdata_new/UNIGBK.BIN
19.0:/srcdata_new/__秉火F103_srcdata.txt
20.0:/srcdata/GB2312_H1616.FON
21.0:/srcdata/GB2312_H3232.FON
22.0:/srcdata/HZLIB.bin
23.0:/srcdata/Note/new.txt
24.0:/srcdata/Note/使用之前.txt
25.0:/srcdata/Picture/cat.gif
26.0:/srcdata/Picture/football.bmp
27.0:/srcda
[2023-01-06 17:25:05.989]# RECV ASCII>
ta/Picture/LuFuu.jpg
28.0:/srcdata/Picture/round.gif
29.0:/srcdata/Picture/sunset.bmp
30.0:/srcdata/songti.xbf
31.0:/srcdata/System/messagelist.txt
32.0:/srcdata/UNIGBK.BIN
33.0:/srcdata/__秉火F103_srcdata.txt
34.0:/srcdata/System Volume Information/WPSettings.dat
35.0:/srcdata/System Volume Information/IndexerVolumeGuid
36.0:/srcdata/TestDir/testdir.txt
37.0:/srcdata_00000000/GB2312_H1616.FON
38.0:/srcdata_00000000/GB2312_H3232.FON
39.0:/srcdata_00000000/HZLIB.bin
40.0:/srcdata_00000000/Note/new.txt
41.0:/srcdata_00000000/Note/使用之前.txt
42.0:/srcdata_00000000/Picture/cat.gif
43.0:/srcdata_00000000/Picture/football.bmp
44.0:/srcdata_00000000/Picture/LuFuu.jpg
45.0:/srcdata_00000000/Picture/round.gif
46.0:/srcdata_00000000/Picture/sunset.bmp
47.0:/srcdata_00000000/songti.xbf
48.0:/srcdata_00000000/System/messagelist.txt
49.0:/srcdata_00000000/UNIGBK.BIN
50.0:/srcdata_00000000/__秉火F103_srcdata.txt
51.0:/srcdata_00000000/System Volume Information/WPSettings.dat
52.0:/srcdata_0000000
[2023-01-06 17:25:06.114]# RECV ASCII>
0/System Volume Information/IndexerVolumeGuid
53.0:/srcdata_00000000/TestDir/testdir.txt
f_unlink 1. res=10
f_unlink 2.0:/FatFs读写测试文件.txt res=10
f_unlink 3.0:/FatFstest1.txt res=10
f_unlink 4.0:/srcdata_new/Note/new.txt res=10
f_unlink 5.0:/srcdata_new/Note/使用之前.txt res=10
f_unlink 6.0:/srcdata_new/Picture/cat.gif res=0
f_unlink 7.0:/srcdata_new/Picture/football.bmp res=0
f_unlink 8.0:/srcdata_new/Picture/LuFuu.jpg res=0
f_unlink 9.0:/srcdata_new/Picture/round.gif res=0
f_unlink 10.0:/srcdata_new/Picture/sunset.bmp res=10
f_unlink 11.0:/srcdata_new/System/messagelist.txt res=10
f_unlink 12.0:/srcdata_new/System Volume Information/WPSettings.dat res=10
f_unlink 13.0:/srcdata_new/System Volume Information/IndexerVolumeGuid res=10
f_unlink 14.0:/srcdata_new/TestDir/testdir.txt res=0
f_unlink 15.0:/srcdata_new/GB2312_H1616.FON res=0
f_unlink 16.0:/srcdata_new/GB2312_H3232.FON res=0
f_unlink 17.0:/srcdata_new/HZLIB.bin res=0
f_unlink 18.0:/srcdata_new/songti.xbf res=10
f_unlink 19.0:/srcdata_new/UNIGBK
[2023-01-06 17:25:06.267]# RECV ASCII>
.BIN res=10
f_unlink 20.0:/srcdata_new/__秉火F103_srcdata.txt res=10
f_unlink 21.0:/srcdata/GB2312_H1616.FON res=10
f_unlink 22.0:/srcdata/GB2312_H3232.FON res=0
f_unlink 23.0:/srcdata/HZLIB.bin res=0
f_unlink 24.0:/srcdata/Note/new.txt res=0
f_unlink 25.0:/srcdata/Note/使用之前.txt res=0
f_unlink 26.0:/srcdata/Picture/cat.gif res=10
f_unlink 27.0:/srcdata/Picture/football.bmp res=10
f_unlink 28.0:/srcdata/Picture/LuFuu.jpg res=10
f_unlink 29.0:/srcdata/Picture/round.gif res=10
f_unlink 30.0:/srcdata/Picture/sunset.bmp res=0
f_unlink 31.0:/srcdata/songti.xbf res=0
f_unlink 32.0:/srcdata/System/messagelist.txt res=0
f_unlink 33.0:/srcdata/UNIGBK.BIN res=0
f_unlink 34.0:/srcdata/__秉火F103_srcdata.txt res=10
f_unlink 35.0:/srcdata/System Volume Information/WPSettings.dat res=10
f_unlink 36.0:/srcdata/System Volume Information/IndexerVolumeGuid res=10
f_unlink 37.0:/srcdata/TestDir/testdir.txt res=10
f_unlink 38.0:/srcdata_00000000/GB2312_H1616.FON res=0
f_unlink 39.0:/srcdata_00000000/GB2312_H3232.FON res=0
f_u
[2023-01-06 17:25:06.406]# RECV ASCII>
nlink 40.0:/srcdata_00000000/HZLIB.bin res=0
f_unlink 41.0:/srcdata_00000000/Note/new.txt res=0
f_unlink 42.0:/srcdata_00000000/Note/使用之前.txt res=10
f_unlink 43.0:/srcdata_00000000/Picture/cat.gif res=10
f_unlink 44.0:/srcdata_00000000/Picture/football.bmp res=10
f_unlink 45.0:/srcdata_00000000/Picture/LuFuu.jpg res=10
f_unlink 46.0:/srcdata_00000000/Picture/round.gif res=0
f_unlink 47.0:/srcdata_00000000/Picture/sunset.bmp res=0
f_unlink 48.0:/srcdata_00000000/songti.xbf res=0
f_unlink 49.0:/srcdata_00000000/System/messagelist.txt res=0
f_unlink 50.0:/srcdata_00000000/UNIGBK.BIN res=10
f_unlink 51.0:/srcdata_00000000/__秉火F103_srcdata.txt res=10
f_unlink 52.0:/srcdata_00000000/System Volume Information/WPSettings.dat res=10
f_unlink 53.0:/srcdata_00000000/System Volume Information/IndexerVolumeGuid res=10
[2023-01-06 17:25:50.772]# RECV ASCII>
****** 这是一个删除SD卡上所有文件的测试 ******
>> 0:文件系统挂载成功,可以进行读写测试
1.0:/FatFs读写测试文件.txt
2.0:/FatFstest1.txt
3.0:/srcdata_new/Note/new.txt
4.0:/srcdata_new/Note/使用之前.txt
5.0:/srcdata_new/Picture/sunset.bmp
6.0:/srcdata_new/System/messagelist.txt
7.0:/srcdata_new/System Volume Information/WPSettings.dat
8.0:/srcdata_new/System Volume Information/IndexerVolumeGuid
9.0:/srcdata_new/songti.xbf
10.0:/srcdata_new/UNIGBK.BIN
11.0:/srcdata_new/__秉火F103_srcdata.txt
12.0:/srcdata/GB2312_H1616.FON
13.0:/srcdata/Picture/cat.gif
14.0:/srcdata/Picture/football.bmp
15.0:/srcdata/Picture/LuFuu.jpg
16.0:/srcdata/Picture/round.gif
17.0:/srcdata/__秉火F103_srcdata.txt
18.0:/srcdata/System Volume Information/WPSettings.dat
19.0:/srcdata/System Volume Information/IndexerVolumeGuid
20.0:/srcdata/TestDir/testdir.txt
21.0:/srcdata_00000000/Note/使用之前.txt
22.0:/srcdata_00000000/Picture/cat.gif
23.0:/srcdata_00000000/Picture/football.bmp
24.0:/srcdata_00000000/Picture/LuFuu.
[2023-01-06 17:25:50.905]# RECV ASCII>
jpg
25.0:/srcdata_00000000/UNIGBK.BIN
26.0:/srcdata_00000000/__秉火F103_srcdata.txt
27.0:/srcdata_00000000/System Volume Information/WPSettings.dat
28.0:/srcdata_00000000/System Volume Information/IndexerVolumeGuid
29.0:/srcdata_00000000/TestDir/testdir.txt
f_unlink 1. res=10
f_unlink 2.0:/FatFs读写测试文件.txt res=10
f_unlink 3.0:/FatFstest1.txt res=10
f_unlink 4.0:/srcdata_new/Note/new.txt res=10
f_unlink 5.0:/srcdata_new/Note/使用之前.txt res=10
f_unlink 6.0:/srcdata_new/Picture/sunset.bmp res=0
f_unlink 7.0:/srcdata_new/System/messagelist.txt res=0
f_unlink 8.0:/srcdata_new/System Volume Information/WPSettings.dat res=0
f_unlink 9.0:/srcdata_new/System Volume Information/IndexerVolumeGuid res=0
f_unlink 10.0:/srcdata_new/songti.xbf res=10
f_unlink 11.0:/srcdata_new/UNIGBK.BIN res=10
f_unlink 12.0:/srcdata_new/__秉火F103_srcdata.txt res=10
f_unlink 13.0:/srcdata/GB2312_H1616.FON res=10
f_unlink 14.0:/srcdata/Picture/cat.gif res=0
f_unlink 15.0:/srcdata/Picture/football.bmp res=0
f_unlink 16.0:/srcdat
[2023-01-06 17:25:51.048]# RECV ASCII>
a/Picture/LuFuu.jpg res=0
f_unlink 17.0:/srcdata/Picture/round.gif res=0
f_unlink 18.0:/srcdata/__秉火F103_srcdata.txt res=10
f_unlink 19.0:/srcdata/System Volume Information/WPSettings.dat res=10
f_unlink 20.0:/srcdata/System Volume Information/IndexerVolumeGuid res=10
f_unlink 21.0:/srcdata/TestDir/testdir.txt res=10
f_unlink 22.0:/srcdata_00000000/Note/使用之前.txt res=0
f_unlink 23.0:/srcdata_00000000/Picture/cat.gif res=0
f_unlink 24.0:/srcdata_00000000/Picture/football.bmp res=0
f_unlink 25.0:/srcdata_00000000/Picture/LuFuu.jpg res=0
f_unlink 26.0:/srcdata_00000000/UNIGBK.BIN res=10
f_unlink 27.0:/srcdata_00000000/__秉火F103_srcdata.txt res=10
f_unlink 28.0:/srcdata_00000000/System Volume Information/WPSettings.dat res=10
f_unlink 29.0:/srcdata_00000000/System Volume Information/IndexerVolumeGuid res=10
|
|